-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
So, I was wondering. How do people here like to learn dates? I have a
horrible time learning dates with just one or two questions, so I
wrote a script. It does stuff like this:
[EMAIL PROTECTED]:28249~>echo "Anaximander died in %546% BCE." | runhaskell
memo3.hs [ 5:49PM]
Anaximander died in 546 BCE. 54_
Anaximander died in 546 BCE. 5_6
Anaximander died in 546 BCE. 5__
Anaximander died in 546 BCE. _46
Anaximander died in 546 BCE. _4_
Anaximander died in 546 BCE. __6
Anaximander died in 546 BCE. ___
(Tab format as usual.)
In other words, you write yourself a sentence, and you specify a
subsection for Cloze deletions by enclosing in %s. The script then
breaks the sentence apart, generates all possible deletions, and
outputs them as tab-delimited question-answer pairs. This approach
certainly guarantees that one will either memorize the number or
become very irritated at some point. :)
The source is a Haskell '98 script:
- -----------------
main :: IO ()
main = interact (unlines . concat . map (map tabify .
generateQuestions . parseQuestion) . lines)
data Stuff = Question String | Answer String deriving (Eq)
extract :: Stuff -> String
extract (Answer x) = x
extract (Question x) = x
getAnswer :: [Stuff] -> String
getAnswer xs = concat $ [x | Answer x String
tabify (q,a) = q ++ "\t" ++ a
- -- parseQuestion "David Hume born %1711%" ~> [Question "David Hume
born ",Answer "1711"]
parseQuestion :: String -> [Stuff]
parseQuestion = filter (/= Question "") . parseIntoStuff . split (=='%')
- -- Non-destructively break a list into sublists based on occurrence
of an entry:
- -- split (=='%') "Plato died in %328% BCE." ~> ["Plato died in
","%","328","%"," BCE."]
split :: (a -> Bool) -> [a] -> [[a]]
split _ [] = []
split p s = let (l,s') = break p s in l : case s' of
[] -> []
(r:s'') -> [r] : split p s''
parseIntoStuff :: [String] -> [Stuff]
parseIntoStuff (x:[]) = [Question x]
parseIntoStuff (a:b:c:ds) | a == "%" && c == "%" = Answer b : parseIntoStuff ds
| otherwise = Question a : parseIntoStuff (b:c:ds)
generateQuestions :: [Stuff] -> [(String, String)]
generateQuestions x = zip (cycle [concatMap extract x]) (drop 1 . mapM
(:"_") . getAnswer $ x)
- -----------------
- --
gwern
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEAREKAAYFAkkbXycACgkQvpDo5Pfl1oJHSwCeL3sBWWZzYIfchhmUkRfpV5fW
9iMAn2SbVcBmGSy1acCQlLRNTRKysIRx
=6Mam
-----END PGP SIGNATURE-----
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"mnemosyne-proj-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/mnemosyne-proj-users?hl=en
-~----------~----~----~----~------~----~------~--~---
main :: IO ()
main = interact (unlines . concat . map (map tabify . generateQuestions . parseQuestion) . lines)
data Stuff = Question String | Answer String deriving (Eq)
extract :: Stuff -> String
extract (Answer x) = x
extract (Question x) = x
getAnswer :: [Stuff] -> String
getAnswer xs = concat $ [x | Answer x <- xs]
tabify :: (String, String) -> String
tabify (q,a) = q ++ "\t" ++ a
-- parseQuestion "David Hume born %1711%" ~> [Question "David Hume born ",Answer "1711"]
parseQuestion :: String -> [Stuff]
parseQuestion = filter (/= Question "") . parseIntoStuff . split (=='%')
-- Non-destructively break a list into sublists based on occurrence of an entry:
-- split (=='%') "Plato died in %328% BCE." ~> ["Plato died in ","%","328","%"," BCE."]
split :: (a -> Bool) -> [a] -> [[a]]
split _ [] = []
split p s = let (l,s') = break p s in l : case s' of
[] -> []
(r:s'') -> [r] : split p s''
parseIntoStuff :: [String] -> [Stuff]
parseIntoStuff (x:[]) = [Question x]
parseIntoStuff (a:b:c:ds) | a == "%" && c == "%" = Answer b : parseIntoStuff ds
| otherwise = Question a : parseIntoStuff (b:c:ds)
generateQuestions :: [Stuff] -> [(String, String)]
generateQuestions x = zip (cycle [concatMap extract x]) (drop 1 . mapM (:"_") . getAnswer $ x)