summaryrefslogtreecommitdiff
path: root/src/PGF
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-10-01 16:01:51 +0000
committeraarne <aarne@cs.chalmers.se>2008-10-01 16:01:51 +0000
commit429092ac6aa1374a468b36904b4c2c668d892c54 (patch)
tree73d56e3a233b80b8e25a80b5b518802590603718 /src/PGF
parent307042a6a1863854920da7eaae6fbc588457221c (diff)
added mode 'gf --run' for running silently a script ; made quizzes handle character encoding correctly ; for this end, collected coding functions in GF.Text.Coding
Diffstat (limited to 'src/PGF')
-rw-r--r--src/PGF/Quiz.hs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/PGF/Quiz.hs b/src/PGF/Quiz.hs
index 7f5bae201..096930f46 100644
--- a/src/PGF/Quiz.hs
+++ b/src/PGF/Quiz.hs
@@ -23,6 +23,7 @@ import PGF.ShowLinearize
import GF.Data.Operations
import GF.Infra.UseIO
+import GF.Text.Coding
import System.Random
@@ -32,9 +33,9 @@ import Data.List (nub)
-- generic quiz function
-mkQuiz :: String -> [(String,[String])] -> IO ()
-mkQuiz msg tts = do
- let qas = [ (q, mkAnswer as) | (q,as) <- tts]
+mkQuiz :: String -> String -> [(String,[String])] -> IO ()
+mkQuiz cod msg tts = do
+ let qas = [ (q, mkAnswer cod as) | (q,as) <- tts]
teachDialogue qas msg
translationList ::
@@ -57,11 +58,14 @@ morphologyList pgf ig cat number = do
(pws,i) <- zip ss forms, let (par,ws) = pws !! i]
-- | compare answer to the list of right answers, increase score and give feedback
-mkAnswer :: [String] -> String -> (Integer, String)
-mkAnswer as s = if (elem (norml s) as)
- then (1,"Yes.")
- else (0,"No, not" +++ s ++ ", but" ++++ unlines as)
+mkAnswer :: String -> [String] -> String -> (Integer, String)
+mkAnswer cod as s =
+ if (elem (norm s) as)
+ then (1,"Yes.")
+ else (0,"No, not" +++ s ++ ", but" ++++ enc (unlines as))
+ where
+ norm = unwords . words . decodeUnicode cod
+ enc = encodeUnicode cod
-norml :: String -> String
norml = unwords . words