From a28eeb58bd2ce2bb1cd198a11acc0800ef0ddddf Mon Sep 17 00:00:00 2001 From: aarne Date: Wed, 1 Feb 2006 23:04:05 +0000 Subject: [PATCH] Latin example in HOWTO --- lib/resource-1.0/doc/Resource-HOWTO.html | 89 ++++++--- lib/resource-1.0/doc/Resource-HOWTO.txt | 34 +++- lib/resource-1.0/doc/latin.gf | 175 ++++++++++++++++++ .../mathematical/MathematicalFre.gf | 2 +- .../mathematical/MathematicalIta.gf | 2 +- 5 files changed, 271 insertions(+), 31 deletions(-) create mode 100644 lib/resource-1.0/doc/latin.gf diff --git a/lib/resource-1.0/doc/Resource-HOWTO.html b/lib/resource-1.0/doc/Resource-HOWTO.html index 61ed5cdc7..960527f09 100644 --- a/lib/resource-1.0/doc/Resource-HOWTO.html +++ b/lib/resource-1.0/doc/Resource-HOWTO.html @@ -7,7 +7,7 @@

Resource grammar writing HOWTO

Author: Aarne Ranta <aarne (at) cs.chalmers.se>
-Last update: Wed Jan 25 15:04:36 2006 +Last update: Thu Feb 2 00:04:00 2006

