1
0
forked from GitHub/gf-core

structural words merged with other constructors; links to paradigms from lexical cats, in synopsis

This commit is contained in:
aarne
2007-11-26 21:27:29 +00:00
parent 3c7e6724a3
commit f643cd271b
2 changed files with 717 additions and 430 deletions

View File

@@ -16,7 +16,9 @@ main = do
writeFile synopsis "GF Resource Grammar Library: Synopsis" writeFile synopsis "GF Resource Grammar Library: Synopsis"
append "Aarne Ranta" append "Aarne Ranta"
space space
append "%!postproc(html): '(SRC=\"categories.png\")' '\\1 USEMAP=\"#categories\"'" append "%!postproc(html): '(SRC=\"categories.png\")' '\\1 USEMAP=\"#categories\"'"
append "%!postproc(html): '#LParadigms' '<a name=\"RParadigms\"></a>'"
append "%!postproc(tex): '#LParadigms' ''"
delimit $ addToolTips cs delimit $ addToolTips cs
include "synopsis-intro.txt" include "synopsis-intro.txt"
title "Categories" title "Categories"
@@ -30,20 +32,24 @@ main = do
append "==Explanations==\n" append "==Explanations==\n"
delimit $ mkCatTable isLatex cs delimit $ mkCatTable isLatex cs
space space
title "Syntax Rules" title "Syntax Rules and Structural Words"
space space
link "Source:" syntaxAPI link "Source 1:" syntaxAPI
space
link "Source 2:" structuralAPI
space space
rs <- getRules syntaxAPI rs <- getRules syntaxAPI
delimit $ mkSplitTables True isLatex cs rs rs2 <- getRules structuralAPI
delimit $ mkSplitTables True isLatex cs $ rs ++ rs2
space space
title "Structural Words" -- title "Structural Words"
space -- space
link "Source:" structuralAPI -- link "Source:" structuralAPI
space -- space
rs <- rulesTable False isLatex cs structuralAPI -- rs <- rulesTable False isLatex cs structuralAPI
delimit rs -- delimit rs
space space
title "Lexical Paradigms"
mapM_ (putParadigms isLatex cs) paradigmFiles mapM_ (putParadigms isLatex cs) paradigmFiles
space space
include "synopsis-browse.txt" include "synopsis-browse.txt"
@@ -108,7 +114,8 @@ getRules file = do
putParadigms :: Bool -> Cats -> (String, FilePath) -> IO () putParadigms :: Bool -> Cats -> (String, FilePath) -> IO ()
putParadigms isLatex cs (lang,file) = do putParadigms isLatex cs (lang,file) = do
title ("Paradigms for " ++ lang) stitle ("Paradigms for " ++ lang)
append "#LParadigms"
space space
link "source" file link "source" file
space space
@@ -126,10 +133,16 @@ inChunks i f = concat . intersperse ["\n\n"] . map f . chunks i where
-- Adds a subsection header for each table. -- Adds a subsection header for each table.
mkSplitTables :: Bool -> Bool -> Cats -> Rules -> [String] mkSplitTables :: Bool -> Bool -> Cats -> Rules -> [String]
mkSplitTables hasEx isLatex cs = concatMap t . addLexicalCats cs . sortRules mkSplitTables hasEx isLatex cs = concatMap t . addLexicalCats cs . sortRules
where t (c, xs) = [subtitle c expl] ++ mkTable hasEx isLatex cs xs where t (c, xs) = [subtitle c expl] ++ tableOrLink
where expl = case [e | (n,e,_) <- cs, n == c] of where
expl = case [e | (n,e,_) <- cs, n == c] of
[] -> "" [] -> ""
e:_ -> e e:_ -> e
tableOrLink = if null xs then parad else mkTable hasEx isLatex cs xs
parad = [
"Lexical category, constructors given in",
"[lexical paradigms #RParadigms]."
]
mkTable :: Bool -> Bool -> Cats -> Rules -> [String] mkTable :: Bool -> Bool -> Cats -> Rules -> [String]
mkTable hasEx isLatex cs = inChunks chsize (\rs -> header : map (unwords . row) rs) mkTable hasEx isLatex cs = inChunks chsize (\rs -> header : map (unwords . row) rs)
@@ -173,6 +186,7 @@ paradigmFiles = [
append s = appendFile synopsis ('\n':s) append s = appendFile synopsis ('\n':s)
title s = append $ "=" ++ s ++ "=" title s = append $ "=" ++ s ++ "="
stitle s = append $ "==" ++ s ++ "=="
include s = append $ "%!include: " ++ s include s = append $ "%!include: " ++ s
space = append "\n" space = append "\n"
delimit ss = mapM_ append ss delimit ss = mapM_ append ss
@@ -221,4 +235,4 @@ showTyp cs = unwords . map f . words
where c = init (tail s) where c = init (tail s)
isCat cat = cat `notElem` ["Str","Int"] isCat cat = cat `notElem` ["Str","Int"]
&& all (\c -> isAlphaNum c || c == '\'') cat && all (\c -> isAlphaNum c || c == '\'') cat
&& isUpper (head cat) && isUpper (head cat)

File diff suppressed because it is too large Load Diff