summaryrefslogtreecommitdiff
path: root/src/runtime/haskell
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2010-01-28 10:06:16 +0000
committeraarne <aarne@chalmers.se>2010-01-28 10:06:16 +0000
commite056cc2bfd2e5e152edd9829b8d4d77637536a14 (patch)
treef48c6256e866402ae921d910fbfb5a7483c035cc /src/runtime/haskell
parent750a2639b0f46153c36f6c713f522db5bb2d8587 (diff)
in example-based grammar conversion, warnings about unknown words
Diffstat (limited to 'src/runtime/haskell')
-rw-r--r--src/runtime/haskell/PGF/Morphology.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/runtime/haskell/PGF/Morphology.hs b/src/runtime/haskell/PGF/Morphology.hs
index f5c65b3ba..711f9c01d 100644
--- a/src/runtime/haskell/PGF/Morphology.hs
+++ b/src/runtime/haskell/PGF/Morphology.hs
@@ -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
+