summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Command
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2011-03-03 08:31:15 +0000
committeraarne <aarne@chalmers.se>2011-03-03 08:31:15 +0000
commitf32091cd53b796a1938dd5e486dc0292c24ff4b0 (patch)
treee831e7281e722d8c1ee848b257aecea7b92663e7 /src/compiler/GF/Command
parent8e3674600ccbe539a62aec6b79340d4dd27ef9d5 (diff)
print lexicon in Xerox LEXC format: pg -lexc
Diffstat (limited to 'src/compiler/GF/Command')
-rw-r--r--src/compiler/GF/Command/Commands.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs
index 3f01135ef..1c4c1377f 100644
--- a/src/compiler/GF/Command/Commands.hs
+++ b/src/compiler/GF/Command/Commands.hs
@@ -588,6 +588,7 @@ allCommands env@(pgf, mos) = Map.fromList [
("cats", "show just the names of abstract syntax categories"),
("fullform", "print the fullform lexicon"),
("funs", "show just the names and types of abstract syntax functions"),
+ ("lexc", "print the lexicon in Xerox LEXC format"),
("missing","show just the names of functions that have no linearization"),
("opt", "optimize the generated pgf"),
("pgf", "write current pgf image in file"),
@@ -1143,6 +1144,7 @@ allCommands env@(pgf, mos) = Map.fromList [
| isOpt "cats" opts = return $ fromString $ unwords $ map showCId $ categories pgf
| isOpt "funs" opts = return $ fromString $ unlines $ map showFun $ funsigs pgf
| isOpt "fullform" opts = return $ fromString $ concatMap (morpho "" prFullFormLexicon) $ optLangs opts
+ | isOpt "lexc" opts = return $ fromString $ concatMap (morpho "" prLexcLexicon) $ optLangs opts
| isOpt "missing" opts = return $ fromString $ unlines $ [unwords (showCId la:":": map showCId cs) |
la <- optLangs opts, let cs = missingLins pgf la]
| isOpt "words" opts = return $ fromString $ concatMap (morpho "" prAllWords) $ optLangs opts
@@ -1225,6 +1227,16 @@ morphologyQuiz mex pgf ig typ = do
infinity :: Int
infinity = 256
+prLexcLexicon :: Morpho -> String
+prLexcLexicon mo =
+ unlines $ "LEXICON" : [w ++ ":" ++ prLexc l p | (w,lps) <- morpho, (l,p) <- lps] ++ ["END"]
+ where
+ morpho = fullFormLexicon mo
+ prLexc l p = showCId l ++ mkTags (words p) ++ " # ;"
+ mkTags p = case p of
+ "s":ws -> mkTags ws --- remove record field
+ ws -> concat $ "+" : intersperse "+" ws
+
prFullFormLexicon :: Morpho -> String
prFullFormLexicon mo =
unlines (map prMorphoAnalysis (fullFormLexicon mo))