@@ -462,7 +462,7 @@ analyseWords env = mapRTree lemma2fun
462462
463463 -- find all functions that are possible parses of the word in any appropriate category
464464 --- it is still possible that some other category is meant
465- getWordTrees wf w cs = case morphoFallback wf $ concatMap (parseWord w) cs of
465+ getWordTrees wf w cs = case concatMap (parseWord w) cs `ifEmpty` concatMap (parseWord ( map toLower w)) cs `ifEmpty` morphoFallback wf of
466466 [] -> case cs of
467467 [] -> (True ,[(newWordTree w unknownCat, unknownCat)])
468468 _ -> (True ,[(newWordTree w ec, ec) | c <- cs, let ec = either id id c, strFunExists ec]
@@ -473,7 +473,7 @@ analyseWords env = mapRTree lemma2fun
473473 -- | Return the first non-empty list
474474 ifEmpty [] xs = xs
475475 ifEmpty xs _ = xs
476- infixl 3 `ifEmpty`
476+ infixr 3 `ifEmpty`
477477
478478 -- Verify that a StrSomeCat function exists in grammar
479479 strFunExists c | Just typ <- functionType (pgfGrammar env) f = True
@@ -494,14 +494,13 @@ analyseWords env = mapRTree lemma2fun
494494
495495 -- Fall back to morphoanalysis if gf parse fails
496496 -- TODO: We might want to use the morphoanalysis for all words, not just when parse fails
497- morphoFallback :: String -> [(RTree Lemma , CId )] -> [( RTree CId , CId )]
498- morphoFallback w [] =
497+ morphoFallback :: String -> [(RTree CId , CId )]
498+ morphoFallback w =
499499 [(RTree name [] , c)
500500 | (name, _) <- lookupMorpho morpho w
501501 , Just tp <- pure $ functionType (pgfGrammar env) name
502502 , ([] , c, [] ) <- pure $ unType tp
503503 ]
504- morphoFallback _ xs = xs
505504
506505-- auxiliaries
507506-- newWordTree w c = RTree (mkCId (w ++ "_" ++ showCId c)) [] ---
0 commit comments