mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-26 11:18:55 -06:00
Improvement to test script, distinguishes when input ends with whitespace
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
import PGF2
|
import PGF2
|
||||||
|
import qualified Data.Char as C
|
||||||
|
import qualified Data.List as L
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
@@ -8,8 +10,13 @@ main = do
|
|||||||
Just concr = M.lookup "FoodsEng" (languages pgf)
|
Just concr = M.lookup "FoodsEng" (languages pgf)
|
||||||
loop = do
|
loop = do
|
||||||
putStr "> "
|
putStr "> "
|
||||||
tks <- words <$> getLine
|
input <- getLine
|
||||||
let pr = complete concr (startCat pgf) (unwords (init tks)) (last tks) Nothing
|
let
|
||||||
|
(sent,pfx) =
|
||||||
|
if C.isSpace (last input)
|
||||||
|
then (input, "")
|
||||||
|
else let toks = words input in (unwords (init toks), last toks)
|
||||||
|
let pr = complete concr (startCat pgf) sent pfx Nothing
|
||||||
case pr of
|
case pr of
|
||||||
ParseOk x -> print x
|
ParseOk x -> print x
|
||||||
ParseFailed x s -> putStrLn $ "parse failed at " ++ show x ++ " " ++ s
|
ParseFailed x s -> putStrLn $ "parse failed at " ++ show x ++ " " ++ s
|
||||||
|
|||||||
Reference in New Issue
Block a user