summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorKrasimir Angelov <kr.angelov@gmail.com>2017-08-30 16:35:57 +0200
committerKrasimir Angelov <kr.angelov@gmail.com>2017-08-30 16:35:57 +0200
commit7db9f51d78a24405e2f6544f6e5d57fa3a23fc44 (patch)
tree72912749c32595214c218aa1ca3637a0f682047d /src/compiler
parent4a24bc98f21a4abccb39ca2b0f2972852a6fa90f (diff)
"ma" command in the C shell
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/GF/Command/Commands2.hs44
1 files changed, 13 insertions, 31 deletions
diff --git a/src/compiler/GF/Command/Commands2.hs b/src/compiler/GF/Command/Commands2.hs
index 0a0538280..b70bfb9e3 100644
--- a/src/compiler/GF/Command/Commands2.hs
+++ b/src/compiler/GF/Command/Commands2.hs
@@ -338,34 +338,21 @@ pgfCommands = Map.fromList [
needsTypeCheck = False
}),
-}
-{-
("ma", emptyCommandInfo {
longname = "morpho_analyse",
- synopsis = "print the morphological analyses of all words in the string",
+ synopsis = "print the morphological analyses of the (multiword) expression in the string",
explanation = unlines [
- "Prints all the analyses of space-separated words in the input string,",
+ "Prints all the analyses of the (multiword) expression in the input string,",
"using the morphological analyser of the actual grammar (see command pg)"
],
- exec = \env opts -> case opts of
- _ | isOpt "missing" opts ->
- return . fromString . unwords .
- H.morphoMissing (optMorpho env opts) .
- concatMap words . toStrings
- _ | isOpt "known" opts ->
- return . fromString . unwords .
- H.morphoKnown (optMorpho env opts) .
- concatMap words . toStrings
- _ -> return . fromString . unlines .
- map prMorphoAnalysis . concatMap (morphos env opts) .
- concatMap words . toStrings ,
+ exec = needPGF $ \opts args env ->
+ return ((fromString . unlines .
+ map prMorphoAnalysis . concatMap (morphos env opts) . toStrings) args),
flags = [
("lang","the languages of analysis (comma-separated, no spaces)")
- ],
- options = [
- ("known", "return only the known words, in order of appearance"),
- ("missing","show the list of unknown words, in order of appearance")
]
}),
+{-
("mq", emptyCommandInfo {
longname = "morpho_quiz",
synopsis = "start a morphology quiz",
@@ -1044,14 +1031,10 @@ pgfCommands = Map.fromList [
funsigs pgf = [(f,ty) | (f,(ty,_,_,_)) <- Map.assocs (H.funs (H.abstract pgf))]
showFun (f,ty) = H.showCId f ++ " : " ++ H.showType [] ty ++ " ;"
-
- morphos (pgf,mos) opts s =
- [(s,morpho mos [] (\mo -> H.lookupMorpho mo s) la) | la <- optLangs pgf opts]
-
- morpho mos z f la = maybe z f $ Map.lookup la mos
-
- optMorpho (pgf,mos) opts = morpho mos (error "no morpho") id (head (optLangs pgf opts))
-
+-}
+ morphos env opts s =
+ [(s,lookupMorpho concr s) | (lang,concr) <- optConcs env opts]
+{-
optClitics opts = case valStrOpts "clitics" "" opts of
"" -> []
cs -> map reverse $ chunks ',' cs
@@ -1104,11 +1087,10 @@ prFullFormLexicon mo =
prAllWords :: H.Morpho -> String
prAllWords mo =
unwords [w | (w,_) <- H.fullFormLexicon mo]
-
-prMorphoAnalysis :: (String,[(H.Lemma,H.Analysis)]) -> String
-prMorphoAnalysis (w,lps) =
- unlines (w:[H.showCId l ++ " : " ++ p | (l,p) <- lps])
-}
+prMorphoAnalysis :: (String,[MorphoAnalysis]) -> String
+prMorphoAnalysis (w,lps) =
+ unlines (w:[fun ++ " : " ++ cat | (fun,cat,p) <- lps])
hsExpr c =
case unApp c of