Add LPGF function for catching errors. Manual fixes to Phrasebook treebank.

This commit is contained in:
John J. Camilleri
2021-03-05 12:05:25 +01:00
parent 70581c2d8c
commit 575a746a3e
6 changed files with 78 additions and 57 deletions

View File

@@ -68,13 +68,14 @@ doGrammar' path gname cncs = do
results <- forM gs $ \grp -> do
let ast = drop 2 $ dropWhile (/=':') $ head grp
printf "- %s: %s\n" gname ast
let
Just tree = readExpr ast
-- Linearization into all languages
outs =
[ printf "%s: %s" (showLanguage lang) (linearizeConcrete concr tree)
| (lang,concr) <- Map.toList (concretes lpgf)
]
let Just tree = readExpr ast
-- Linearization into all languages
outs <- forM (Map.toList (concretes lpgf)) $ \(lang,concr) -> do
e <- try $ linearizeConcrete concr tree
return $ case e of
Right s -> printf "%s: %s" (showLanguage lang) s
Left e -> printf "%s: ERROR: %s" (showLanguage lang) e
-- filter out missing langs from treebank
let golds = [ g | o <- outs, g <- tail grp, takeWhile (/=':') o == takeWhile (/=':') g ]