I upgraded to gf 3.1 today and have some problems with incremental parser.
I was using incremental parsing with gf 3.0 in a way that it may
report the exact token which fails to parse (using initState,
finalState and extractExps functions) as shown below:
loop :: PGF -> Language -> Type -> String -> Abs.ErrM.Err [Tree]
loop pgf lang cat [] = fail $ "error: no text to parse"
loop pgf lang cat text = do
let state0 = initState pgf lang cat
finalState <- mkStates state0 (words text)
return $ extractExps finalState cat
mkStates :: ParseState -> [String] -> Abs.ErrM.Err ParseState
mkStates state0 [] = return state0
mkStates state0 (w:ws) = do
let state1 = Parse.nextState state0 w
case state1 of
Nothing -> fail $ "error: no Parse at token: " ++ w
Just state2 -> mkStates state2 ws
I think these state functions are very useful and may benefit a lot to
the users.
So my question is: how can I restore the above mentioned functionality
in gf 3.1 ?
Thanks in advance
/Humayoun
- nextState now returns:
Either ErrorState ParseState
instead of
Maybe ParseState
You have to replace Nothing with 'Left es' and 'Just ps' with 'Right
ps'. The error state is new experimental feature which makes it
possible to do some kind of robust parsing.
- extractExps is called extractTrees now.
--
Muhammad Humayoun
PhD student
University of Savoie
Laboratory of Mathematics
Batiment Le Chablais, office 020
73376 Le Bourget-du-Lac Cedex, France
Tel: (+33/0) 4.79.75.85.85 extension 70.95
Fax: (+33/0) 4.79.75.81.42
Web: http://www.lama.univ-savoie.fr/~humayoun/