forked from GitHub/gf-core
in example-based grammar conversion, warnings about unknown words
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user