diff --git a/doc/gf2-highlights.html b/doc/gf2-highlights.html index 82c2f358d..9542c3f8d 100644 --- a/doc/gf2-highlights.html +++ b/doc/gf2-highlights.html @@ -6,11 +6,11 @@

Grammatical Framework Version 2

-Highlights, versions 2.0 and 2.1 +Highlights, versions 2.0, 2.1, and 2.2

-13/10/2003 - 25/11 - 2/4/2004 - 18/6 - 13/10 +13/10/2003 - 25/11 - 2/4/2004 - 18/6 - 13/10 - 16/2/2005

@@ -24,7 +24,7 @@ Highlights, versions 2.0 and 2.1 An accurate language specification is now available. -

Summary of novelties

+

Summary of novelties in Versions 2.0 to 2.2

Module system

@@ -35,18 +35,20 @@ An accurate language specification is now available.
  • Hierarchic structure (single inheritance **) + cross-cutting reuse (open)
  • Separate compilation, one module per file -
  • Reuse of abstract+concrete as resource +
  • Reuse of abstract+concrete as resource
    + Version 2.2: separate reuse modules no longer needed
  • Parametrized modules: interface, instance, incomplete.
  • New experimental module types: transfer, union. -
  • Version 2.1: multiple inheritance in module extension. +
  • Version 2.1: multiple inheritance in module extension.

    Canonical format GFC

  • The target of GF compiler; to reuse, just read in.
  • Readable by Haskell/Java/C++/C applications. -
  • Version 2.1: Java interpreter available for GFC (by Björn Bringert). +
  • Version 2.1: Java interpreter available for GFC (by Björn Bringert). +
  • Version 2.2: new optimizations to reduce the size of GFC files

    New features in expression language

    @@ -59,7 +61,7 @@ An accurate language specification is now available. braces and where.
  • Pattern variables can be used on lhs's of oper definitions.
  • New Unicode transliterations (by Harad Hammarström). -
  • Version 2.1: Initial segments of integers +
  • Version 2.1: Initial segments of integers (Intsn) available as parameter types. @@ -78,6 +80,8 @@ An accurate language specification is now available.
  • pm = print_multi prints the multilingual grammar resident in the current state to a ready-compiles .gfcm file. +
  • Version 2.2: several new command options +
  • Version 2.2: vg visializes the module dependency graph
  • All commands have both long and short names (see help). Short names are easier to type, whereas long names make scripts more readable. @@ -89,6 +93,7 @@ An accurate language specification is now available.
  • Active text field: click the middle button in the focus to send in refinement through the parser.
  • Clipboard: copy complex terms into the refine menu. +
  • Version 2.2: text corresponding to subtrees with constraints marked with red colour

    Improved implementation

    @@ -99,6 +104,10 @@ An accurate language specification is now available.
  • Lexical rules sorted out by option -cflexer for efficient parsing with large lexica.
  • GHC optimizations and strictness flags are used for improving performance. +
  • Version 2.2: started haddock documentation + by using uniform module headers +

    New parser (work in progress)

    @@ -106,131 +115,12 @@ An accurate
    language specification is now available.
  • By Peter Ljunglöf, based on MCFG.
  • Much more efficient for morphology and discontinuous constituents.
  • Treatment of cyclic rules. -
  • Version 2.1: improved generation of speech recognition +
  • Version 2.1: improved generation of speech recognition grammars (by Björn Bringert). -
  • Version 2.1: output of Labelled BNF files readable by the +
  • Version 2.1: output of Labelled BNF files readable by the BNF Converter. - - -

    Missing features of GF 1.2 (13/10/2004)

    - -Generally, GF1 grammars can be automatically translated to GF2, although the -result is not as good -as manual, since indentation and comments are destroyed. -The results can be -saved in GF2 files, but this is not necessary. -Some rarely used GF1 features are no longer supported (see next section). -It is also possible to write a GF2 grammar back to GF1, with the -command pg -printer=old. - - -

    - -Resource libraries -and some example grammars have been -converted. Most old example grammars work without any changes. -However, there is a new resource API with -many new constructions, and which is recommended. - -

    - -Soundness checking of module depencencies and completeness is not -complete. This means that some errors may show up too late. - -

    - -Latex and XML printing of grammars do not work yet. - - - - - -

    How to use GF 1.* files

    - -Backward compatibility with respect to old GF grammars has been -a central goal. All GF grammars, from version 0.9, should work in -the old way in GF2. The main exceptions are some features that -are rarely used. - - -

    - -Very old GF grammars (from versions before 0.9), with the completely -different notation, do not work. They should be first converted to -GF1 by using GF version 1.2. - -

    - -The import command i can be given the option -old. E.g. -

    -  i -old tut1.Eng.g2
    -
    -But this is no more necessary: GF2 detects automatically if a grammar -is in the GF1 format. - -

    - -Importing a set of GF2 files generates, internally, three modules: -

    -  abstract tut1 = ...
    -  resource ResEng = ...
    -  concrete Eng of tut1 = open ResEng in ...
    -
    -(The names are different if the file name has fewer parts.) - - -

    - -The option -o causes GF2 to write these modules into files. - -

    - -The flags -abs, -cnc, and -res can be used -to give custom names to the modules. In particular, it is good to use -the -abs flag to guarantee that the abstract syntax module -has the same name for all grammars in a multilingual environmens: -

    -  i -old -abs=Numerals hungarian.gf
    -  i -old -abs=Numerals tamil.gf
    -  i -old -abs=Numerals sanskrit.gf
    -
    - -

    - -The same flags as in the import command can be used when invoking -GF2 from the system shell. Many grammars can be imported on the same command -line, e.g. -

    -  % gf2 -old -abs=Tutorial tut1.Eng.gf tut1.Fin.gf tut1.Fra.gf
    -
    - -

    - -To write a GF2 grammar back to GF1 (as one big file), use the command -

    -  > pg -old
    -
    - - -

    - - -GF2 has more reserved words than GF 1.2. When old files are read, a preprocessor -replaces every identifier that has the shape of a new reserved word -with a variant where the last letter is replaced by Z, e.g. -instance is replaced by instancZ. This method is of course -unsafe and should be replaced by something better. - - @@ -404,6 +294,54 @@ To force compilation: when testing operations with the cc command. + + +

    Compiler optimizations

    + +Version 2.2 + +

    + +The sometimes exploding size of generated gfc and +gfr files has made it urgent to find optimizations +that reduce the size of the code. There are five +combinations optimizations that can be chosen, as the value of the +optimize flag: +

    +The share and parametrize optimizations are always +just good, whereas the values optimization may slow down the +use of the table. However, it is very good for grammars mostly consisting +of the inflection tables of lexical items: it can reduce the file size +by the factor of 4. + +

    + +An optimization can be selected individually for each +resource and concrete module by including +the judgement +

    +  flags optimize=(share|parametrize|values|all|none) ;
    +
    +in the module body. These flags can be overridden by a flag given +in the i command, e.g. +
    +  i -src -optimize=none Foo.gf
    +
    +Notice that the option -src is needed if there already are +generated files created with other optimization flags. + + +

    Module search paths

    @@ -429,7 +367,124 @@ places: A flag set on a command line overrides ones set in files. + +

    How to use GF 1.* files

    + +Backward compatibility with respect to old GF grammars has been +a central goal. All GF grammars, from version 0.9, should work in +the old way in GF2. The main exceptions are some features that +are rarely used. + + +

    + +Very old GF grammars (from versions before 0.9), with the completely +different notation, do not work. They should be first converted to +GF1 by using GF version 1.2. + +

    + +The import command i can be given the option -old. E.g. +

    +  i -old tut1.Eng.g2
    +
    +But this is no more necessary: GF2 detects automatically if a grammar +is in the GF1 format. + +

    + +Importing a set of GF2 files generates, internally, three modules: +

    +  abstract tut1 = ...
    +  resource ResEng = ...
    +  concrete Eng of tut1 = open ResEng in ...
    +
    +(The names are different if the file name has fewer parts.) + + +

    + +The option -o causes GF2 to write these modules into files. + +

    + +The flags -abs, -cnc, and -res can be used +to give custom names to the modules. In particular, it is good to use +the -abs flag to guarantee that the abstract syntax module +has the same name for all grammars in a multilingual environmens: +

    +  i -old -abs=Numerals hungarian.gf
    +  i -old -abs=Numerals tamil.gf
    +  i -old -abs=Numerals sanskrit.gf
    +
    + +

    + +The same flags as in the import command can be used when invoking +GF2 from the system shell. Many grammars can be imported on the same command +line, e.g. +

    +  % gf2 -old -abs=Tutorial tut1.Eng.gf tut1.Fin.gf tut1.Fra.gf
    +
    + +

    + +To write a GF2 grammar back to GF1 (as one big file), use the command +

    +  > pg -old
    +
    + + +

    + + +GF2 has more reserved words than GF 1.2. When old files are read, a preprocessor +replaces every identifier that has the shape of a new reserved word +with a variant where the last letter is replaced by Z, e.g. +instance is replaced by instancZ. This method is of course +unsafe and should be replaced by something better. + + + + +

    Missing features of GF 1.2 (13/10/2004)

    + +Generally, GF1 grammars can be automatically translated to GF2, although the +result is not as good +as manual, since indentation and comments are destroyed. +The results can be +saved in GF2 files, but this is not necessary. +Some rarely used GF1 features are no longer supported (see next section). +It is also possible to write a GF2 grammar back to GF1, with the +command pg -printer=old. + + +

    + +Resource libraries +and some example grammars have been +converted. Most old example grammars work without any changes. +However, there is a new resource API with +many new constructions, and which is recommended. + +

    + +Soundness checking of module depencencies and completeness is not +complete. This means that some errors may show up too late. + +

    + +Latex and XML printing of grammars do not work yet. + + diff --git a/lib/resource/abstract/Resource.gf b/lib/resource/abstract/Resource.gf index 24aac721d..c675bc1ba 100644 --- a/lib/resource/abstract/Resource.gf +++ b/lib/resource/abstract/Resource.gf @@ -1 +1,3 @@ +--# -path=.:../../prelude + abstract Resource = Rules, Clause, Structural ** {} ; diff --git a/lib/resource/doc/Makefile b/lib/resource/doc/Makefile index 7caf2a716..1af678c52 100644 --- a/lib/resource/doc/Makefile +++ b/lib/resource/doc/Makefile @@ -6,17 +6,27 @@ htmls: gfdoc: gfdoc ../abstract/Categories.gf ; mv ../abstract/Categories.html . gfdoc ../abstract/Rules.gf ; mv ../abstract/Rules.html . + gfdoc ../abstract/Verbphrase.gf ; mv ../abstract/Verbphrase.html . gfdoc ../abstract/Clause.gf ; mv ../abstract/Clause.html . gfdoc ../abstract/Structural.gf ; mv ../abstract/Structural.html . gfdoc ../abstract/Basic.gf ; mv ../abstract/Basic.html . gfdoc ../abstract/Time.gf ; mv ../abstract/Time.html . gfdoc ../abstract/Lang.gf ; mv ../abstract/Lang.html . gfdoc ../swedish/ParadigmsSwe.gf ; mv ../swedish/ParadigmsSwe.html . + gfdoc ../swedish/VerbsSwe.gf ; mv ../swedish/VerbsSwe.html . gfdoc ../swedish/BasicSwe.gf ; mv ../swedish/BasicSwe.html . gfdoc ../english/ParadigmsEng.gf ; mv ../english/ParadigmsEng.html . gfdoc ../english/VerbsEng.gf ; mv ../english/VerbsEng.html . + gfdoc ../english/BasicEng.gf ; mv ../english/BasicEng.html . + gfdoc ../french/ParadigmsFre.gf ; mv ../french/ParadigmsFre.html . + gfdoc ../french/VerbsFre.gf ; mv ../french/VerbsFre.html . + gfdoc ../french/BasicFre.gf ; mv ../french/BasicFre.html . -gifs: lang scand low +gifs: api lang scand low + +api: +# echo "pm -printer=graph | wf Resource.dot" | gf ../abstract/Resource.gf + dot -Tgif ResourceVP.dot>Resource.gif lang: echo "pm -printer=graph | wf Lang.dot" | gf ../abstract/Lang.gf diff --git a/lib/resource/doc/ResourceVP.dot b/lib/resource/doc/ResourceVP.dot new file mode 100644 index 000000000..d31fcc288 --- /dev/null +++ b/lib/resource/doc/ResourceVP.dot @@ -0,0 +1,28 @@ +digraph { + +Verbphrase [style = "solid", shape = "ellipse", URL = "Verbphrase.gf"]; +Verbphrase -> Categories [style = "solid"]; + +Resource [style = "solid", shape = "ellipse", URL = "Resource.gf"]; +Resource -> Rules [style = "solid"]; +Resource -> Clause [style = "solid"]; +Resource -> Structural [style = "solid"]; + +Rules [style = "solid", shape = "ellipse", URL = "Rules.gf"]; +Rules -> Categories [style = "solid"]; + +Clause [style = "solid", shape = "ellipse", URL = "Clause.gf"]; +Clause -> Categories [style = "solid"]; + +Structural [style = "solid", shape = "ellipse", URL = "Structural.gf"]; +Structural -> Categories [style = "solid"]; +Structural -> Numerals [style = "solid"]; + +Categories [style = "solid", shape = "ellipse", URL = "Categories.gf"]; +Categories -> PredefAbs [style = "solid"]; + +PredefAbs [style = "solid", shape = "ellipse", URL = "PredefAbs.gf"]; + +Numerals [style = "solid", shape = "ellipse", URL = "Numerals.gf"]; + +} diff --git a/lib/resource/doc/example/Animals.gf b/lib/resource/doc/example/Animals.gf new file mode 100644 index 000000000..a1cb3654a --- /dev/null +++ b/lib/resource/doc/example/Animals.gf @@ -0,0 +1,12 @@ +abstract Animals = { + cat + Phrase ; Animal ; Action ; + fun + Who : Action -> Animal -> Phrase ; + Whom : Animal -> Action -> Phrase ; + Answer : Animal -> Action -> Animal -> Phrase ; + + Dog, Cat, Mouse, Lion, Zebra : Animal ; + Chase, Eat, Like : Action ; +} + diff --git a/lib/resource/doc/example/AnimalsEng.gf b/lib/resource/doc/example/AnimalsEng.gf new file mode 100644 index 000000000..861289fa0 --- /dev/null +++ b/lib/resource/doc/example/AnimalsEng.gf @@ -0,0 +1,37 @@ +--# -path=.:resource/english:resource/abstract:resource/../prelude + +concrete AnimalsEng of Animals = open ResourceEng, ParadigmsEng, VerbsEng in { + lincat + Phrase = Phr ; + Animal = N ; + Action = V2 ; + lin + Who act obj = QuestPhrase (UseQCl (PosTP TPresent ASimul) + (QPredV2 who8one_IP act (IndefNumNP NoNum (UseN obj)))) ; + Whom subj act = QuestPhrase (UseQCl (PosTP TPresent ASimul) + (IntSlash who8one_IP (SlashV2 (DefOneNP (UseN subj)) act))) ; + Answer subj act obj = IndicPhrase (UseCl (PosTP TPresent ASimul) + (SPredV2 (DefOneNP (UseN subj)) act (IndefNumNP NoNum (UseN obj)))) ; + Dog = regN "dog" ; + Cat = regN "cat" ; + Mouse = mk2N "mouse" "mice" ; + Lion = regN "lion" ; + Zebra = regN "zebra" ; + Chase = dirV2 (regV "chase") ; + Eat = dirV2 (eat_V ** {lock_V = <>}) ; + Like = dirV2 (regV "like") ; +} + + +{- +> p -cat=Phr "who likes cars ?" + +QuestPhrase (UseQCl (PosTP TPresent ASimul) (QPredV2 who8one_IP like_V2 (IndefNumNP NoNum (UseN car_N)))) + +QuestPhrase (UseQCl (PosTP TPresent ASimul) (IntSlash who8one_IP (SlashV2 (DefOneNP (UseN car_N)) like_V2))) + +> p -cat=Phr "the house likes cars ." + +IndicPhrase (UseCl (PosTP TPresent ASimul) (SPredV2 (DefOneNP (UseN house_N)) like_V2 (IndefNumNP NoNum (UseN car_N)))) + +-} \ No newline at end of file diff --git a/lib/resource/doc/example/AnimalsFre.gf b/lib/resource/doc/example/AnimalsFre.gf new file mode 100644 index 000000000..ace09a5c0 --- /dev/null +++ b/lib/resource/doc/example/AnimalsFre.gf @@ -0,0 +1,23 @@ +--# -path=.:resource/french:resource/romance:resource/abstract:resource/../prelude + +concrete AnimalsFre of Animals = open ResourceFre, ParadigmsFre, VerbsFre in { + lincat + Phrase = Phr ; + Animal = N ; + Action = V2 ; + lin + Who act obj = QuestPhrase (UseQCl (PosTP TPresent ASimul) + (QPredV2 who8one_IP act (IndefNumNP NoNum (UseN obj)))) ; + Whom subj act = QuestPhrase (UseQCl (PosTP TPresent ASimul) + (IntSlash who8one_IP (SlashV2 (DefOneNP (UseN subj)) act))) ; + Answer subj act obj = IndicPhrase (UseCl (PosTP TPresent ASimul) + (SPredV2 (DefOneNP (UseN subj)) act (IndefNumNP NoNum (UseN obj)))) ; + Dog = regN "chien" masculine ; + Cat = regN "chat" masculine ; + Mouse = regN "souris" feminine ; + Lion = regN "lion" masculine ; + Zebra = regN "zčbre" masculine ; + Chase = dirV2 (regV "chasser") ; + Eat = dirV2 (regV "manger") ; + Like = dirV2 (regV "aimer") ; +} diff --git a/lib/resource/doc/example/AnimalsSwe.gf b/lib/resource/doc/example/AnimalsSwe.gf new file mode 100644 index 000000000..126135b3a --- /dev/null +++ b/lib/resource/doc/example/AnimalsSwe.gf @@ -0,0 +1,23 @@ +--# -path=.:resource/swedish:resource/scandinavian:resource/abstract:resource/../prelude + +concrete AnimalsSwe of Animals = open ResourceSwe, ParadigmsSwe, VerbsSwe in { + lincat + Phrase = Phr ; + Animal = N ; + Action = V2 ; + lin + Who act obj = QuestPhrase (UseQCl (PosTP TPresent ASimul) + (QPredV2 who8one_IP act (IndefNumNP NoNum (UseN obj)))) ; + Whom subj act = QuestPhrase (UseQCl (PosTP TPresent ASimul) + (IntSlash who8one_IP (SlashV2 (DefOneNP (UseN subj)) act))) ; + Answer subj act obj = IndicPhrase (UseCl (PosTP TPresent ASimul) + (SPredV2 (DefOneNP (UseN subj)) act (IndefNumNP NoNum (UseN obj)))) ; + Dog = regN "hund" utrum ; + Cat = mk2N "katt" "katter" ; + Mouse = mkN "mus" "musen" "möss" "mössen" ; + Lion = mk2N "lejon" "lejon" ; + Zebra = regN "zebra" utrum ; + Chase = dirV2 (regV "jaga") ; + Eat = dirV2 äta_V ; + Like = mkV2 (mk2V "tycka" "tycker") "om" ; +} diff --git a/lib/resource/doc/gf-resource.html b/lib/resource/doc/gf-resource.html index 5dd9e0f7a..15dfb93c3 100644 --- a/lib/resource/doc/gf-resource.html +++ b/lib/resource/doc/gf-resource.html @@ -9,7 +9,9 @@

    -First Draft, Gothenburg, 7 February 2005 +Second Version, Gothenburg, 18 February 2005 +
    +First Draft, Gothenburg, 7 February 2005

    @@ -23,18 +25,124 @@ Aarne Ranta -

    The purpose of the resource grammar library

    +

    GF = Grammatical Framework

    -Basic syntactic structures +A grammar formalism based on functional programming and type theory.

    +Designed to be nice for ordinary programmers to use. + +

    + +Mission: to make natural-language applications available for +ordinary programmers, in tasks like +

    +Thus not primarily another theoretical framework for +linguists. + + + +

    Language + Libraries

    + +Writing natural language grammars still requires +theoretical knowledge about the language. + +

    + +Which kind of programmer is easier to find? +

    + +

    + +In main-stream programming, sorting algorithms are not +written by hand but taken from libraries. + +

    + +In the same way, we want to create grammar libraries that encapsulate +basic linguistic facts. + +

    + +Cf. the Java success story: the language is just a half of the +success - libraries are another half. + + + + +

    Example of library-based grammar writing

    + +To define Swedish definite phrases form scratch: +
    +
    +
    +To use a library function for Swedish definite phrases: +
    +
    +
    + + + +

    Questions in grammar library design

    + +What should there be in the library? +
    +
  • morphology, lexicon, syntax, semantics,... + +

    + +How do we organize and present the library? +
    +

  • division into modules, level of granularity +
    +
  • "school grammar" vs. sophisticated linguistic concepts + +

    + +Where do we get the data from? +
    +

  • automatic extraction or hand-writing? +
    +
  • reuse of existing resources? + +

    + +Extra constraint: we want open-source free software. + + + + + + +

    The scope of the resource grammar library

    + All morphological paradigms

    Basic lexicon of structural, common, and irregular words +

    + +Basic syntactic structures + +

    + +Currently no semantics, +no language-specific structures if not +necessary for expressivity. + + +

    Success criteria

    @@ -43,17 +151,23 @@ Grammatical correctness

    -Semantic coverage +Semantic coverage: you can express whatever you want.

    -Usability as library for non-linguists +Usability as library for non-linguists. + +

    + +(Bonus for linguists:) nice generalizations w.r.t. language +families, using the module system of GF. + -

    These are not success criteria

    +

    These are not our success criteria

    -Language coverage +Language coverage: you can parse all expressions.

    @@ -64,11 +178,61 @@ Semantic correctness the time is seventy past forty-two +

    + +(Warning for linguists:) theoretical innovation in +syntax + + + + +

    So where is semantics?

    + +GF incorporates a Logical Framework and is therefore +capable of expressing logical semantics ā la Montague +or any other flavour, including anaphora and discourse. + +

    + +But we do not believe semantics can be given once and +for all for a natural language. + +

    + +Instead, we expect semantics to be given in +application grammars built on semantic models +of different domains. + +

    + +Example application: number theory +

    +  fun Even : Nat -> Prop ;         -- a mathematical predicate
    +
    +  lin Even = predA (regA "even") ; -- English translation
    +  lin Even = predA (regA "pair") ; -- French translation
    +  lin Even = predA (regA "jämn") ; -- Swedish translation
    +
    +How could the resource predict that just these +translations are correct in this domain? + +

    + +Application grammars are built by experts of these domains +who - thanks to resource grammars - do no more need to be +experts in linguistics. + + + + + +

    Languages

    -

    +The current GF Resource Project covers ten languages: +

    > +The first three letters (Dan etc) are used in grammar module names + + + +

    Library structure 1: language-independent API

    + +
  • syntactic Categories (parts of speech, word classes), e.g. +
    +  V ; NP ; CN ; Det ;  -- verb, noun phrase, common noun, determiner
    +
    +
  • Rules for combining words and phrases, e.g. +
    +  DetNP : Det -> CN -> NP ; -- combine Det and CN into NP
    +
    +
  • the most common Structural words (determiners, +conjunctions, pronouns), e.g. +
    +  and_Conj : Conj ;
    +
    + + +

    Library structure 2: language-dependent modules

    + +
  • morphological Paradigms, e.g. +
    +  mkN : Str -> Str -> Str -> Str -> Gender -> N ; -- worst-case nouns
    +  mkN : Str -> N ;                                -- regular nouns
    +
    +
  • irregular Verbs, e.g. +
    +  angripa_V = irregV "angripa" "angrep" "angripit" ;
    +
    +
  • Lexicon of frequent words +
    +  man_N = mkN "man" "mannen" "män" "männen" masculine ;
    +
    +
  • Extended syntax with language-specific rules +
    +  PassBli : V2 -> NP -> VP ;  -- bli överkörd av ngn
    +
    -

    Library structure: overview

    +

    How much can be language-independent?

    -Language-independent API +For the ten languages we have considered, it is possible +to implement the current API.

    -Language-dependent resources +Reservations:

    +
  • does not necessarily extend to all other languages +
  • does not necessarily cover the most idiomatic expressions + of each language +
  • may not be the easiest API to implement (e.g. negation and +inversion with do in English suggest that some other +structure would be more natural) +
  • does not guarantee that same structure has the same semantics +in different languages +

    Library structure: language-independent API

    +
    + +
    + + + +

    Library structure: test bed for the language-independent API

    +
    +

    API documentation

    @@ -113,7 +333,9 @@ Language-dependent resources Rules

    -Clause +Alternative views on sentence formation: +Clause, +Verbphrase

    Structural @@ -135,19 +357,27 @@ Language-dependent resources

    Paradigms documentation

    -English - -

    - +English paradigms +
    +example use of English oaradigms +
    English verbs

    -Swedish +French paradigms +
    +example use of French paradigms +
    +French verbs

    -example of Swedish +Swedish paradigms +
    +example use of Swedish paradigms +
    +Swedish verbs diff --git a/lib/resource/english/ParadigmsEng.gf b/lib/resource/english/ParadigmsEng.gf index 75baeec62..685d8fa33 100644 --- a/lib/resource/english/ParadigmsEng.gf +++ b/lib/resource/english/ParadigmsEng.gf @@ -1,6 +1,6 @@ --# -path=.:../abstract:../../prelude ---1 English Lexical Paradigms UNDER RECONSTRUCTION! +--1 English Lexical Paradigms -- -- Aarne Ranta 2003 -- diff --git a/lib/resource/english/SyntaxEng.gf b/lib/resource/english/SyntaxEng.gf index a8c5020b9..c2d15077f 100644 --- a/lib/resource/english/SyntaxEng.gf +++ b/lib/resource/english/SyntaxEng.gf @@ -1076,7 +1076,7 @@ oper intPronWho : Number -> IntPron = \num -> { s = table { NomP => "who" ; - AccP => variants {"who" ; "whom"} ; + AccP => variants {"whom" ; "who"} ; GenP => "whose" ; GenSP => "whom" } ; diff --git a/lib/resource/swedish/ParadigmsSwe.gf b/lib/resource/swedish/ParadigmsSwe.gf index 5c5b98878..f0b8fe306 100644 --- a/lib/resource/swedish/ParadigmsSwe.gf +++ b/lib/resource/swedish/ParadigmsSwe.gf @@ -1,6 +1,6 @@ --# -path=.:../scandinavian:../abstract:../../prelude ---1 Swedish Lexical Paradigms UNDER RECONSTRUCTION! +--1 Swedish Lexical Paradigms -- -- Aarne Ranta 2003 -- diff --git a/src/GF/API/IOGrammar.hs b/src/GF/API/IOGrammar.hs index 85dd3bbd1..6bebba83f 100644 --- a/src/GF/API/IOGrammar.hs +++ b/src/GF/API/IOGrammar.hs @@ -53,11 +53,11 @@ shellStateFromFiles :: Options -> ShellState -> FilePath -> IOE ShellState shellStateFromFiles opts st file = case fileSuffix file of "gfcm" -> do cenv <- compileOne opts (compileEnvShSt st []) file - ioeErr $ updateShellState opts st cenv + ioeErr $ updateShellState opts Nothing st cenv s | elem s ["cf","ebnf"] -> do let osb = addOptions (options [beVerbose]) opts grts <- compileModule osb st file - ioeErr $ updateShellState opts st grts + ioeErr $ updateShellState opts Nothing st grts _ -> do b <- ioeIO $ isOldFile file let opts' = if b then (addOption showOld opts) else opts @@ -66,7 +66,8 @@ shellStateFromFiles opts st file = case fileSuffix file of then addOptions (options [beVerbose]) opts' -- for old no emit else addOptions (options [beVerbose, emitCode]) opts' grts <- compileModule osb st file - ioeErr $ updateShellState opts' st grts + let top = identC $ justModuleName file + ioeErr $ updateShellState opts' (Just top) st grts --- liftM (changeModTimes rts) $ grammar2shellState opts gr getShellStateFromFiles :: Options -> FilePath -> IO ShellState diff --git a/src/GF/Compile/ModDeps.hs b/src/GF/Compile/ModDeps.hs index 797b445e0..bc47e23a5 100644 --- a/src/GF/Compile/ModDeps.hs +++ b/src/GF/Compile/ModDeps.hs @@ -118,12 +118,14 @@ openInterfaces ds m = do -- | this function finds out what modules are really needed in the canoncal gr. -- its argument is typically a concrete module name -requiredCanModules :: (Eq i, Show i) => MGrammar i f a -> i -> [i] -requiredCanModules gr = nub . iterFix (concatMap more) . singleton where +requiredCanModules :: (Ord i, Show i) => MGrammar i f a -> i -> [i] +requiredCanModules gr = nub . iterFix (concatMap more) . allExtends gr where more i = errVal [] $ do m <- lookupModMod gr i - return $ extends m ++ map openedModule (opens m) - + return $ extends m ++ [o | o <- map openedModule (opens m), notReuse o] + notReuse i = errVal True $ do + m <- lookupModMod gr i + return $ isModRes m -- to exclude reused Cnc and Abs from required {- diff --git a/src/GF/Compile/Optimize.hs b/src/GF/Compile/Optimize.hs index 605d50061..1b0d5e464 100644 --- a/src/GF/Compile/Optimize.hs +++ b/src/GF/Compile/Optimize.hs @@ -112,8 +112,8 @@ evalCncInfo gr cnc abs (c,info) = case info of return (c, CncCat ptyp pde' ppr') - CncFun (mt@(Just (_,ty))) pde ppr -> eIn ("linearization in type" +++ - show ty +++ "of") $ do + CncFun (mt@(Just (_,ty@(cont,val)))) pde ppr -> + eIn ("linearization in type" +++ prt (mkProd (cont,val,[])) ++++ "of function") $ do pde' <- case pde of Yes de -> do liftM yes $ pEval ty de diff --git a/src/GF/Compile/ShellState.hs b/src/GF/Compile/ShellState.hs index ebd85784a..abda01100 100644 --- a/src/GF/Compile/ShellState.hs +++ b/src/GF/Compile/ShellState.hs @@ -123,16 +123,18 @@ cncModuleIdST = stateGrammarST -- | form a shell state from a canonical grammar grammar2shellState :: Options -> (CanonGrammar, G.SourceGrammar) -> Err ShellState grammar2shellState opts (gr,sgr) = - updateShellState opts emptyShellState ((0,sgr,gr),[]) --- is 0 safe? + updateShellState opts Nothing emptyShellState ((0,sgr,gr),[]) --- is 0 safe? -- | update a shell state from a canonical grammar -updateShellState :: Options -> ShellState -> +updateShellState :: Options -> Maybe Ident -> ShellState -> ((Int,G.SourceGrammar,CanonGrammar),[(FilePath,ModTime)]) -> ---- (CanonGrammar,(G.SourceGrammar,[(FilePath,ModTime)])) -> Err ShellState -updateShellState opts sh ((_,sgr,gr),rts) = do +updateShellState opts mcnc sh ((_,sgr,gr),rts) = do let cgr0 = M.updateMGrammar (canModules sh) gr - a' = M.greatestAbstract cgr0 + a' <- return $ case mcnc of + Just cnc -> err (const Nothing) Just $ M.abstractOfConcrete cgr0 cnc + _ -> M.greatestAbstract cgr0 abstr0 <- case abstract sh of Just a -> do -- test that abstract is compatible --- unsafe exception for old? diff --git a/src/GF/Grammar/Compute.hs b/src/GF/Grammar/Compute.hs index 643621119..50f640b71 100644 --- a/src/GF/Grammar/Compute.hs +++ b/src/GF/Grammar/Compute.hs @@ -24,6 +24,7 @@ import Macros import Lookup import Refresh import PatternMatch +import Lockfield (isLockLabel) ---- import AppPredefined @@ -82,6 +83,12 @@ computeTerm gr = comp where (S (T i cs) e,_) -> prawitz g i (flip App a') cs e _ -> returnC $ appPredefined $ App f' a' + + P t l | isLockLabel l -> return $ R [] + ---- a workaround 18/2/2005: take this away and find the reason + ---- why earlier compilation destroys the lock field + + P t l -> do t' <- comp g t case t' of diff --git a/src/GF/Grammar/Lockfield.hs b/src/GF/Grammar/Lockfield.hs index f283dde93..f7ec081bd 100644 --- a/src/GF/Grammar/Lockfield.hs +++ b/src/GF/Grammar/Lockfield.hs @@ -12,7 +12,7 @@ -- Creating and using lock fields in reused resource grammars. ----------------------------------------------------------------------------- -module Lockfield (lockRecType, unlockRecord, lockLabel) where +module Lockfield (lockRecType, unlockRecord, lockLabel, isLockLabel) where import Grammar import Ident @@ -40,3 +40,7 @@ unlockRecord c ft = do lockLabel :: Ident -> Label lockLabel c = LIdent $ "lock_" ++ prt c ---- +isLockLabel :: Label -> Bool +isLockLabel l = case l of + LIdent c -> take 5 c == "lock_" + _ -> False \ No newline at end of file diff --git a/src/GF/Grammar/Lookup.hs b/src/GF/Grammar/Lookup.hs index 06672cb72..d0c8434ce 100644 --- a/src/GF/Grammar/Lookup.hs +++ b/src/GF/Grammar/Lookup.hs @@ -60,8 +60,17 @@ lookupResType gr m c = do -- used in reused concrete CncCat _ _ _ -> return typeType - CncFun (Just (_,(cont,val))) _ _ -> return $ mkProd (cont, val, []) - + CncFun (Just (cat,(cont,val))) _ _ -> do + val' <- lockRecType cat val + return $ mkProd (cont, val', []) + CncFun _ _ _ -> do + a <- abstractOfConcrete gr m + mu <- lookupModMod gr a + info <- lookupInfo mu c + case info of + AbsFun (Yes ty) _ -> return $ redirectTerm m ty + AbsCat _ _ -> return typeType + _ -> prtBad "cannot find type of reused function" c AnyInd _ n -> lookupResType gr n c ResParam _ -> return $ typePType ResValue (Yes t) -> return $ qualifAnnotPar m t diff --git a/src/GF/Grammar/Macros.hs b/src/GF/Grammar/Macros.hs index cb4dcc526..62a15a511 100644 --- a/src/GF/Grammar/Macros.hs +++ b/src/GF/Grammar/Macros.hs @@ -486,6 +486,12 @@ patt2term pt = case pt of PInt i -> EInt i PString s -> K s +redirectTerm :: Ident -> Term -> Term +redirectTerm n t = case t of + QC _ f -> QC n f + Q _ f -> Q n f + _ -> composSafeOp (redirectTerm n) t + -- to gather s-fields; assumes term in normal form, preserves label allLinFields :: Term -> Err [[(Label,Term)]] allLinFields trm = case unComputed trm of