math with gfcc

This commit is contained in:
aarne
2007-09-20 13:31:24 +00:00
parent 74ad9aa2fd
commit 8eadf828a9
3 changed files with 67 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
module Main where
import GF.Canon.GFCC.GFCCAPI
import TransferDefGFCC (transfer)
main :: IO ()
main = do
gr <- file2grammar "math.gfcc"
loop (translate transfer gr)
loop :: (String -> String) -> IO ()
loop trans = do
s <- getLine
if s == "quit" then putStrLn "bye" else do
putStrLn $ trans s
loop trans
translate :: (Tree -> Tree) -> MultiGrammar -> String -> String
translate tr gr = unlines . map transLine . lines where
transLine s = case parseAllLang gr "Question" s of
(lg,t:_):_ -> linearize gr lg (tr t)
_ -> "NO PARSE"