Skip to content

Commit d94a5fc

Browse files
committed
If parse fails, try parsing the lowercase version
1 parent 74185a1 commit d94a5fc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

UD2GF.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ analyseWords env = mapRTree lemma2fun
471471

472472
-- find all functions that are possible parses of the word in any appropriate category
473473
--- it is still possible that some other category is meant
474-
getWordTrees wf w cs = case morphoFallback wf $ concatMap (parseWord w) cs of
474+
getWordTrees wf w cs = case concatMap (parseWord w) cs `ifEmpty` concatMap (parseWord (map toLower w)) cs `ifEmpty` morphoFallback wf of
475475
[] -> case cs of
476476
[] -> (True,[(newWordTree w unknownCat, unknownCat)])
477477
_ -> (True,[(newWordTree w ec, ec) | c <- cs, let ec = either id id c, strFunExists ec]
@@ -482,7 +482,7 @@ analyseWords env = mapRTree lemma2fun
482482
-- | Return the first non-empty list
483483
ifEmpty [] xs = xs
484484
ifEmpty xs _ = xs
485-
infixl 3 `ifEmpty`
485+
infixr 3 `ifEmpty`
486486

487487
-- Verify that a StrSomeCat function exists in grammar
488488
strFunExists c | Just typ <- functionType (pgfGrammar env) f = True
@@ -503,14 +503,13 @@ analyseWords env = mapRTree lemma2fun
503503

504504
-- Fall back to morphoanalysis if gf parse fails
505505
-- TODO: We might want to use the morphoanalysis for all words, not just when parse fails
506-
morphoFallback :: String -> [(RTree Lemma, CId)] -> [(RTree CId, CId)]
507-
morphoFallback w [] =
506+
morphoFallback :: String -> [(RTree CId, CId)]
507+
morphoFallback w =
508508
[(RTree name [], c)
509509
| (name, _) <- lookupMorpho morpho w
510510
, Just tp <- pure $ functionType (pgfGrammar env) name
511511
, ([], c, []) <- pure $ unType tp
512512
]
513-
morphoFallback _ xs = xs
514513

515514
-- auxiliaries
516515
-- newWordTree w c = RTree (mkCId (w ++ "_" ++ showCId c)) [] ---

0 commit comments

Comments
 (0)