@@ -30,22 +30,23 @@ Last update: Wed Jan 25 15:04:36 2006
  • Lock fields
  • Lexicon construction -
  • Inside grammar modules +
  • The core of the syntax +
  • Inside grammar modules -
  • Lexicon extension +
  • Lexicon extension -
  • Writing an instance of parametrized resource grammar implementation -
  • Parametrizing a resource grammar implementation +
  • Writing an instance of parametrized resource grammar implementation +
  • Parametrizing a resource grammar implementation

    @@ -175,6 +176,14 @@ try out the module explained in the GF Tutorial.

    +

    +Another reduced API is the +toy Latin grammar +which will be used as a reference when discussing the details. +It is not so usable in practice as the Tutorial API, but it goes +deeper in explaining what parameters and dependencies the principal categories +and rules have. +

    Phases of the work

    @@ -494,19 +503,45 @@ use of the paradigms in BasicGer gives a good set of examples for those who want to build new lexica.

    +

    The core of the syntax

    +

    +Among all categories and functions, there is is a handful of the +most important and distinct ones, of which the others are can be +seen as variations. The categories are +

    +
    +    Cl ; VP ; V2 ; NP ; CN ; Det ; AP ;
    +
    +

    +The functions are +

    +
    +    PredVP  : NP  -> VP -> Cl ;  -- predication
    +    ComplV2 : V2  -> NP -> VP ;  -- complementization
    +    DetCN   : Det -> CN -> NP ;  -- determination
    +    ModCN   : AP  -> CN -> CN ;  -- modification
    +
    +

    +This toy Latin grammar shows in a nutshell how these +rules relate the categories to each other. It is intended to be a +first approximation when designing the parameter system of a new +language. We will refer to the implementations contained in it +when discussing the modules in more detail. +

    +

    Inside grammar modules

    So far we just give links to the implementations of each API. -More explanation iś to follow - but many detail implementation tricks -are only found in the cooments of the modules. +More explanations follow - but many detail implementation tricks +are only found in the comments of the modules.

    - +

    The category system

    - +

    Phrase category modules

    - +

    Resource modules

    - +

    Lexicon

    - -

    Lexicon extension

    +

    Lexicon extension

    +

    The irregularity lexicon

    It may be handy to provide a separate module of irregular @@ -551,7 +586,7 @@ few hundred perhaps. Building such a lexicon separately also makes it less important to cover everything by the worst-case paradigms (mkV etc).

    - +

    Lexicon extraction from a word list

    You can often find resources such as lists of @@ -586,7 +621,7 @@ When using ready-made word lists, you should think about coyright issues. Ideally, all resource grammar material should be provided under GNU General Public License.

    - +

    Lexicon extraction from raw text data

    This is a cheap technique to build a lexicon of thousands @@ -594,7 +629,7 @@ of words, if text data is available in digital format. See the Functional Morphology homepage for details.

    - +

    Extending the resource grammar API

    Sooner or later it will happen that the resource grammar API @@ -603,7 +638,7 @@ that it does not include idiomatic expressions in a given language. The solution then is in the first place to build language-specific extension modules. This chapter will deal with this issue.

    - +

    Writing an instance of parametrized resource grammar implementation

    Above we have looked at how a resource implementation is built by @@ -621,7 +656,7 @@ use parametrized modules. The advantages are In this chapter, we will look at an example: adding Italian to the Romance family.

    - +

    Parametrizing a resource grammar implementation

    This is the most demanding form of resource grammar writing. @@ -637,6 +672,6 @@ This chapter will work out an example of how an Estonian grammar is constructed from the Finnish grammar through parametrization.

    - + diff --git a/lib/resource-1.0/doc/Resource-HOWTO.txt b/lib/resource-1.0/doc/Resource-HOWTO.txt index eaa4d556e..744f7be55 100644 --- a/lib/resource-1.0/doc/Resource-HOWTO.txt +++ b/lib/resource-1.0/doc/Resource-HOWTO.txt @@ -127,6 +127,13 @@ try out the module explained in the [GF Tutorial http://www.cs.chalmers.se/~aarne/GF/doc/tutorial/gf-tutorial2.html]. +Another reduced API is the +[toy Latin grammar latin.gf] +which will be used as a reference when discussing the details. +It is not so usable in practice as the Tutorial API, but it goes +deeper in explaining what parameters and dependencies the principal categories +and rules have. + @@ -426,11 +433,34 @@ those who want to build new lexica. +==The core of the syntax== + +Among all categories and functions, there is is a handful of the +most important and distinct ones, of which the others are can be +seen as variations. The categories are +``` + Cl ; VP ; V2 ; NP ; CN ; Det ; AP ; +``` +The functions are +``` + PredVP : NP -> VP -> Cl ; -- predication + ComplV2 : V2 -> NP -> VP ; -- complementization + DetCN : Det -> CN -> NP ; -- determination + ModCN : AP -> CN -> CN ; -- modification +``` +This [toy Latin grammar latin.gf] shows in a nutshell how these +rules relate the categories to each other. It is intended to be a +first approximation when designing the parameter system of a new +language. We will refer to the implementations contained in it +when discussing the modules in more detail. + + + ==Inside grammar modules== So far we just give links to the implementations of each API. -More explanation iś to follow - but many detail implementation tricks -are only found in the cooments of the modules. +More explanations follow - but many detail implementation tricks +are only found in the comments of the modules. ===The category system=== diff --git a/lib/resource-1.0/doc/latin.gf b/lib/resource-1.0/doc/latin.gf new file mode 100644 index 000000000..f00f0d4fc --- /dev/null +++ b/lib/resource-1.0/doc/latin.gf @@ -0,0 +1,175 @@ +--1 A Latin grammar to illustrate some main dependencies +-- +-- All implementations of the resource API have so far been variations +-- and extensions of this. The most notable regularities are +-- - which types of features each category has +-- - how inherent features are inherited and passed to parameters +-- +-- + + +cat + Cl ; -- clause + VP ; -- verb phrase + V2 ; -- two-place verb + NP ; -- noun phrase + CN ; -- common noun + Det ; -- determiner + AP ; -- adjectival phrase + +fun + PredVP : NP -> VP -> Cl ; -- predication + ComplV2 : V2 -> NP -> VP ; -- complementization + DetCN : Det -> CN -> NP ; -- determination + ModCN : AP -> CN -> CN ; -- modification + +param + Number = Sg | Pl ; + Person = P1 | P2 | P3 ; + Tense = Pres | Past ; + Polarity = Pos | Neg ; + Case = Nom | Acc | Dat ; + Gender = Masc | Fem | Neutr ; + +oper + Agr = {g : Gender ; n : Number ; p : Person} ; -- agreement features + +lincat + Cl = { + s : Tense => Polarity => Str + } ; + VP = { + verb : Tense => Polarity => Agr => Str ; + neg : Polarity => Str ; -- negation + compl : Agr => Str -- complement + } ; + V2 = { + s : Tense => Number => Person => Str ; + c : Case -- complement case + } ; + NP = { + s : Case => Str ; + a : Agr -- agreement features + } ; + CN = { + s : Number => Case => Str ; + g : Gender + } ; + Det = { + s : Gender => Case => Str ; + n : Number + } ; + AP = { + s : Gender => Number => Case => Str + } ; + +lin + PredVP np vp = { + s = \\t,p => + let + agr = np.a ; + subject = np.s ! Nom ; + object = vp.compl ! agr ; + verb = vp.neg ! p ++ vp.verb ! t ! p ! agr + in + subject ++ object ++ verb + } ; + + ComplV2 v np = { + verb = \\t,p,a => v.s ! t ! a.n ! a.p ; + compl = \\_ => np.s ! v.c ; + neg = table {Pos => [] ; Neg => "non"} + } ; + + DetCN det cn = + let + g = cn.g ; + n = det.n + in { + s = \\c => det.s ! g ! c ++ cn.s ! n ! c ; + a = {g = g ; n = n ; p = P3} + } ; + + ModCN ap cn = + let + g = cn.g + in { + s = \\n,c => cn.s ! n ! c ++ ap.s ! g ! n ! c ; + g = g + } ; + +-- lexicon to test + +fun + ego_NP : NP ; + omnis_Det : Det ; + defPl_Det : Det ; + + amare_V2 : V2 ; + licere_V2 : V2 ; + puella_CN : CN ; + servus_CN : CN ; + habilis_AP : AP ; + +lin + ego_NP = { + s = table Case ["ego" ; "me" ; "mihi"] ; + a = {g = Fem ; n = Sg ; p = P1} + } ; + + omnis_Det = { + s = table { + Masc | Fem => table Case ["omnis" ; "omnem" ; "omni"] ; + _ => table Case ["omne" ; "omne" ; "omni"] + } ; + n = Sg + } ; + + defPl_Det = { + s = \\_,_ => [] ; + n = Pl + } ; + + amare_V2 = { + s = \\t,n,p => table (Tense * Number * Person) [ + "amo" ; "amas" ; "amat" ; "amamus" ; "amatis" ; "amant" ; + "amabam" ; "amabas" ; "amabat" ; "amabamus" ; "amabatis" ; "amabant" + ] ! ; + c = Acc + } ; + + licere_V2 = { + s = \\t,n,p => table (Tense * Number * Person) [ + "liceo" ; "lices" ; "licet" ; "licemus" ; "licetis" ; "licent" ; + "licebam" ; "licebas" ; "licebat" ; "licebamus" ; "licebatis" ; "licebant" + ] ! ; + c = Dat + } ; + + puella_CN = { + s = \\n,c => table (Number * Case) [ + "puella" ; "puellam" ; "puellae" ; + "puellae" ; "puellas" ; "puellis" + ] ! ; + g = Fem + } ; + + servus_CN = { + s = \\n,c => table (Number * Case) [ + "servus" ; "servum" ; "servo" ; + "servi" ; "servos" ; "servis" + ] ! ; + g = Masc + } ; + + habilis_AP = { + s = table { + Masc | Fem => \\n,c => table (Number * Case) [ + "habilis" ; "habilem" ; "habili" ; "habiles" ; "habiles" ; "habilibus" + ] ! ; + _ => \\n,c => table (Number * Case) [ + "habile" ; "habile" ; "habili" ; "habilia" ; "habilia" ; "habilibus" + ] ! + } + } ; + diff --git a/lib/resource-1.0/mathematical/MathematicalFre.gf b/lib/resource-1.0/mathematical/MathematicalFre.gf index 2bb1bb203..8d07e2e08 100644 --- a/lib/resource-1.0/mathematical/MathematicalFre.gf +++ b/lib/resource-1.0/mathematical/MathematicalFre.gf @@ -14,7 +14,7 @@ concrete MathematicalFre of Mathematical = StructuralFre, SymbolFre, - PredicationFre, + PredicationFre - [predV3], ---- gf bug LexiconFre ** { diff --git a/lib/resource-1.0/mathematical/MathematicalIta.gf b/lib/resource-1.0/mathematical/MathematicalIta.gf index 11d8224f6..c9ff3ac8f 100644 --- a/lib/resource-1.0/mathematical/MathematicalIta.gf +++ b/lib/resource-1.0/mathematical/MathematicalIta.gf @@ -14,7 +14,7 @@ concrete MathematicalIta of Mathematical = StructuralIta, SymbolIta, - PredicationIta, + PredicationIta, -- - [predV3,predV2], --- gf bug LexiconIta ** {