diff --git a/doc/intro-resource.txt b/doc/intro-resource.txt index 74a366d87..25dcebde7 100644 --- a/doc/intro-resource.txt +++ b/doc/intro-resource.txt @@ -143,29 +143,32 @@ two interfaces: the resource ``Syntax`` and an application lexicon. American = mkAP american_A ; } ``` -The application lexicon ``MusicLex`` has an abstract syntax that extends -the resource category system ``Cat``. +The application lexicon ``MusicLex`` is an interface +opening the resource category system ``Cat``. ``` - abstract MusicLex = Cat ** { - - fun + interface MusicLex = Cat ** { + oper song_N : N ; american_A : A ; } ``` +It could also be an abstract syntax that extends ``Cat``, but +this would limit the kind of constructions that are possible in +the interface + Each language has its own concrete syntax, which opens the inflectional paradigms module for that language: ``` - concrete MusicLexGer of MusicLex = + interface MusicLexGer of MusicLex = CatGer ** open ParadigmsGer in { - lin + oper song_N = mkN "Lied" "Lieder" neuter ; american_A = mkA "amerikanisch" ; } - concrete MusicLexFre of MusicLex = + interface MusicLexFre of MusicLex = CatFre ** open ParadigmsFre in { - lin + oper song_N = mkN "chanson" feminine ; american_A = mkA "américain" ; } @@ -195,9 +198,9 @@ instantiating ``Music``. The latter is completely trivial, whereas the former one involves the choice of correct vocabulary and inflectional paradigms. For instance, Finnish is added as follows: ``` - concrete MusicLexFin of MusicLex = + instance MusicLexFin of MusicLex = CatFin ** open ParadigmsFin in { - lin + oper song_N = mkN "kappale" ; american_A = mkA "amerikkalainen" ; } @@ -226,9 +229,9 @@ restricted inheritance of the functor: ``` The lexicon is as expected: ``` - concrete MusicLexEng of MusicLex = + instance MusicLexEng of MusicLex = CatEng ** open ParadigmsEng in { - lin + oper song_N = mkN "song" ; american_A = mkA "American" ; } diff --git a/lib/resource-1.0/abstract/Common.gf b/lib/resource-1.0/abstract/Common.gf index 4ef52ae51..b90329052 100644 --- a/lib/resource-1.0/abstract/Common.gf +++ b/lib/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/lib/resource-1.0/doc/MkSynopsis.hs b/lib/resource-1.0/doc/MkSynopsis.hs index ec4b5903d..576fddb7a 100644 --- a/lib/resource-1.0/doc/MkSynopsis.hs +++ b/lib/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/lib/resource-1.0/doc/synopsis-example.txt b/lib/resource-1.0/doc/synopsis-example.txt new file mode 100644 index 000000000..f435a2316 --- /dev/null +++ b/lib/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/lib/resource-1.0/doc/synopsis.html b/lib/resource-1.0/doc/synopsis.html index c6f2b00d6..151f116f8 100644 --- a/lib/resource-1.0/doc/synopsis.html +++ b/lib/resource-1.0/doc/synopsis.html @@ -13,26 +13,321 @@
-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
+
| Category | +Explanation | +Example | +|
|---|---|---|---|
Text |
+text consisting of several phrases | +"He is here. Why?" | +|
Phr |
+phrase in a text | +"but be quiet please" | +|
Utt |
+sentence, question, word... | +"be quiet" | +|
Voc |
+vocative or "please" | +"my darling" | +|
PConj |
+phrase-beginning conj. | +"therefore" | +|
SC |
+embedded sentence or question | +"that it rains" | +|
Adv |
+verb-phrase-modifying adverb, | +"in the house" | +|
AdV |
+adverb directly attached to verb | +"always" | +|
AdA |
+adjective-modifying adverb, | +"very" | +|
AdN |
+numeral-modifying adverb, | +"more than" | +|
IAdv |
+interrogative adverb | +"why" | +|
CAdv |
+comparative adverb | +"more" | +|
Tense |
+tense | +present, past, future | +|
Pol |
+polarity | +positive, negative | +|
Ant |
+anteriority | +simultaneous, anterior | +|
S |
+declarative sentence | +"she lived here" | +|
QS |
+question | +"where did she live" | +|
RS |
+relative | +"in which she lived" | +|
Cl |
+declarative clause, with all tenses | +"she looks at this" | +|
Slash |
+clause missing NP (S/NP in GPSG) | +"she looks at" | +|
Imp |
+imperative | +"look at this" | +|
QCl |
+question clause, with all tenses | +"why does she walk" | +|
IP |
+interrogative pronoun | +"who" | +|
IComp |
+interrogative complement of copula | +"where" | +|
IDet |
+interrogative determiner | +"which" | +|
RCl |
+relative clause, with all tenses | +"in which she lives" | +|
RP |
+relative pronoun | +"in which" | +|
VP |
+verb phrase | +"is very warm" | +|
Comp |
+complement of copula, such as AP | +"very warm" | +|
AP |
+adjectival phrase | +"very warm" | +|
CN |
+common noun (without determiner) | +"red house" | +|
NP |
+noun phrase (subject or object) | +"the red house" | +|
Pron |
+personal pronoun | +"she" | +|
Det |
+determiner phrase | +"those seven" | +|
Quant |
+quantifier with both sg and pl | +"this/these" | +|
Num |
+cardinal number (used with QuantPl) | +"seven" | +|
Ord |
+ordinal number (used in Det) | +"seventh" | +|
Conj |
+conjunction, | +"and" | +|
DConj |
+distributed conj. | +"both - and" | +|
Subj |
+subjunction, | +"if" | +|
Prep |
+preposition, or just case | +"in" | +|
V |
+one-place verb | +"sleep" | +|
V2 |
+two-place verb | +"love" | +|
V3 |
+three-place verb | +"show" | +|
VV |
+verb-phrase-complement verb | +"want" | +|
VS |
+sentence-complement verb | +"claim" | +|
VQ |
+question-complement verb | +"ask" | +|
VA |
+adjective-complement verb | +"look" | +|
V2A |
+verb with NP and AP complement | +"paint" | +|
A |
+one-place adjective | +"warm" | +|
A2 |
+two-place adjective | +"divisible" | +|
N |
+common noun | +"house" | +|
N2 |
+relational noun | +"son" | +|
N3 |
+three-place relational noun | +"connection" | +|
PN |
+proper name | +"Paris" | +|
+Source: http://www.cs.chalmers.se/~aarne/GF/lib/resource/api/Constructors.gf
+Source: http://www.cs.chalmers.se/~aarne/GF/lib/resource/abstract/Structural.gf
+
| Function | +Type | +Example | +|
|---|---|---|---|
above_Prep |
+Prep |
+- | +|
after_Prep |
+Prep |
+- | +|
all_Predet |
+Predet |
+- | +|
almost_AdA |
+AdA |
+- | +|
almost_AdN |
+AdN |
+- | +|
although_Subj |
+Subj |
+- | +|
always_AdV |
+AdV |
+- | +|
and_Conj |
+Conj |
+- | +|
because_Subj |
+Subj |
+- | +|
before_Prep |
+Prep |
+- | +|
behind_Prep |
+Prep |
+- | +|
between_Prep |
+Prep |
+- | +|
both7and_DConj |
+DConj |
+- | +|
but_PConj |
+PConj |
+- | +|
by8agent_Prep |
+Prep |
+- | +|
by8means_Prep |
+Prep |
+- | +|
can8know_VV |
+VV |
+- | +|
can_VV |
+VV |
+- | +|
during_Prep |
+Prep |
+- | +|
either7or_DConj |
+DConj |
+- | +|
every_Det |
+Det |
+- | +|
everybody_NP |
+NP |
+- | +|
everything_NP |
+NP |
+- | +|
everywhere_Adv |
+Adv |
+- | +|
first_Ord |
+Ord |
+- | +|
few_Det |
+Det |
+- | +|
for_Prep |
+Prep |
+- | +|
from_Prep |
+Prep |
+- | +|
he_Pron |
+Pron |
+- | +|
here_Adv |
+Adv |
+- | +|
here7to_Adv |
+Adv |
+- | +|
here7from_Adv |
+Adv |
+- | +|
how_IAdv |
+IAdv |
+- | +|
how8many_IDet |
+IDet |
+- | +|
i_Pron |
+Pron |
+- | +|
if_Subj |
+Subj |
+- | +|
in8front_Prep |
+Prep |
+- | +|
in_Prep |
+Prep |
+- | +|
it_Pron |
+Pron |
+- | +|
less_CAdv |
+CAdv |
+- | +|
many_Det |
+Det |
+- | +|
more_CAdv |
+CAdv |
+- | +|
most_Predet |
+Predet |
+- | +|
much_Det |
+Det |
+- | +|
must_VV |
+VV |
+- | +|
no_Phr |
+Phr |
+- | +|
on_Prep |
+Prep |
+- | +|
one_Quant |
+QuantSg |
+- | +|
only_Predet |
+Predet |
+- | +|
or_Conj |
+Conj |
+- | +|
otherwise_PConj |
+PConj |
+- | +|
part_Prep |
+Prep |
+- | +|
please_Voc |
+Voc |
+- | +|
possess_Prep |
+Prep |
+- | +|
quite_Adv |
+AdA |
+- | +|
she_Pron |
+Pron |
+- | +|
so_AdA |
+AdA |
+- | +|
someSg_Det |
+Det |
+- | +|
somePl_Det |
+Det |
+- | +|
somebody_NP |
+NP |
+- | +|
something_NP |
+NP |
+- | +|
somewhere_Adv |
+Adv |
+- | +|
that_Quant |
+Quant |
+- | +|
that_NP |
+NP |
+- | +|
there_Adv |
+Adv |
+- | +|
there7to_Adv |
+Adv |
+- | +|
there7from_Adv |
+Adv |
+- | +|
therefore_PConj |
+PConj |
+- | +|
these_NP |
+NP |
+- | +|
they_Pron |
+Pron |
+- | +|
this_Quant |
+Quant |
+- | +|
this_NP |
+NP |
+- | +|
those_NP |
+NP |
+- | +|
through_Prep |
+Prep |
+- | +|
to_Prep |
+Prep |
+- | +|
too_AdA |
+AdA |
+- | +|
under_Prep |
+Prep |
+- | +|
very_AdA |
+AdA |
+- | +|
want_VV |
+VV |
+- | +|
we_Pron |
+Pron |
+- | +|
whatPl_IP |
+IP |
+- | +|
whatSg_IP |
+IP |
+- | +|
when_IAdv |
+IAdv |
+- | +|
when_Subj |
+Subj |
+- | +|
where_IAdv |
+IAdv |
+- | +|
whichPl_IDet |
+IDet |
+- | +|
whichSg_IDet |
+IDet |
+- | +|
whoPl_IP |
+IP |
+- | +|
whoSg_IP |
+IP |
+- | +|
why_IAdv |
+IAdv |
+- | +|
with_Prep |
+Prep |
+- | +|
without_Prep |
+Prep |
+- | +|
yes_Phr |
+Phr |
+- | +|
youSg_Pron |
+Pron |
+- | +|
youPl_Pron |
+Pron |
+- | +|
youPol_Pron |
+Pron |
+- | +|
-source
+source http://www.cs.chalmers.se/~aarne/GF/lib/resource/danish/ParadigmsDan.gf
-source
+source http://www.cs.chalmers.se/~aarne/GF/lib/resource/english/ParadigmsEng.gf
-source
+source http://www.cs.chalmers.se/~aarne/GF/lib/resource/finnish/ParadigmsFin.gf
-source
+source http://www.cs.chalmers.se/~aarne/GF/lib/resource/french/ParadigmsFre.gf
-source
+source http://www.cs.chalmers.se/~aarne/GF/lib/resource/german/ParadigmsGer.gf
-source
+source http://www.cs.chalmers.se/~aarne/GF/lib/resource/italian/ParadigmsIta.gf
-source
+source http://www.cs.chalmers.se/~aarne/GF/lib/resource/norwegian/ParadigmsNor.gf
-source
+source http://www.cs.chalmers.se/~aarne/GF/lib/resource/russian/ParadigmsRus.gf
-source
+source http://www.cs.chalmers.se/~aarne/GF/lib/resource/spanish/ParadigmsSpa.gf
-source
+source http://www.cs.chalmers.se/~aarne/GF/lib/resource/swedish/ParadigmsSwe.gf
+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) ; +