This commit is contained in:
Krasimir Angelov
2018-10-15 12:04:36 +02:00
4 changed files with 26 additions and 12 deletions

View File

@@ -33,9 +33,9 @@ Phrasebook</a>
<P><a href="http://cloud.grammaticalframework.org/minibar/minibar.html">Minibar</A> <P><a href="http://cloud.grammaticalframework.org/minibar/minibar.html">Minibar</A>
<!-- | <small><a href="../src/www/minibar/minibar_offline.html">Minibar offline</a></small> --> <!-- | <small><a href="../src/www/minibar/minibar_offline.html">Minibar offline</a></small> -->
(<small>Predecessors: <!--(<small>Predecessors:
<a href="http://www.grammaticalframework.org:41296/fridge">Fridge poetry</A> <a href="http://www.grammaticalframework.org:41296/fridge">Fridge poetry</A>
| <a href="http://www.grammaticalframework.org:41296/translate">Word-completing translator</A></small>) | <a href="http://www.grammaticalframework.org:41296/translate">Word-completing translator</A></small>)-->
<p><a href="http://www.grammaticalframework.org/~hallgren/Talks/GF/Tutorial2012/Ex4/answer.html">Question answering demo</a> for simple math questions. <p><a href="http://www.grammaticalframework.org/~hallgren/Talks/GF/Tutorial2012/Ex4/answer.html">Question answering demo</a> for simple math questions.
<P> <P>
@@ -63,16 +63,17 @@ to your web browser.
<P> <P>
<A HREF="http://webalt.math.helsinki.fi/PublicFiles/CD/Screencast/TextMathEditor%20Demo.swf">WebALT Math Editor</A>: <A HREF="http://webalt.math.helsinki.fi/PublicFiles/CD/Screencast/TextMathEditor%20Demo.swf">WebALT Math Editor</A>:
create mathematical exercises in six languages simultaneously (film). create mathematical exercises in six languages simultaneously (film).
<!--
<P> <P>
[Out of order, early May 2012] [Out of order, early May 2012]
<small> <small>
<A HREF="http://www.jem-thematic.net/en/node/846#comment-209">WebALT Math translator</A>: <A HREF="http://www.jem-thematic.net/en/node/846#comment-209">WebALT Math translator</A>:
translate mathematical exercises in a web service using incremental parsing. translate mathematical exercises in a web service using incremental parsing.
</small> </small>
-->
<!--
<P> <P>
<!-- <A HREF="http://csmisc14.cs.chalmers.se/~bjorn/langtrain.cgi">GF Language Trainer</A>: <A HREF="http://csmisc14.cs.chalmers.se/~bjorn/langtrain.cgi">GF Language Trainer</A>:
translation quizzes in Arabic, English, Russian, Swedish. --> translation quizzes in Arabic, English, Russian, Swedish. -->
<P> <P>

View File

@@ -445,6 +445,7 @@ pgfCommands = Map.fromList [
], ],
options = [ options = [
("lines","return the list of lines, instead of the singleton of all contents"), ("lines","return the list of lines, instead of the singleton of all contents"),
("paragraphs","return the list of paragraphs, as separated by empty lines"),
("tree","convert strings into trees") ("tree","convert strings into trees")
], ],
exec = getEnv $ \ opts _ (Env pgf mos) -> do exec = getEnv $ \ opts _ (Env pgf mos) -> do
@@ -470,6 +471,7 @@ pgfCommands = Map.fromList [
_ | isOpt "tree" opts -> _ | isOpt "tree" opts ->
returnFromLines [(1::Int,s)] returnFromLines [(1::Int,s)]
_ | isOpt "lines" opts -> return (fromStrings $ lines s) _ | isOpt "lines" opts -> return (fromStrings $ lines s)
_ | isOpt "paragraphs" opts -> return (fromStrings $ toParagraphs $ lines s)
_ -> return (fromString s), _ -> return (fromString s),
flags = [("file","the input file name")] flags = [("file","the input file name")]
}), }),

View File

@@ -3,6 +3,7 @@
-- elsewhere -- elsewhere
module GF.Command.CommonCommands where module GF.Command.CommonCommands where
import Data.List(sort) import Data.List(sort)
import Data.Char (isSpace)
import GF.Command.CommandInfo import GF.Command.CommandInfo
import qualified Data.Map as Map import qualified Data.Map as Map
import GF.Infra.SIO import GF.Infra.SIO
@@ -116,11 +117,13 @@ commonCommands = fmap (mapCommandExec liftSIO) $ Map.fromList [
let (os,fs) = optsAndFlags opts let (os,fs) = optsAndFlags opts
trans <- optTranslit opts trans <- optTranslit opts
if isOpt "lines" opts case opts of
then return $ fromStrings $ map (trans . stringOps (envFlag fs) (map prOpt os)) $ toStrings x _ | isOpt "lines" opts -> return $ fromStrings $ map (trans . stringOps (envFlag fs) (map prOpt os)) $ toStrings x
else return ((fromString . trans . stringOps (envFlag fs) (map prOpt os) . toString) x), _ | isOpt "paragraphs" opts -> return $ fromStrings $ map (trans . stringOps (envFlag fs) (map prOpt os)) $ toParagraphs $ toStrings x
_ -> return ((fromString . trans . stringOps (envFlag fs) (map prOpt os) . toString) x),
options = [ options = [
("lines","apply the operation separately to each input line, returning a list of lines") ("lines","apply the operation separately to each input line, returning a list of lines"),
("paragraphs","apply separately to each input paragraph (as separated by empty lines), returning a list of lines")
] ++ ] ++
stringOpOptions, stringOpOptions,
flags = [ flags = [
@@ -269,3 +272,11 @@ trie = render . pptss . H.toTrie . map H.toATree
-- ** Converting command input -- ** Converting command input
toString = unwords . toStrings toString = unwords . toStrings
toLines = unlines . toStrings toLines = unlines . toStrings
toParagraphs = map (unwords . words) . toParas
where
toParas ls = case break (all isSpace) ls of
([],[]) -> []
([],_:ll) -> toParas ll
(l, []) -> [unwords l]
(l, _:ll) -> unwords l : toParas ll

View File

@@ -22,12 +22,12 @@
<hr> <hr>
<small> <small>
[<a href="about.html">About Minibar</a> [<a href="about.html">About Minibar</a><!--
| <a href="http://www.grammaticalframework.org:41296/fridge/">Original Fridge Poetry</a> | <a href="http://www.grammaticalframework.org:41296/fridge/">Original Fridge Poetry</a>
&amp; <a href="http://www.grammaticalframework.org:41296/translate/">Translator</a>] &amp; <a href="http://www.grammaticalframework.org:41296/translate/">Translator</a>-->]
</small> </small>
<small class=modtime> <small class=modtime>
HTML <!-- hhmts start -->Last modified: Thu Jun 9 16:13:26 CEST 2016 <!-- hhmts end --> HTML <!-- hhmts start -->Last modified: Wed Oct 10 14:14:10 CEST 2018 <!-- hhmts end -->
</small> </small>
<div id="debug" class="hidden"></div> <div id="debug" class="hidden"></div>