diff options
| author | krasimir <krasimir@chalmers.se> | 2017-04-19 13:00:46 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2017-04-19 13:00:46 +0000 |
| commit | 25e14b253d24a9409ec70758126d8a64f24a691d (patch) | |
| tree | 4d8cb50896fba0edba8894938a5164db6f4452ae /src/ui/android/glosses.hs | |
| parent | 5c93f2fba5eadaa1e516106c08d495c14a0eb647 (diff) | |
now the database with glosses is compiled on the PC by running glosses.hs. On the phone we just extract the database
Diffstat (limited to 'src/ui/android/glosses.hs')
| -rw-r--r-- | src/ui/android/glosses.hs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/ui/android/glosses.hs b/src/ui/android/glosses.hs index 3776d569b..966ec90aa 100644 --- a/src/ui/android/glosses.hs +++ b/src/ui/android/glosses.hs @@ -1,10 +1,21 @@ import SG +import PGF2 import Data.Char import Data.List main = do - ls <- fmap lines $ readFile "../../../lib/src/translator/Dictionary.gf" - writeFile "assets/glosses.txt" (unlines [x | Just (fn,gloss) <- map gloss ls, x <- glossTriples fn gloss]) + db <- openSG "assets/semantics.db" + inTransaction db $ do + ls <- fmap lines $ readFile "../../../lib/src/translator/Dictionary.gf" + let glosses = [x | Just (fn,gloss) <- map gloss ls, x <- glossTriples fn gloss] + topics <- fmap (map toTriple . lines) $ readFile "topics.txt" + sequence_ [insertTriple db s p o | (s,p,o) <- glosses++topics] + closeSG db + +toTriple l = + case readTriple l of + Just t -> t + Nothing -> error ("topics.txt: "++l) gloss l = case words l of @@ -14,9 +25,12 @@ gloss l = _ -> Nothing glossTriples fn s = - (if null gs then [] else ["<"++fn++",gloss,"++show (merge gs)++">"])++ - (if null es then [] else ["<"++fn++",example,"++show (merge (map (init . tail) es))++">"]) + (if null gs then [] else [(fn_e,gloss,mkStr (merge gs))])++ + (if null es then [] else [(fn_e,example,mkStr (merge (map (init . tail) es)))]) where + fn_e = mkApp fn [] + gloss = mkApp "gloss" [] + example = mkApp "example" [] (es,gs) = partition isExample (splitGloss s) splitGloss s = |
