summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/index.html11
-rw-r--r--src/compiler/GF/Command/Commands.hs2
-rw-r--r--src/compiler/GF/Command/CommonCommands.hs19
-rw-r--r--src/www/minibar/minibar.html6
4 files changed, 26 insertions, 12 deletions
diff --git a/demos/index.html b/demos/index.html
index 503487dca..8435d7776 100644
--- a/demos/index.html
+++ b/demos/index.html
@@ -33,9 +33,9 @@ Phrasebook</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>Predecessors:
+<!--(<small>Predecessors:
<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>
@@ -63,16 +63,17 @@ to your web browser.
<P>
<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).
-
+<!--
<P>
[Out of order, early May 2012]
<small>
<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.
</small>
-
+-->
+<!--
<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. -->
<P>
diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs
index a8a175f7c..72e57fcf5 100644
--- a/src/compiler/GF/Command/Commands.hs
+++ b/src/compiler/GF/Command/Commands.hs
@@ -445,6 +445,7 @@ pgfCommands = Map.fromList [
],
options = [
("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")
],
exec = getEnv $ \ opts _ (Env pgf mos) -> do
@@ -470,6 +471,7 @@ pgfCommands = Map.fromList [
_ | isOpt "tree" opts ->
returnFromLines [(1::Int,s)]
_ | isOpt "lines" opts -> return (fromStrings $ lines s)
+ _ | isOpt "paragraphs" opts -> return (fromStrings $ toParagraphs $ lines s)
_ -> return (fromString s),
flags = [("file","the input file name")]
}),
diff --git a/src/compiler/GF/Command/CommonCommands.hs b/src/compiler/GF/Command/CommonCommands.hs
index 69ccaf325..0b698e79c 100644
--- a/src/compiler/GF/Command/CommonCommands.hs
+++ b/src/compiler/GF/Command/CommonCommands.hs
@@ -3,6 +3,7 @@
-- elsewhere
module GF.Command.CommonCommands where
import Data.List(sort)
+import Data.Char (isSpace)
import GF.Command.CommandInfo
import qualified Data.Map as Map
import GF.Infra.SIO
@@ -116,11 +117,13 @@ commonCommands = fmap (mapCommandExec liftSIO) $ Map.fromList [
let (os,fs) = optsAndFlags opts
trans <- optTranslit opts
- if isOpt "lines" opts
- then return $ fromStrings $ map (trans . stringOps (envFlag fs) (map prOpt os)) $ toStrings x
- else return ((fromString . trans . stringOps (envFlag fs) (map prOpt os) . toString) x),
+ case opts of
+ _ | isOpt "lines" opts -> return $ fromStrings $ map (trans . stringOps (envFlag fs) (map prOpt os)) $ toStrings 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 = [
- ("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,
flags = [
@@ -269,3 +272,11 @@ trie = render . pptss . H.toTrie . map H.toATree
-- ** Converting command input
toString = unwords . 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
diff --git a/src/www/minibar/minibar.html b/src/www/minibar/minibar.html
index b1382339e..4392e5fa8 100644
--- a/src/www/minibar/minibar.html
+++ b/src/www/minibar/minibar.html
@@ -22,12 +22,12 @@
<hr>
<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>
-&amp; <a href="http://www.grammaticalframework.org:41296/translate/">Translator</a>]
+&amp; <a href="http://www.grammaticalframework.org:41296/translate/">Translator</a>-->]
</small>
<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>
<div id="debug" class="hidden"></div>