From b7ffd929a01462bd8d0208dd4fbbdc7c466c8f8a Mon Sep 17 00:00:00 2001 From: aarne Date: Wed, 4 Jul 2007 09:39:24 +0000 Subject: [PATCH] extended Synopsis with categories, structural, and an example --- resource-1.0/abstract/Common.gf | 6 +- resource-1.0/doc/MkSynopsis.hs | 54 +- resource-1.0/doc/synopsis-example.txt | 49 ++ resource-1.0/doc/synopsis.html | 918 +++++++++++++++++++++++++- 4 files changed, 986 insertions(+), 41 deletions(-) create mode 100644 resource-1.0/doc/synopsis-example.txt diff --git a/resource-1.0/abstract/Common.gf b/resource-1.0/abstract/Common.gf index 4ef52ae5..b9032905 100644 --- a/resource-1.0/abstract/Common.gf +++ b/resource-1.0/abstract/Common.gf @@ -46,9 +46,9 @@ abstract Common = { --2 Tense, polarity, and anteriority - Tense ; -- tense: present, past, future, conditional - Pol ; -- polarity: positive, negative - Ant ; -- anteriority: simultaneous, anterior + Tense ; -- tense e.g. present, past, future + Pol ; -- polarity e.g. positive, negative + Ant ; -- anteriority e.g. simultaneous, anterior fun PPos, PNeg : Pol ; -- I sleep/don't sleep diff --git a/resource-1.0/doc/MkSynopsis.hs b/resource-1.0/doc/MkSynopsis.hs index ec4b5903..576fddb7 100644 --- a/resource-1.0/doc/MkSynopsis.hs +++ b/resource-1.0/doc/MkSynopsis.hs @@ -5,16 +5,51 @@ main = do writeFile synopsis "GF Resource Grammar Library: Synopsis" append "Aarne Ranta" space - title "Syntax" + title "Categories" space - link "source" syntaxAPI + link "Source 1:" commonAPI + space + link "Source 2:" catAPI + space + cs1 <- getCats True commonAPI + cs2 <- getCats False catAPI + delimit $ cs1 ++ cs2 + space + title "Syntax Rules" + space + link "Source:" syntaxAPI space rs <- getRules syntaxAPI delimit rs space + title "Structural Words" + space + link "Source:" structuralAPI + space + rs <- getRules structuralAPI + delimit rs + space mapM_ putParadigms paradigmFiles + space + title "Example Usage" + space + ss <- readFile "synopsis-example.txt" >>= return . lines + mapM_ append ss + space system $ "txt2tags -thtml --toc " ++ synopsis +getCats isBeg file = do + ss <- readFile file >>= return . lines + return $ mkCatTable isBeg $ getrs [] ss + where + getrs rs ss = case ss of + ('-':'-':'.':_):_ -> reverse rs + [] -> reverse rs + ('-':'-':_):ss2 -> getrs rs ss2 + s:ss2 -> case words s of + cat:";":"--":exp -> getrs ((cat,unwords expl, unwords (tail ex)):rs) ss2 where + (expl,ex) = span (/="e.g.") exp + _ -> getrs rs ss2 getRules file = do ss <- readFile file >>= return . lines @@ -28,6 +63,7 @@ getRules file = do _:_:"overload":_ -> getrs rs ss2 _:":":_ -> getrs (layout s:rs) ss2 _ -> getrs rs ss2 + layout s = " " ++ dropWhile isSpace s putParadigms (lang,file) = do title ("Paradigms for " ++ lang) @@ -39,8 +75,6 @@ putParadigms (lang,file) = do delimit rs space -layout s = " " ++ dropWhile isSpace s - mkTable rs = "|| Function | Type | Example ||" : map (unwords . row . words) rs where row ws = ["|", name, "|", typ, "|", ex, "|"] where @@ -53,8 +87,17 @@ mkTable rs = "|| Function | Type | Example ||" : map (unwords . row . words) _ -> e filtype = filter (/=";") +mkCatTable isBeg rs = + (if isBeg then ("|| Category | Explanation | Example ||" :) else id) + (map mk1 rs) + where + mk1 (name,typ,ex) = unwords ["|", ttf name, "|", typ, "|", ex, "|"] + synopsis = "synopsis.txt" +commonAPI = "../abstract/Common.gf" +catAPI = "../abstract/Cat.gf" syntaxAPI = "../api/Constructors.gf" +structuralAPI = "../abstract/Structural.gf" paradigmFiles = [ ("Danish", "../danish/ParadigmsDan.gf"), ("English", "../english/ParadigmsEng.gf"), @@ -72,7 +115,8 @@ append s = appendFile synopsis ('\n':s) title s = append $ "=" ++ s ++ "=" space = append "\n" delimit ss = mapM_ append ss -link s f = append $ "[" ++ s ++ " " ++ f ++ "]" +link s f = append $ s ++ " [``" ++ fa ++ "`` " ++ f ++ "]" where + fa = "http://www.cs.chalmers.se/~aarne/GF/lib/resource" ++ dropWhile (=='.') f ttf s = "``" ++ s ++ "``" itf s = "//" ++ s ++ "//" diff --git a/resource-1.0/doc/synopsis-example.txt b/resource-1.0/doc/synopsis-example.txt new file mode 100644 index 00000000..f435a231 --- /dev/null +++ b/resource-1.0/doc/synopsis-example.txt @@ -0,0 +1,49 @@ +The standard way of building an application has the following modules. + +An abstract syntax: +``` + abstract Music = { + cat + Kind, + Property ; + fun + PropKind : Kind -> Property -> Kind ; + Song : Kind ; + American : Property ; + } +``` +A domain lexicon interface: +``` + interface MusicLex = open Cat in { + oper + song_N : N ; + american_A : A ; + } +``` +A functor on ``Syntax`` and the domain lexicon interface: +``` + incomplete concrete MusicI of Music = open Syntax, MusicLex in { + lincat + Kind = CN ; + Property = AP ; + lin + PropKind k p = mkCN p k ; + Song = mkCN song_N ; + American = mkAP american_A ; + } +``` +For each language, an instance of the domain lexicon: +``` + instance MusicLexGer of MusicLex = CatGer ** open ParadigmsGer in { + oper + song_N = mkN "Lied" "Lieder" neuter ; + american_A = mkA "amerikanisch" ; + } +``` +For each language, an instantiation of the functor: +``` + --# -path=.:present:prelude + concrete MusicGer of Music = MusicI with + (Syntax = SyntaxGer), + (MusicLex = MusicLexGer) ; +``` diff --git a/resource-1.0/doc/synopsis.html b/resource-1.0/doc/synopsis.html index c6f2b00d..151f116f 100644 --- a/resource-1.0/doc/synopsis.html +++ b/resource-1.0/doc/synopsis.html @@ -13,26 +13,321 @@


-

Syntax

+

Categories

-source +Source 1: http://www.cs.chalmers.se/~aarne/GF/lib/resource/abstract/Common.gf +

+

+Source 2: http://www.cs.chalmers.se/~aarne/GF/lib/resource/abstract/Cat.gf +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CategoryExplanationExample
Texttext consisting of several phrases"He is here. Why?"
Phrphrase in a text"but be quiet please"
Uttsentence, question, word..."be quiet"
Vocvocative or "please""my darling"
PConjphrase-beginning conj."therefore"
SCembedded sentence or question"that it rains"
Advverb-phrase-modifying adverb,"in the house"
AdVadverb directly attached to verb"always"
AdAadjective-modifying adverb,"very"
AdNnumeral-modifying adverb,"more than"
IAdvinterrogative adverb"why"
CAdvcomparative adverb"more"
Tensetensepresent, past, future
Polpolaritypositive, negative
Antanterioritysimultaneous, anterior
Sdeclarative sentence"she lived here"
QSquestion"where did she live"
RSrelative"in which she lived"
Cldeclarative clause, with all tenses"she looks at this"
Slashclause missing NP (S/NP in GPSG)"she looks at"
Impimperative"look at this"
QClquestion clause, with all tenses"why does she walk"
IPinterrogative pronoun"who"
ICompinterrogative complement of copula"where"
IDetinterrogative determiner"which"
RClrelative clause, with all tenses"in which she lives"
RPrelative pronoun"in which"
VPverb phrase"is very warm"
Compcomplement of copula, such as AP"very warm"
APadjectival phrase"very warm"
CNcommon noun (without determiner)"red house"
NPnoun phrase (subject or object)"the red house"
Pronpersonal pronoun"she"
Detdeterminer phrase"those seven"
Quantquantifier with both sg and pl"this/these"
Numcardinal number (used with QuantPl)"seven"
Ordordinal number (used in Det)"seventh"
Conjconjunction,"and"
DConjdistributed conj."both - and"
Subjsubjunction,"if"
Preppreposition, or just case"in"
Vone-place verb"sleep"
V2two-place verb"love"
V3three-place verb"show"
VVverb-phrase-complement verb"want"
VSsentence-complement verb"claim"
VQquestion-complement verb"ask"
VAadjective-complement verb"look"
V2Averb with NP and AP complement"paint"
Aone-place adjective"warm"
A2two-place adjective"divisible"
Ncommon noun"house"
N2relational noun"son"
N3three-place relational noun"connection"
PNproper name"Paris"
+ +

+ +

Syntax Rules

+

+Source: http://www.cs.chalmers.se/~aarne/GF/lib/resource/api/Constructors.gf

@@ -1223,10 +1518,504 @@

- + +

Structural Words

+

+Source: http://www.cs.chalmers.se/~aarne/GF/lib/resource/abstract/Structural.gf +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionTypeExample
above_PrepPrep-
after_PrepPrep-
all_PredetPredet-
almost_AdAAdA-
almost_AdNAdN-
although_SubjSubj-
always_AdVAdV-
and_ConjConj-
because_SubjSubj-
before_PrepPrep-
behind_PrepPrep-
between_PrepPrep-
both7and_DConjDConj-
but_PConjPConj-
by8agent_PrepPrep-
by8means_PrepPrep-
can8know_VVVV-
can_VVVV-
during_PrepPrep-
either7or_DConjDConj-
every_DetDet-
everybody_NPNP-
everything_NPNP-
everywhere_AdvAdv-
first_OrdOrd-
few_DetDet-
for_PrepPrep-
from_PrepPrep-
he_PronPron-
here_AdvAdv-
here7to_AdvAdv-
here7from_AdvAdv-
how_IAdvIAdv-
how8many_IDetIDet-
i_PronPron-
if_SubjSubj-
in8front_PrepPrep-
in_PrepPrep-
it_PronPron-
less_CAdvCAdv-
many_DetDet-
more_CAdvCAdv-
most_PredetPredet-
much_DetDet-
must_VVVV-
no_PhrPhr-
on_PrepPrep-
one_QuantQuantSg-
only_PredetPredet-
or_ConjConj-
otherwise_PConjPConj-
part_PrepPrep-
please_VocVoc-
possess_PrepPrep-
quite_AdvAdA-
she_PronPron-
so_AdAAdA-
someSg_DetDet-
somePl_DetDet-
somebody_NPNP-
something_NPNP-
somewhere_AdvAdv-
that_QuantQuant-
that_NPNP-
there_AdvAdv-
there7to_AdvAdv-
there7from_AdvAdv-
therefore_PConjPConj-
these_NPNP-
they_PronPron-
this_QuantQuant-
this_NPNP-
those_NPNP-
through_PrepPrep-
to_PrepPrep-
too_AdAAdA-
under_PrepPrep-
very_AdAAdA-
want_VVVV-
we_PronPron-
whatPl_IPIP-
whatSg_IPIP-
when_IAdvIAdv-
when_SubjSubj-
where_IAdvIAdv-
whichPl_IDetIDet-
whichSg_IDetIDet-
whoPl_IPIP-
whoSg_IPIP-
why_IAdvIAdv-
with_PrepPrep-
without_PrepPrep-
yes_PhrPhr-
youSg_PronPron-
youPl_PronPron-
youPol_PronPron-
+ +

+

Paradigms for Danish

-source +source http://www.cs.chalmers.se/~aarne/GF/lib/resource/danish/ParadigmsDan.gf

@@ -1547,10 +2336,10 @@

- +

Paradigms for English

-source +source http://www.cs.chalmers.se/~aarne/GF/lib/resource/english/ParadigmsEng.gf

@@ -1831,10 +2620,10 @@

- +

Paradigms for Finnish

-source +source http://www.cs.chalmers.se/~aarne/GF/lib/resource/finnish/ParadigmsFin.gf

@@ -2245,10 +3034,10 @@

- +

Paradigms for French

-source +source http://www.cs.chalmers.se/~aarne/GF/lib/resource/french/ParadigmsFre.gf

@@ -2529,10 +3318,10 @@

- +

Paradigms for German

-source +source http://www.cs.chalmers.se/~aarne/GF/lib/resource/german/ParadigmsGer.gf

@@ -2843,10 +3632,10 @@

- +

Paradigms for Italian

-source +source http://www.cs.chalmers.se/~aarne/GF/lib/resource/italian/ParadigmsIta.gf

@@ -3132,10 +3921,10 @@

- +

Paradigms for Norwegian

-source +source http://www.cs.chalmers.se/~aarne/GF/lib/resource/norwegian/ParadigmsNor.gf

@@ -3456,10 +4245,10 @@

- +

Paradigms for Russian

-source +source http://www.cs.chalmers.se/~aarne/GF/lib/resource/russian/ParadigmsRus.gf

@@ -3755,10 +4544,10 @@

- +

Paradigms for Spanish

-source +source http://www.cs.chalmers.se/~aarne/GF/lib/resource/spanish/ParadigmsSpa.gf

@@ -4049,10 +4838,10 @@

- +

Paradigms for Swedish

-source +source http://www.cs.chalmers.se/~aarne/GF/lib/resource/swedish/ParadigmsSwe.gf

@@ -4347,6 +5136,69 @@
+

+ +

Example Usage

+

+The standard way of building an application has the following modules. +

+

+An abstract syntax: +

+
+    abstract Music = {    
+    cat 
+      Kind, 
+      Property ;
+    fun 
+      PropKind : Kind -> Property -> Kind ; 
+      Song : Kind ;
+      American : Property ;
+    }
+
+

+A domain lexicon interface: +

+
+    interface MusicLex = open Cat in {
+    oper
+      song_N : N ;
+      american_A : A ;
+    }
+
+

+A functor on Syntax and the domain lexicon interface: +

+
+    incomplete concrete MusicI of Music = open Syntax, MusicLex in {
+    lincat 
+      Kind = CN ;
+      Property = AP ;
+    lin
+      PropKind k p = mkCN p k ;
+      Song = mkCN song_N ;
+      American = mkAP american_A ;
+    }
+
+

+For each language, an instance of the domain lexicon: +

+
+    instance MusicLexGer of MusicLex = CatGer ** open ParadigmsGer in {    
+    oper
+      song_N = mkN "Lied" "Lieder" neuter ;
+      american_A = mkA "amerikanisch" ;
+    }
+
+

+For each language, an instantiation of the functor: +

+
+    --# -path=.:present:prelude
+    concrete MusicGer of Music = MusicI with
+      (Syntax = SyntaxGer),
+      (MusicLex = MusicLexGer) ;
+