summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorjohn <john@johnjcamilleri.com>2014-07-11 09:25:26 +0000
committerjohn <john@johnjcamilleri.com>2014-07-11 09:25:26 +0000
commit9b496084512ca94ca7fb96fd606e749d02022aad (patch)
treed52b20ccca47bd313f0355cf16e3ecfb6fe3797c /src/runtime
parent0222d2440c6b6246da2a5d8d397bb1d766419c0e (diff)
PGF web service: Return additional completion info with 'full' flag
BETA! The 'complete' command now has a new flag 'full' which when set returns additional info about completions. Without 'full' flag (default): [ { "from": "PhrasebookEng", "brackets": { "cat": "_", "fid": 0, "index": 0, "fun": "_", "children": [ { "token": "the" } ] }, "text": "su", "completions": [ "supermarket", "suspect" ] } ] With full=true or full=yes: [ { "from": "PhrasebookEng", "brackets": { "cat": "_", "fid": 0, "index": 0, "fun": "_", "children": [ { "token": "the" } ] }, "text": "su", "completions": [ { "token": "supermarket", "funs": [ { "fid": 421, "fun": "Supermarket", "hyps": [], "cat": "PlaceKind" } ] }, { "token": "suspect", "funs": [ { "fid": 445, "fun": "Suspect", "hyps": [], "cat": "Property" } ] } ] } ]
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/haskell/PGF.hs1
-rw-r--r--src/runtime/haskell/PGF/Parse.hs12
2 files changed, 13 insertions, 0 deletions
diff --git a/src/runtime/haskell/PGF.hs b/src/runtime/haskell/PGF.hs
index c1d903f4f..77eac1ada 100644
--- a/src/runtime/haskell/PGF.hs
+++ b/src/runtime/haskell/PGF.hs
@@ -88,6 +88,7 @@ module PGF(
Parse.initState, Parse.nextState, Parse.getCompletions, Parse.recoveryStates,
Parse.ParseInput(..), Parse.simpleParseInput, Parse.mkParseInput,
Parse.ParseOutput(..), Parse.getParseOutput,
+ Parse.getContinuationInfo,
-- ** Generation
-- | The PGF interpreter allows automatic generation of
diff --git a/src/runtime/haskell/PGF/Parse.hs b/src/runtime/haskell/PGF/Parse.hs
index 0ab1ad9fb..ad31cc25f 100644
--- a/src/runtime/haskell/PGF/Parse.hs
+++ b/src/runtime/haskell/PGF/Parse.hs
@@ -10,6 +10,7 @@ module PGF.Parse
, ParseOutput(..), getParseOutput
, parse
, parseWithRecovery
+ , getContinuationInfo
) where
import Data.Array.IArray
@@ -503,6 +504,17 @@ data Chart
type Continuation = TrieMap.TrieMap Token ActiveSet
+-- | Return the Continuation of a Parsestate with exportable types
+-- Used by PGFService
+getContinuationInfo :: ParseState -> Map.Map [Token] [(FunId, CId)]
+getContinuationInfo pstate = Map.map (map f . Set.toList) contMap
+ where
+ PState abstr concr chart cont = pstate
+ contMap = Map.fromList (TrieMap.toList cont) -- always get [([], _::ActiveSet)]
+ f :: Active -> (FunId,CId)
+ f (Active int dotpos funid seqid pargs ak) = (funid, cid)
+ where CncFun cid _ = cncfuns concr ! funid
+
----------------------------------------------------------------
-- Error State
----------------------------------------------------------------