forked from GitHub/gf-core
some fixes in synopsis example display
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
module MkExxTable (getApiExx, ApiExx, prApiEx) where
|
||||
module MkExxTable (getApiExx, ApiExx, prApiEx, mkEx) where
|
||||
|
||||
import System.Cmd
|
||||
import System.Environment
|
||||
@@ -13,7 +13,7 @@ main = do
|
||||
getApiExx :: [FilePath] -> IO ApiExx
|
||||
getApiExx xx = do
|
||||
s <- readFile (head xx)
|
||||
let aet = getApiExxTrees $ filter validOutput $ lines s
|
||||
let aet = getApiExxTrees $ filter validOutput $ mergeOutput $ lines s
|
||||
aeos <- mapM readApiExxOne xx
|
||||
let aexx = mkApiExx $ ("API",aet) : aeos
|
||||
-- putStrLn $ prApiExx aexx
|
||||
@@ -22,7 +22,7 @@ getApiExx xx = do
|
||||
readApiExxOne file = do
|
||||
s <- readFile file
|
||||
let lang = reverse (take 3 (drop 4 (reverse file))) -- api-exx-*Eng*.txt
|
||||
let api = getApiExxOne $ filter validOutput $ lines s
|
||||
let api = getApiExxOne $ filter validOutput $ mergeOutput $ lines s
|
||||
putStrLn $ unlines $ prApiEx api ---
|
||||
return (lang,api)
|
||||
|
||||
@@ -51,6 +51,13 @@ getApiExxTrees = M.fromList . pairs . map cleanUp
|
||||
-- remove leading prompts and spaces
|
||||
cleanUp = dropWhile (flip elem " >")
|
||||
|
||||
--- this makes txt2tags loop...
|
||||
mergeOutput ls = ls
|
||||
mergeOutputt ls = case ls of
|
||||
l@('>':_):ll -> let (ll1,ll2) = span ((/=">") . take 1) ll in unwords (l : map (unwords . words) ll1) : mergeOutput ll2
|
||||
_:ll -> mergeOutput ll
|
||||
_ -> []
|
||||
|
||||
-- only accept lines starting with prompts (to eliminate multi-line gf uncomputed output)
|
||||
validOutput = (==">") . take 1
|
||||
|
||||
@@ -76,12 +83,19 @@ mkEx l = unws . bind . mkE . words where
|
||||
mkE e = case e of
|
||||
"atomic":"term":_ -> ["*"]
|
||||
"[]":_ -> ["''"]
|
||||
"pre":p@('{':_):es -> init (init (drop 2 p)) : [] ---- mkE es -- occurs only on last position
|
||||
"(table":es -> ["..."]
|
||||
"table":es -> ["..."]
|
||||
('{':_):es -> ["..."]
|
||||
"pre":p@('{':_):es -> init (init (drop 2 p)) : ["..."]
|
||||
--- "pre":p@('{':_):es -> init (init (drop 2 p)) : reverse (takeWhile ((/='}') . head) (reverse es))
|
||||
e0:es -> e0:mkE es
|
||||
_ -> e
|
||||
|
||||
bind ws = case ws of
|
||||
w : "&+" : u : ws2 -> bind ((w ++ u) : ws2)
|
||||
w : "Predef.BIND" : u : ws2 -> bind ((w ++ u) : ws2)
|
||||
"&+":ws2 -> bind ws2
|
||||
"Predef.BIND":ws2 -> bind ws2
|
||||
w : ws2 -> w : bind ws2
|
||||
w : "++" : ws2 -> w : bind ws2
|
||||
_ -> ws
|
||||
|
||||
@@ -203,7 +203,7 @@ mkTable hasEx isLatex aexx cs = inChunks chsize (\rs -> header : map (unwords .
|
||||
-- make an example with hover-popup translations
|
||||
mkExample es ex = unwords [
|
||||
"#divreveal",
|
||||
itf (maybe ex id (M.lookup revealedLang es)),
|
||||
itf (maybe ex (mkEx revealedLang) (M.lookup revealedLang es)),
|
||||
"#divpopup",
|
||||
"#UL",
|
||||
unwords ["#LI" ++ e | e <- prApiEx es],
|
||||
|
||||
@@ -243,9 +243,9 @@ mkUtt (mkNP (mkDet the_Quant (mkNum (mkNumeral n5_Unit))) (mkCN old_A man_N))
|
||||
mkNP : Det -> N -> NP -- the first man
|
||||
mkUtt (mkNP (mkDet the_Quant (mkNum (mkNumeral n5_Unit))) man_N)
|
||||
mkNP : Numeral -> CN -> NP -- fifty old men
|
||||
mkUtt (mkNP (mkNumeral (tenfoldSub100 n5_Unit)) (mkCN old_A man_N))
|
||||
mkUtt (mkNP (mkNumeral (n5_Unit)) (mkCN old_A man_N))
|
||||
mkNP : Numeral -> N -> NP -- fifty men
|
||||
mkUtt (mkNP (mkNumeral (tenfoldSub100 n5_Unit)) man_N)
|
||||
mkUtt (mkNP (mkNumeral (n5_Unit)) man_N)
|
||||
mkNP : Digits -> CN -> NP -- 51 old men
|
||||
mkUtt (mkNP (mkDigits n5_Dig (mkDigits n1_Dig)) (mkCN old_A man_N))
|
||||
mkNP : Digits -> N -> NP -- 51 men
|
||||
|
||||
@@ -8,7 +8,36 @@
|
||||
=Introduction=
|
||||
|
||||
The GF Resource Grammar Library is the standard library for Grammatical Framework.
|
||||
It covers the morphology and basic syntax of currently 27 languages.
|
||||
It covers the morphology and basic syntax of currently 29 languages:
|
||||
Afrikaans,
|
||||
Bulgarian,
|
||||
Catalan,
|
||||
Chinese,
|
||||
Danish,
|
||||
Dutch,
|
||||
English,
|
||||
Estonian,
|
||||
Finnish,
|
||||
French,
|
||||
German,
|
||||
Greek,
|
||||
Hindi,
|
||||
Japanese,
|
||||
Italian,
|
||||
Latvian,
|
||||
Maltese,
|
||||
Nepali,
|
||||
Norwegian bokmål,
|
||||
Persian,
|
||||
Polish,
|
||||
<li>Punjabi,
|
||||
Romanian,
|
||||
Russian,
|
||||
Sindhi,
|
||||
Spanish,
|
||||
Swedish,
|
||||
Thai,
|
||||
Urdu.
|
||||
|
||||
This document contains the most important parts of the GF Resource Grammar API,
|
||||
as needed by a GF application programmer.
|
||||
|
||||
Reference in New Issue
Block a user