1
0
forked from GitHub/gf-core

in example-based grammar conversion, warnings about unknown words

This commit is contained in:
aarne
2010-01-28 10:06:16 +00:00
parent 750a2639b0
commit e056cc2bfd
4 changed files with 33 additions and 19 deletions

View File

@@ -1,6 +1,7 @@
module PGF.Morphology(Lemma,Analysis,Morpho,
buildMorpho,
lookupMorpho,fullFormLexicon) where
lookupMorpho,fullFormLexicon,
morphoMissing,missingWordMsg) where
import PGF.CId
import PGF.Data
@@ -10,6 +11,7 @@ import qualified Data.Set as Set
import qualified Data.IntMap as IntMap
import Data.Array.IArray
import Data.List (intersperse)
import Data.Char (isDigit) ----
-- these 4 definitions depend on the datastructure used
@@ -42,3 +44,13 @@ lookupMorpho (Morpho mo) s = maybe [] id $ Map.lookup s mo
fullFormLexicon :: Morpho -> [(String,[(Lemma,Analysis)])]
fullFormLexicon (Morpho mo) = Map.toList mo
morphoMissing :: Morpho -> [String] -> [String]
morphoMissing mo ws = [w | w <- ws, null (lookupMorpho mo w), notLiteral w] where
notLiteral w = not (all isDigit w) ---- should be defined somewhere
missingWordMsg :: Morpho -> [String] -> String
missingWordMsg morpho ws = case morphoMissing morpho ws of
[] -> ", but all words are known"
ws -> "; unknown words: " ++ unwords ws