forked from GitHub/gf-core
Spring cleaning
Nothing major...
This commit is contained in:
2
Makefile
2
Makefile
@@ -2,7 +2,7 @@
|
||||
|
||||
all: build
|
||||
|
||||
dist/setup-config: gf.cabal Setup.hs
|
||||
dist/setup-config: gf.cabal Setup.hs WebSetup.hs
|
||||
cabal configure
|
||||
|
||||
build: dist/setup-config
|
||||
|
||||
@@ -26,7 +26,7 @@ document.write('<div style="text-align: right"> <form onsubmit="return sitesear
|
||||
<img id=gflogo class=grow src="doc/Logos/gf0.png" alt="">
|
||||
<script>
|
||||
if(document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"))
|
||||
document.getElementById("gflogo").src="doc/Logos/gf0.svg"
|
||||
document.getElementById("gflogo").src="doc/Logos/gf1.svg"
|
||||
</script>
|
||||
<H1>Grammatical Framework</H1>
|
||||
<P>
|
||||
|
||||
@@ -31,7 +31,9 @@ module GF.Data.Operations (-- * misc functions
|
||||
lookupTree, --lookupTreeMany,
|
||||
lookupTreeManyAll, updateTree,
|
||||
buildTree, filterBinTree,
|
||||
sorted2tree, mapTree, mapMTree, tree2list,
|
||||
--sorted2tree,
|
||||
mapTree, --mapMTree,
|
||||
tree2list,
|
||||
|
||||
|
||||
-- * printing
|
||||
@@ -167,16 +169,16 @@ updateTree (a,b) = Map.insert a b
|
||||
|
||||
buildTree :: (Ord a) => [(a,b)] -> BinTree a b
|
||||
buildTree = Map.fromList
|
||||
|
||||
{-
|
||||
sorted2tree :: Ord a => [(a,b)] -> BinTree a b
|
||||
sorted2tree = Map.fromAscList
|
||||
|
||||
-}
|
||||
mapTree :: ((a,b) -> c) -> BinTree a b -> BinTree a c
|
||||
mapTree f = Map.mapWithKey (\k v -> f (k,v))
|
||||
|
||||
{-
|
||||
mapMTree :: (Ord a,Monad m) => ((a,b) -> m c) -> BinTree a b -> m (BinTree a c)
|
||||
mapMTree f t = liftM Map.fromList $ sequence [liftM ((,) k) (f (k,x)) | (k,x) <- Map.toList t]
|
||||
|
||||
-}
|
||||
filterBinTree :: Ord a => (a -> b -> Bool) -> BinTree a b -> BinTree a b
|
||||
filterBinTree = Map.filterWithKey
|
||||
|
||||
|
||||
@@ -304,7 +304,7 @@ pgfMain command (t,pgf) =
|
||||
"linearize" -> o =<< doLinearize pgf # tree % to
|
||||
"linearizeAll" -> o =<< doLinearizes pgf # tree % to
|
||||
"linearizeTable" -> o =<< doLinearizeTabular pgf # tree % to
|
||||
"random" -> cat >>= \c -> depth >>= \dp -> limit >>= \l -> to >>= \to -> liftIO (doRandom pgf c dp l to) >>= o
|
||||
"random" -> o =<< join (doRandom pgf # cat % depth % limit % to)
|
||||
"generate" -> o =<< doGenerate pgf # cat % depth % limit % to
|
||||
"translate" -> o =<< doTranslate pgf # input % cat % to % limit %trie
|
||||
"translategroup" -> o =<< doTranslateGroup pgf # input % cat % to % limit
|
||||
@@ -312,10 +312,7 @@ pgfMain command (t,pgf) =
|
||||
"grammar" -> o =<< doGrammar pgf # requestAcceptLanguage
|
||||
"abstrtree" -> outputGraphviz =<< abstrTree pgf # graphvizOptions % tree
|
||||
"alignment" -> outputGraphviz =<< alignment pgf # tree % to
|
||||
"parsetree" -> do t <- tree
|
||||
Just l <- from
|
||||
opts <- graphvizOptions
|
||||
outputGraphviz (parseTree pgf l opts t)
|
||||
"parsetree" -> outputGraphviz =<< parseTree pgf # from1 % graphvizOptions % tree
|
||||
"abstrjson" -> o . jsonExpr =<< tree
|
||||
"browse" -> join $ doBrowse pgf # optId % cssClass % href % format "html" % getIncludePrintNames
|
||||
"external" -> do cmd <- getInput "external"
|
||||
@@ -595,8 +592,9 @@ doLinearizeTabular pgf tree (tos,unlex) = showJSON
|
||||
| (ps,ts)<-texts]]
|
||||
| (to,texts) <- linearizeTabular pgf tos tree]
|
||||
|
||||
doRandom :: PGF -> Maybe PGF.Type -> Maybe Int -> Maybe Int -> To -> IO JSValue
|
||||
doRandom :: PGF -> Maybe PGF.Type -> Maybe Int -> Maybe Int -> To -> CGI JSValue
|
||||
doRandom pgf mcat mdepth mlimit to =
|
||||
liftIO $
|
||||
do g <- newStdGen
|
||||
let trees = PGF.generateRandomDepth g pgf cat (Just depth)
|
||||
return $ showJSON
|
||||
|
||||
Reference in New Issue
Block a user