diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-12-05 10:05:33 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-12-05 10:05:33 +0000 |
| commit | 05854280181f5ad30939a4fc533d42560103d23f (patch) | |
| tree | 124ef170431dbc6455a25824a8752e7ce81fbf20 /treebanks/susanne/convert.hs | |
| parent | 106b41a2cb562b26a477af5372ddf09fe8f79ca7 (diff) | |
more on the Susanne treebank
Diffstat (limited to 'treebanks/susanne/convert.hs')
| -rw-r--r-- | treebanks/susanne/convert.hs | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/treebanks/susanne/convert.hs b/treebanks/susanne/convert.hs index 91fdc2cf4..dfd2328ca 100644 --- a/treebanks/susanne/convert.hs +++ b/treebanks/susanne/convert.hs @@ -1,14 +1,54 @@ import System.Directory import System.FilePath import Data.List +import Data.Char(toLower) +import PGF (readPGF, readLanguage, buildMorpho, lookupMorpho, mkCId, functionType, unType) import SusanneFormat +Just eng = readLanguage "ParseEng" + main = do + gr <- readPGF "../../ParseEngAbs.pgf" + let morpho = buildMorpho gr eng fs <- getDirectoryContents "data" txts <- (mapM (\f -> readFile ("data" </> f)) . filter ((/= ".") . take 1)) (sort fs) - let ts = filter (not . isBreak) (readTreebank (lines (concat txts))) + --let ts = concatMap (convert gr morpho) (readTreebank (lines (concat txts))) + let ts = readTreebank (lines (concat txts)) writeFile "text" (unlines (map show ts)) -isBreak (Phrase "Oh" [Word _ "YB" "<minbrk>" _]) = True -isBreak _ = False +convert pgf morpho w@(Word _ tag _ lemma) + | elem tag ["YB","YBL","YBR","YF","YIL","YIR","YTL","YTR", "YO"] = [] + | tag == "NN1c" = convertLemma pgf morpho (mkCId "N") "s Sg Nom" w + | tag == "NN1n" = convertLemma pgf morpho (mkCId "N") "s Sg Nom" w + | tag == "NN2" = convertLemma pgf morpho (mkCId "N") "s Pl Nom" w + | tag == "JJ" = convertLemma pgf morpho (mkCId "A") "s (AAdj Posit Nom)" w + | tag == "JB" = convertLemma pgf morpho (mkCId "A") "s (AAdj Posit Nom)" w + | tag == "JBo" = convertLemma pgf morpho (mkCId "A") "s (AAdj Posit Nom)" w + | tag == "AT" = convertLemma pgf morpho (mkCId "Quant") "s False Sg" w + | tag == "VVDi" = convertLemma pgf morpho (mkCId "V") "s VPast" w + | tag == "VVDt" = convertLemma pgf morpho (mkCId "V2") "s VPast" w + | tag == "VVDv" = convertLemma pgf morpho (mkCId "V") "s VPast" w + | tag == "VVZi" = convertLemma pgf morpho (mkCId "V") "s VPres" w + | tag == "VVZt" = convertLemma pgf morpho (mkCId "V2") "s VPres" w + | tag == "VVZv" = convertLemma pgf morpho (mkCId "V") "s VPres" w + | tag == "PPHS2"= convertLemma pgf morpho (mkCId "Pron") "s (NCase Nom)" w + | tag == "PPHO2"= convertLemma pgf morpho (mkCId "Pron") "s NPAcc" w + | tag == "RR" = convertLemma pgf morpho (mkCId "Adv") "s" w + | tag == "II" = convertLemma pgf morpho (mkCId "Prep") "s" w + | tag == "IO" = convertLemma pgf morpho (mkCId "Prep") "s" w + | otherwise = [w] +convert pgf morpho (Phrase tag mods fn idx ts) + | tag == "O" = concatMap (convert pgf morpho) ts + | otherwise = [Phrase tag mods fn idx (concatMap (convert pgf morpho) ts)] + +convertLemma pgf morpho cat an0 w@(Word _ tag form _) = + case [f | (f,an) <- lookupMorpho morpho (map toLower form), hasCat pgf f cat, an == an0] of + [f] -> [App f []] + _ -> [w] + where + hasCat pgf f cat = + case functionType pgf f of + Just ty -> case unType ty of + (_,cat1,_) -> cat1 == cat + Nothing -> False |
