1
0
forked from GitHub/gf-core

new languages in resource Make; moved GF-specific stuff from Quiz

This commit is contained in:
aarne
2008-06-16 11:15:38 +00:00
parent f6ef4e2dfd
commit 361c6cb096
3 changed files with 32 additions and 23 deletions

View File

@@ -15,23 +15,25 @@ langs = [
("english", "Eng"),
("finnish", "Fin"),
("french", "Fre"),
("hindi", "Hin"),
("german", "Ger"),
("interlingua","Ina"),
("italian", "Ita"),
("norwegian","Nor"),
("russian", "Rus"),
("spanish", "Spa"),
("swedish", "Swe")
("swedish", "Swe"),
("thai", "Tha")
]
-- languagues for which to compile Lang
langsLang = langs `except` ["Ara","Ina","Rus"]
langsLang = langs `except` ["Ara","Rus"]
-- languages for which to compile Try
langsAPI = langsLang `except` ["Bul","Cat"]
langsAPI = langsLang `except` ["Cat","Hin","Tha"]
-- languages for which to run treebank test
langsTest = langsLang `except` ["Bul","Cat","Spa"]
langsTest = langsLang `except` ["Cat","Hin","Spa","Tha"]
-- languages for which langs.pgf is built
langsPGF = langsTest `only` ["Eng","Fre","Swe"]
@@ -64,8 +66,9 @@ make xx = do
system "rm */*.gfo ../alltenses/*.gfo ../present/*.gfo"
return ()
gfc pres path file = do
gfc pres ppath file = do
let preproc = if pres then " -preproc=./mkPresent " else ""
let path = if pres then ppath else ""
putStrLn $ "compiling " ++ file
system $ "gfc -s -src " ++ preproc ++ path ++ file

View File

@@ -454,3 +454,18 @@ allCommands pgf = Map.fromList [
-- ps -f -g s returns g (f s)
stringOps opts s = foldr app s (reverse (map prOpt opts)) where
app f = maybe id id (stringOp f)
translationQuiz :: PGF -> Language -> Language -> Category -> IO ()
translationQuiz pgf ig og cat = do
tts <- translationList pgf ig og cat infinity
mkQuiz "Welcome to GF Translation Quiz." tts
morphologyQuiz :: PGF -> Language -> Category -> IO ()
morphologyQuiz pgf ig cat = do
tts <- morphologyList pgf ig cat infinity
mkQuiz "Welcome to GF Morphology Quiz." tts
-- | the maximal number of precompiled quiz problems
infinity :: Int
infinity = 256

View File

@@ -13,9 +13,8 @@
--------------------------------------------------------------------------------
module PGF.Quiz (
translationQuiz,
mkQuiz,
translationList,
morphologyQuiz,
morphologyList
) where
@@ -31,13 +30,15 @@ import Data.List (nub)
-- translation and morphology quiz. AR 10/5/2000 -- 12/4/2002
translationQuiz :: PGF -> Language -> Language -> Category -> IO ()
translationQuiz pgf ig og cat = do
tts <- translationList pgf ig og cat infinity
let qas = [ (q, mkAnswer as) | (q,as) <- tts]
teachDialogue qas "Welcome to GF Translation Quiz."
-- generic quiz function
translationList :: PGF -> Language -> Language -> Category -> Int -> IO [(String,[String])]
mkQuiz :: String -> [(String,[String])] -> IO ()
mkQuiz msg tts = do
let qas = [ (q, mkAnswer as) | (q,as) <- tts]
teachDialogue qas msg
translationList ::
PGF -> Language -> Language -> Category -> Int -> IO [(String,[String])]
translationList pgf ig og cat number = do
ts <- generateRandom pgf cat >>= return . take number
return $ map mkOne $ ts
@@ -45,12 +46,6 @@ translationList pgf ig og cat number = do
mkOne t = (norml (linearize pgf ig t), map (norml . linearize pgf og) (homonyms t))
homonyms = nub . parse pgf ig cat . linearize pgf ig
morphologyQuiz :: PGF -> Language -> Category -> IO ()
morphologyQuiz pgf ig cat = do
tts <- morphologyList pgf ig cat infinity
let qas = [ (q, mkAnswer as) | (q,as) <- tts]
teachDialogue qas "Welcome to GF Morphology Quiz."
morphologyList :: PGF -> Language -> Category -> Int -> IO [(String,[String])]
morphologyList pgf ig cat number = do
ts <- generateRandom pgf cat >>= return . take (max 1 number)
@@ -70,7 +65,3 @@ mkAnswer as s = if (elem (norml s) as)
norml :: String -> String
norml = unwords . words
-- | the maximal number of precompiled quiz problems
infinity :: Int
infinity = 256