diff --git a/src/GF/API.hs b/src/GF/API.hs index f7bd5fc9c..762fa372f 100644 --- a/src/GF/API.hs +++ b/src/GF/API.hs @@ -241,11 +241,11 @@ optLinearizeTree opts0 gr t = case getOptVal opts transferFun of lin mk | oElem showRecord opts = liftM prt . linearizeNoMark g c | oElem tableLin opts = liftM (unlines . map untok . prLinTable True) . - allLinTables g c + allLinTables True g c | oElem showFields opts = liftM (unlines . map untok) . allLinBranchFields g c | oElem showAll opts = liftM (unlines . map untok . prLinTable False) . - allLinTables g c + allLinTables False g c | otherwise = return . unlines . map untok . optIntOrOne . linTree2strings mk g c g = grammar gr c = cncId gr @@ -306,7 +306,8 @@ optParseArgErrMsg opts gr s = do -- | analyses word by word morphoAnalyse :: Options -> GFGrammar -> String -> String -morphoAnalyse opts gr +morphoAnalyse opts gr + | oElem (iOpt "status") opts = morphoTextStatus mo | oElem beShort opts = morphoTextShort mo | otherwise = morphoText mo where diff --git a/src/GF/Shell/HelpFile.hs b/src/GF/Shell/HelpFile.hs index eebaebd57..a54646710 100644 --- a/src/GF/Shell/HelpFile.hs +++ b/src/GF/Shell/HelpFile.hs @@ -375,6 +375,7 @@ txtHelpFile = "\n the results line by line." ++ "\n options:" ++ "\n -short show analyses in bracketed words, instead of separate lines" ++ + "\n -status show just the work at success, prefixed with \"*\" at failure" ++ "\n flags:" ++ "\n -lang" ++ "\n examples:" ++ diff --git a/src/GF/Shell/ShellCommands.hs b/src/GF/Shell/ShellCommands.hs index 1ed778188..fba8a80a7 100644 --- a/src/GF/Shell/ShellCommands.hs +++ b/src/GF/Shell/ShellCommands.hs @@ -195,7 +195,7 @@ optionsOfCommand co = case co of CLookupTreebank -> both "assocs raw strings trees" "treebank" CWrapTerm _ -> opts "c" CApplyTransfer _ -> flags "lang transfer" - CMorphoAnalyse -> both "short" "lang" + CMorphoAnalyse -> both "short status" "lang" CTestTokenizer -> flags "lexer" CComputeConcrete _ -> both "table" "res" CShowOpers _ -> flags "res" diff --git a/src/GF/Shell/TeachYourself.hs b/src/GF/Shell/TeachYourself.hs index 5c2170f55..7e5a8afe2 100644 --- a/src/GF/Shell/TeachYourself.hs +++ b/src/GF/Shell/TeachYourself.hs @@ -58,7 +58,7 @@ morphoTrainList opts ig number = do mkOnes gen ts where mkOnes gen (t:ts) = do - psss <- ioeErr $ allLinTables gr cnc t + psss <- ioeErr $ allLinTables True gr cnc t let pss = concat $ map snd $ concat psss let (i,gen') = randomR (0, length pss - 1) gen (ps,ss) <- ioeErr $ pss !? i diff --git a/src/GF/UseGrammar/Linear.hs b/src/GF/UseGrammar/Linear.hs index 85bae5b0d..ac6c3b703 100644 --- a/src/GF/UseGrammar/Linear.hs +++ b/src/GF/UseGrammar/Linear.hs @@ -213,14 +213,16 @@ allLinsAsRec gr c t = linearizeNoMark gr c t >>= expandLinTables gr >>= allLinVa -- | the value is a list of structures arranged as records of tables of strings -- only taking into account string fields -allLinTables :: CanonGrammar ->Ident ->A.Tree ->Err [[(Label,[([Patt],[String])])]] -allLinTables gr c t = do +-- True: sep. by /, False: sep by \n +allLinTables :: + Bool -> CanonGrammar ->Ident ->A.Tree ->Err [[(Label,[([Patt],[String])])]] +allLinTables slash gr c t = do r' <- allLinsAsRec gr c t mapM (mapM getS) r' where getS (lab,pss) = liftM (curry id lab) $ mapM gets pss gets (ps,t) = liftM (curry id ps . cc . map str2strings) $ strsFromTerm t - cc = concat . intersperse ["/"] + cc = concat . intersperse [if slash then "/" else "\n"] -- | the value is a list of strings gathered from all fields diff --git a/src/GF/UseGrammar/Morphology.hs b/src/GF/UseGrammar/Morphology.hs index 313aa6fbc..3aeb08dc7 100644 --- a/src/GF/UseGrammar/Morphology.hs +++ b/src/GF/UseGrammar/Morphology.hs @@ -113,9 +113,14 @@ allMorphoWords = map fst . collapse -- analyse running text and show results either in short form or on separate lines --- | analyse running text and show results in short form +-- | analyse running text and show just the word, with "*" if not found +morphoTextStatus :: Morpho -> String -> String +morphoTextStatus mo = unlines . map (prMark . appMorpho mo) . words where + prMark (w,fs) = if null fs then "*" +++ w else w + +-- | analyse running text and show results in short form, one word per line morphoTextShort :: Morpho -> String -> String -morphoTextShort mo = unwords . map (prMorphoAnalysisShort . appMorpho mo) . words +morphoTextShort mo = unlines . map (prMorphoAnalysisShort . appMorpho mo) . words -- | analyse running text and show results on separate lines morphoText :: Morpho -> String -> String diff --git a/src/GF/UseGrammar/Treebank.hs b/src/GF/UseGrammar/Treebank.hs index 952b71877..d353efc8a 100644 --- a/src/GF/UseGrammar/Treebank.hs +++ b/src/GF/UseGrammar/Treebank.hs @@ -241,9 +241,9 @@ linearize opts mgr lang = lin where lin | oElem showRecord opts = err id id . liftM prt . linearizeNoMark cgr zlang | oElem tableLin opts = - err id id . liftM (unlines . map untok . prLinTable True) . allLinTables cgr zlang + err id id . liftM (unlines . map untok . prLinTable True) . allLinTables True cgr zlang | oElem showAll opts = - err id id . liftM (unlines . map untok . prLinTable False) . allLinTables cgr zlang + err id id . liftM (unlines . map untok . prLinTable False) . allLinTables False cgr zlang | otherwise = untok . linTree2string noMark cgr zlang diff --git a/src/HelpFile b/src/HelpFile index be06efb0b..0b18e34a8 100644 --- a/src/HelpFile +++ b/src/HelpFile @@ -346,6 +346,7 @@ ma, morphologically_analyse: ma String the results line by line. options: -short show analyses in bracketed words, instead of separate lines + -status show just the work at success, prefixed with "*" at failure flags: -lang examples: