mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 11:19:32 -06:00
added command c-bracketedLinearize
This commit is contained in:
@@ -153,6 +153,8 @@ cpgfMain qsem command (t,(pgf,pc)) =
|
|||||||
"c-parse" -> withQSem qsem $
|
"c-parse" -> withQSem qsem $
|
||||||
out t=<< join (parse # input % start % limit % treeopts)
|
out t=<< join (parse # input % start % limit % treeopts)
|
||||||
"c-linearize" -> out t=<< lin # tree % to
|
"c-linearize" -> out t=<< lin # tree % to
|
||||||
|
"c-bracketedLinearize"
|
||||||
|
-> out t=<< bracketedLin # tree % to
|
||||||
"c-linearizeAll"-> out t=<< linAll # tree % to
|
"c-linearizeAll"-> out t=<< linAll # tree % to
|
||||||
"c-translate" -> withQSem qsem $
|
"c-translate" -> withQSem qsem $
|
||||||
out t=<<join(trans # input % to % start % limit%treeopts)
|
out t=<<join(trans # input % to % start % limit%treeopts)
|
||||||
@@ -224,6 +226,10 @@ cpgfMain qsem command (t,(pgf,pc)) =
|
|||||||
lin' tree (tos,unlex) =
|
lin' tree (tos,unlex) =
|
||||||
[makeObj ["to".=to,"text".=unlex (C.linearize c tree)]|(to,c)<-tos]
|
[makeObj ["to".=to,"text".=unlex (C.linearize c tree)]|(to,c)<-tos]
|
||||||
|
|
||||||
|
bracketedLin tree to = showJSON (lin' tree to)
|
||||||
|
bracketedLin' tree (tos,unlex) =
|
||||||
|
[makeObj ["to".=to,"brackets".=showJSON (C.bracketedLinearize c tree)]|(to,c)<-tos]
|
||||||
|
|
||||||
trans input@((from,_),_) to start mlimit (trie,jsontree) =
|
trans input@((from,_),_) to start mlimit (trie,jsontree) =
|
||||||
do parses <- parse' start mlimit input
|
do parses <- parse' start mlimit input
|
||||||
return $
|
return $
|
||||||
@@ -978,6 +984,15 @@ instance JSON PGF.BracketedString where
|
|||||||
makeObj ["cat".=cat, "fid".=fid, "index".=index, "fun".=fun, "children".=bs]
|
makeObj ["cat".=cat, "fid".=fid, "index".=index, "fun".=fun, "children".=bs]
|
||||||
showJSON (PGF.Leaf s) = makeObj ["token".=s]
|
showJSON (PGF.Leaf s) = makeObj ["token".=s]
|
||||||
|
|
||||||
|
#if C_RUNTIME
|
||||||
|
instance JSON C.BracketedString where
|
||||||
|
readJSON x = return (C.Leaf "")
|
||||||
|
showJSON (C.Bracket cat fid index fun bs) =
|
||||||
|
makeObj ["cat".=cat, "fid".=fid, "index".=index, "fun".=fun, "children".=bs]
|
||||||
|
showJSON C.BIND = makeObj ["bind".=True]
|
||||||
|
showJSON (C.Leaf s) = makeObj ["token".=s]
|
||||||
|
#endif
|
||||||
|
|
||||||
-- * PGF utilities
|
-- * PGF utilities
|
||||||
{-
|
{-
|
||||||
cat :: PGF -> Maybe PGF.Type -> PGF.Type
|
cat :: PGF -> Maybe PGF.Type -> PGF.Type
|
||||||
|
|||||||
Reference in New Issue
Block a user