diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-06-10 16:00:42 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-06-10 16:00:42 +0000 |
| commit | 9628eb6314bfcb827142d1869626696de101e245 (patch) | |
| tree | 6800242a4ce3cd45a6dda7a4eb93d9aab588e5be /src-3.0/PGF | |
| parent | 9c75bddcfc0340b6e5dd06a23d686113532d2726 (diff) | |
preliminary version of morpho analysis
Diffstat (limited to 'src-3.0/PGF')
| -rw-r--r-- | src-3.0/PGF/Morphology.hs | 46 | ||||
| -rw-r--r-- | src-3.0/PGF/ShowLinearize.hs | 1 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src-3.0/PGF/Morphology.hs b/src-3.0/PGF/Morphology.hs new file mode 100644 index 000000000..97def6b9a --- /dev/null +++ b/src-3.0/PGF/Morphology.hs @@ -0,0 +1,46 @@ +module PGF.Morphology where + +import PGF.ShowLinearize +import PGF.Data +import PGF.CId + +import qualified Data.Map as Map +import Data.List (intersperse) + +-- these 4 definitions depend on the datastructure used + +type Morpho = Map.Map String [(Lemma,Analysis)] + +lookupMorpho :: Morpho -> String -> [(Lemma,Analysis)] +lookupMorpho mo s = maybe noAnalysis id $ Map.lookup s mo + +buildMorpho :: PGF -> CId -> Morpho +buildMorpho pgf = Map.fromListWith (++) . collectWords pgf + +prFullFormLexicon :: Morpho -> String +prFullFormLexicon mo = + unlines [w ++ " : " ++ prMorphoAnalysis ts | (w,ts) <- Map.assocs mo] + +prMorphoAnalysis :: [(Lemma,Analysis)] -> String +prMorphoAnalysis lps = unlines [l ++ " " ++ p | (l,p) <- lps] + +type Lemma = String +type Analysis = String + +noAnalysis :: [(Lemma,Analysis)] +noAnalysis = [] + +collectWords :: PGF -> CId -> [(String, [(Lemma,Analysis)])] +collectWords pgf lang = + concatMap collOne + [(f,c,0) | (f,(DTyp [] c _,_)) <- Map.toList $ funs $ abstract pgf] + where + collOne (f,c,i) = + fromRec f [prCId c] (recLinearize pgf lang (EApp f (replicate i (EMeta 888)))) + fromRec f v r = case r of + RR rs -> concat [fromRec f v t | (_,t) <- rs] + RT rs -> concat [fromRec f (p:v) t | (p,t) <- rs] + RFV rs -> concatMap (fromRec f v) rs + RS s -> [(s,[(prCId f,unwords (reverse v))])] + RCon c -> [] ---- inherent + diff --git a/src-3.0/PGF/ShowLinearize.hs b/src-3.0/PGF/ShowLinearize.hs index a1c1e476a..98a0806ba 100644 --- a/src-3.0/PGF/ShowLinearize.hs +++ b/src-3.0/PGF/ShowLinearize.hs @@ -1,4 +1,5 @@ module PGF.ShowLinearize ( + Record (..), recLinearize, --- used in PGF.Morphology tableLinearize, recordLinearize, termLinearize, |
