Skip to content

Commit

Permalink
If no str functions exists, give all of them
Browse files Browse the repository at this point in the history
This prevents a Prelude.head error form occurring
  • Loading branch information
anka-213 committed Mar 30, 2022
1 parent d16c085 commit 164a3a6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion UD2GF.hs
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,17 @@ analyseWords env = mapRTree lemma2fun
getWordTrees wf w cs = case morphoFallback wf $ concatMap (parseWord w) cs of
[] -> case cs of
[] -> (True,[(newWordTree w unknownCat, unknownCat)])
_ -> (True,[(newWordTree w ec, ec) | c <- cs, let ec = either id id c, strFunExists ec])
_ -> (True,[(newWordTree w ec, ec) | c <- cs, let ec = either id id c, strFunExists ec]
`ifEmpty` [(newWordTree w ec, ec) | c <- cs, let ec = either id id c])

fs -> (False,fs)

-- | Return the first non-empty list
ifEmpty [] xs = xs
ifEmpty xs _ = xs
infixl 3 `ifEmpty`

-- Verify that a StrSomeCat function exists in grammar
strFunExists c | Just typ <- functionType (pgfGrammar env) f = True
| otherwise = False
where f = mkCId ("Str" ++ showCId c)
Expand Down

0 comments on commit 164a3a6

Please sign in to comment.