1
0
forked from GitHub/gf-core

comments in phrasebook abstract syntax

This commit is contained in:
aarne
2010-04-06 15:45:16 +00:00
parent 114cdd78d3
commit a66d2186fe
15 changed files with 133 additions and 82 deletions

View File

@@ -5,6 +5,7 @@ concrete DisambPhrasebookEng of Phrasebook = PhrasebookEng -
IMale, IFemale,
YouFamMale, YouFamFemale,
YouPolMale, YouPolFemale,
LangNat, -- CitiNat,
GExcuse, GExcusePol,
GSorry, GSorryPol,
GPleaseGive, GPleaseGivePol
@@ -18,6 +19,9 @@ lin
YouPolMale = mkP youPol_Pron "(polite,male)" ;
YouPolFemale = mkP youPol_Pron "(polite,female)" ;
LangNat nat = mkNP nat.lang (ParadigmsEng.mkAdv "(language)") ;
-- CitiNat nat = nat.prop ;
GExcuse = fam "excuse me" ;
GExcusePol = pol "excuse me" ;
GSorry = fam "sorry" ;

View File

@@ -1,7 +1,7 @@
abstract Greetings = {
cat
Greeting ;
Greeting ; -- idiomatic phrase, not inflected, e.g. "hello"
fun
GHello : Greeting ;

View File

@@ -1,17 +1,42 @@
-- This module contains phrases that can be defined by a functor over the
-- resource grammar API. The phrases that are likely to have different implementations
-- are in the module Words. But the distinction is not quite sharp; thus it may happen
-- that the functor instantiations make exceptions.
abstract Sentences = Numeral ** {
-- The ontology of the phrasebook is defined by the following types.
cat
Phrase ;
Sentence ; Question ; Proposition ;
Object ; Item ; Kind ; Quality ; Property ;
Place ; PlaceKind ; Currency ; Price ;
Person ; Action ;
Nationality ; Language ; Citizenship ; Country ;
Day ; -- weekday type
Date ; -- definite date
Name ;
Phrase ; -- complete phrase, the unit of translation e.g. "Where are you?"
Sentence ; -- declarative sentence e.g. "I am in the bar"
Question ; -- question, either yes/no or wh e.g. "where are you"
-- Greeting ; -- idiomatic phrase, not inflected, e.g. "hello"
Proposition ; -- can be turned into sentence or question e.g. "this pizza is good"
Object ; -- the object of wanting, ordering, etc e.g. "three pizzas"
Item ; -- a single entity e.g. "this pizza"
Kind ; -- a type of an item e.g. "pizza"
Quality ; -- qualification of an item, can be complex e.g. "very good"
Property ; -- basic property of an item, one word e.g. "good"
Place ; -- location e.g. "the bar"
PlaceKind ; -- type of location e.g. "bar"
Currency ; -- currency unit e.g. "leu"
Price ; -- number of currency units e.g. "eleven leu"
Person ; -- agent wanting or doing something e.g. "you"
Action ; -- proposition about a Person e.g. "you are here"
Nationality ; -- complex of language, property, country e.g. "Swedish, Sweden"
Language ; -- language (can be without nationality) e.g. "Flemish"
Citizenship ; -- property (can be without language) e.g. "Belgian"
Country ; -- country (can be without language) e.g. "Belgium"
Day ; -- weekday type e.g. "Friday"
Date ; -- definite date e.g. "on Friday"
Name ; -- name of person e.g. "NN"
-- Numeral ; -- number expression 1 .. 999,999 e.g. "twenty"
-- Many of the categories are accessible as Phrases, i.e. as translation units.
fun
-- these phrases are formed here, not in Phrasebook, as they are functorial
PSentence : Sentence -> Phrase ;
PQuestion : Question -> Phrase ;
@@ -28,45 +53,67 @@ abstract Sentences = Numeral ** {
PCountry : Country -> Phrase ;
PDay : Day -> Phrase ;
Is : Item -> Quality -> Proposition ;
-- This is the way to build propositions about inanimate items.
SProp : Proposition -> Sentence ;
SPropNot : Proposition -> Sentence ;
QProp : Proposition -> Question ;
Is : Item -> Quality -> Proposition ; -- this pizza is good
WhereIs : Place -> Question ;
SProp : Proposition -> Sentence ; -- this pizza is good
SPropNot : Proposition -> Sentence ; -- this pizza isn't good
QProp : Proposition -> Question ; -- is this pizza good
PropAction : Action -> Proposition ;
WherePlace : Place -> Question ; -- where is the bar
WherePerson : Person -> Question ; -- where are you
HowMuchCost : Item -> Question ;
ItCost : Item -> Price -> Proposition ;
AmountCurrency : Numeral -> Currency -> Price ;
-- This is the way to build propositions about persons.
ObjItem : Item -> Object ;
ObjNumber : Numeral -> Kind -> Object ;
ObjIndef : Kind -> Object ;
PropAction : Action -> Proposition ; -- (you (are|aren't) | are you) Swedish
-- Here are some general syntactic constructions.
ObjItem : Item -> Object ; -- this pizza
ObjNumber : Numeral -> Kind -> Object ; -- five pizzas
ObjIndef : Kind -> Object ; -- a pizza
This, That, These, Those, The, Thes : Kind -> Item ;
SuchKind : Quality -> Kind -> Kind ;
Very : Property -> Quality ;
Too : Property -> Quality ;
PropQuality : Property -> Quality ;
SuchKind : Quality -> Kind -> Kind ; -- Italian pizza
Very : Property -> Quality ; -- very Italian
Too : Property -> Quality ; -- too Italian
PropQuality : Property -> Quality ; -- Italian
ThePlace : PlaceKind -> Place ;
-- Determiners.
IMale, IFemale,
YouFamMale, YouFamFemale,
YouPolMale, YouPolFemale : Person ;
This, That, These, Those : Kind -> Item ; -- this pizza,...,those pizzas
The, Thes : Kind -> Item ; -- the pizza, the pizzas
LangNat : Nationality -> Language ;
CitiNat : Nationality -> Citizenship ;
CountryNat : Nationality -> Country ;
PropCit : Citizenship -> Property ;
AmountCurrency : Numeral -> Currency -> Price ; -- five euros
HowMuchCost : Item -> Question ; -- how much does the pizza cost
ItCost : Item -> Price -> Proposition ; -- the pizza costs five euros
OnDay : Day -> Date ;
Today : Date ;
ThePlace : PlaceKind -> Place ; -- the bar
IMale, IFemale, -- I, said by man/woman (affects agreement)
YouFamMale, YouFamFemale, -- familiar you, said to man/woman (affects agreement)
YouPolMale, YouPolFemale : Person ; -- polite you, said to man/woman (affects agreement)
LangNat : Nationality -> Language ; -- Swedish
CitiNat : Nationality -> Citizenship ; -- Swedish
CountryNat : Nationality -> Country ; -- Sweden
PropCit : Citizenship -> Property ; -- Swedish
OnDay : Day -> Date ; -- on Friday
Today : Date ; -- today
PersonName : Name -> Person ; -- person referred by name
NameNN : Name ; -- the name "NN"
PersonName : Name -> Person ;
---- NameString : String -> Name ; ---- creates ambiguities with all words
NameNN : Name ; -- the name "NN"
-- Actions are typically language-dependent, not only lexically but also
-- structurally. However, these ones are mostly functorial.
AHave : Person -> Kind -> Action ; -- you have a pizza
ACitizen : Person -> Citizenship -> Action ; -- you are Swedish
ABePlace : Person -> Place -> Action ; -- you are in the bar
}

View File

@@ -52,7 +52,8 @@ incomplete concrete SentencesI of Sentences = Numeral **
SPropNot = mkS negativePol ;
QProp p = mkQS (mkQCl p) ;
WhereIs place = mkQS (mkQCl where_IAdv place.name) ;
WherePlace place = mkQS (mkQCl where_IAdv place.name) ;
WherePerson person = mkQS (mkQCl where_IAdv person.name) ;
PropAction a = a ;
@@ -100,6 +101,10 @@ incomplete concrete SentencesI of Sentences = Numeral **
---- NameString s = symb s ;
NameNN = symb "NN" ;
AHave p kind = mkCl p.name have_V2 (mkNP kind) ;
ACitizen p n = mkCl p.name n ;
ABePlace p place = mkCl p.name place.at ;
oper
mkPhrase : Utt -> Text = \u -> lin Text u ; -- no punctuation

View File

@@ -23,10 +23,8 @@ abstract Words = Sentences ** {
AWant : Person -> Object -> Action ;
ALike : Person -> Item -> Action ;
AHave : Person -> Kind -> Action ;
ASpeak : Person -> Language -> Action ;
ALove : Person -> Person -> Action ;
ACitizen : Person -> Citizenship -> Action ;
AHungry : Person -> Action ;
AThirsty : Person -> Action ;
ATired : Person -> Action ;
@@ -35,7 +33,6 @@ abstract Words = Sentences ** {
AUnderstand : Person -> Action ;
AKnow : Person -> Action ;
AWantGo : Person -> Place -> Action ;
ABePlace : Person -> Place -> Action ;
AHasName : Person -> Name -> Action ;
ALive : Person -> Country -> Action ;

View File

@@ -55,10 +55,8 @@ concrete WordsEng of Words = SentencesEng **
AWant p obj = mkCl p.name (mkV2 (mkV "want")) obj ;
ALike p item = mkCl p.name (mkV2 (mkV "like")) item ;
AHave p kind = mkCl p.name have_V2 (mkNP kind) ;
ASpeak p lang = mkCl p.name (mkV2 IrregEng.speak_V) lang ;
ALove p q = mkCl p.name (mkV2 (mkV "love")) q.name ;
ACitizen p n = mkCl p.name n ;
AHungry p = mkCl p.name (mkA "hungry") ;
AThirsty p = mkCl p.name (mkA "thirsty") ;
ATired p = mkCl p.name (mkA "tired") ;
@@ -67,7 +65,6 @@ concrete WordsEng of Words = SentencesEng **
AUnderstand p = mkCl p.name IrregEng.understand_V ;
AKnow p = mkCl p.name IrregEng.know_V ;
AWantGo p place = mkCl p.name want_VV (mkVP (mkVP IrregEng.go_V) place.to) ;
ABePlace p place = mkCl p.name place.at ;
AHasName p name = mkCl (nameOf p) name ;
ALive p co =
mkCl p.name (mkVP (mkVP (mkV "live")) (SyntaxEng.mkAdv in_Prep co)) ;

View File

@@ -63,10 +63,8 @@ concrete WordsFin of Words = SentencesFin **
AWant p obj = mkCl p.name want_V2 obj ;
ALike p item = mkCl p.name L.like_V2 item ;
AHave p kind = mkCl p.name have_V2 (mkNP kind) ;
ASpeak p lang = mkCl p.name (mkV2 (mkV "puhua") partitive) lang ;
ALove p q = mkCl p.name (mkV2 (mkV "rakastaa") partitive) q.name ;
ACitizen p n = mkCl p.name n ;
AHungry p = mkCl p.name have_V2 (mkNP (mkN "nälkä")) ;
AThirsty p = mkCl p.name have_V2 (mkNP (mkN "jano")) ;
ATired p = mkCl p.name (caseV partitive (mkV "väsyttää")) ;
@@ -75,7 +73,6 @@ concrete WordsFin of Words = SentencesFin **
AUnderstand p = mkCl p.name (mkV "ymmärtää") ;
AKnow p = mkCl p.name (mkV "tietää") ;
AWantGo p place = mkCl p.name want_VV (mkVP (mkVP L.go_V) place.to) ;
ABePlace p place = mkCl p.name place.at ;
AHasName p name = mkCl (nameOf p) name ;
ALive p co =
mkCl p.name (mkVP (mkVP (mkV "asua")) (SyntaxFin.mkAdv in_Prep co)) ;

View File

@@ -8,35 +8,33 @@ concrete WordsFre of Words = SentencesFre ** open
ParadigmsFre,
(P = ParadigmsFre) in {
flags coding=utf8 ;
lin
Wine = mkCN (mkN "vin") ;
Beer = mkCN (mkN "bière") ;
Beer = mkCN (mkN "bière") ;
Water = mkCN (mkN "eau" feminine) ;
Coffee = mkCN (mkN "café") ;
Tea = mkCN (mkN "thé") ;
Coffee = mkCN (mkN "café") ;
Tea = mkCN (mkN "thé") ;
Cheese = mkCN (mkN "fromage" masculine) ;
Fish = mkCN (mkN "poisson" masculine) ;
Pizza = mkCN (mkN "pizza" feminine) ;
Fresh = mkA "frais" "fraîche" "frais" "fraîchement" ;
Fresh = mkA "frais" "fraîche" "frais" "fraîchement" ;
Warm = mkA "chaud" ;
Expensive = mkA "cher" ;
Delicious = mkA "délicieux" ;
Delicious = mkA "délicieux" ;
Boring = mkA "ennuyeux" ;
Good = prefixA (mkA "bon" "bonne" "bons" "bien") ;
Restaurant = mkPlace (mkN "restaurant") in_Prep ;
Bar = mkPlace (mkN "bar") in_Prep ;
Toilet = mkPlace (mkN "toilette") in_Prep ;
Museum = mkPlace (mkN "musée" masculine) in_Prep ;
Airport = mkPlace (mkN "aéroport") dative ;
Museum = mkPlace (mkN "musée" masculine) in_Prep ;
Airport = mkPlace (mkN "aéroport") dative ;
Station = mkPlace (mkN "gare") dative ;
Hospital = mkPlace (mkN "hôpital") dative ;
Church = mkPlace (mkN "église") in_Prep ;
Hospital = mkPlace (mkN "hôpital") dative ;
Church = mkPlace (mkN "église") in_Prep ;
Euro = mkCN (mkN "euro") ;
Dollar = mkCN (mkN "dollar") ;
@@ -44,10 +42,10 @@ Good = prefixA (mkA "bon" "bonne" "bons" "bien") ;
English = mkNat "anglais" "Angleterre" ;
Finnish = mkNat "finlandais" "Finlande" ;
French = mkNat "français" "France" ;
French = mkNat "français" "France" ;
Italian = mkNat "italien" "Italie" ;
Romanian = mkNat "roumain" "Roumanie" ;
Swedish = mkNat "suédois" "Suède" ;
Swedish = mkNat "suédois" "Suède" ;
Belgian = mkA "belge" ;
Flemish = mkNP (mkPN "flamand") ;
@@ -63,20 +61,17 @@ Good = prefixA (mkA "bon" "bonne" "bons" "bien") ;
AWant p obj = mkCl p.name want_V2 obj ;
ALike p item = mkCl item plaire_V2 p.name ;
AHave p kind = mkCl p.name have_V2 (mkNP kind) ;
ASpeak p lang = mkCl p.name (mkV2 (mkV "parler")) lang ;
ALove p q = mkCl p.name (mkV2 (mkV "aimer")) q.name ;
ACitizen p n = mkCl p.name n ;
AHungry p = mkCl p.name (E.ComplCN have_V2 (mkCN (mkN "faim" feminine))) ;
AThirsty p = mkCl p.name (E.ComplCN have_V2 (mkCN (mkN "soif" feminine))) ;
ATired p = mkCl p.name (mkA "fatigué") ;
ATired p = mkCl p.name (mkA "fatigué") ;
AScared p = mkCl p.name (E.ComplCN have_V2 (mkCN (mkN "peur" feminine))) ;
AIll p = mkCl p.name (mkA "malade") ;
AUnderstand p = mkCl p.name (mkV IrregFre.comprendre_V2) ;
AKnow p = mkCl p.name (mkV IrregFre.savoir_V2) ;
AWantGo p place =
mkCl p.name want_VV (mkVP (mkVP IrregFre.aller_V) place.to) ;
ABePlace p place = mkCl p.name place.at ;
AHasName p name = mkCl p.name (mkV2 (reflV (mkV "appeler"))) name ;
ALive p co =
mkCl p.name (mkVP (mkVP (mkV "habiter"))
@@ -109,7 +104,6 @@ Good = prefixA (mkA "bon" "bonne" "bons" "bien") ;
} ;
open_A = P.mkA "ouvert" ;
closed_A = P.mkA "fermé" ;
closed_A = P.mkA "fermé" ;
}

View File

@@ -62,10 +62,8 @@ Good = prefixA (mkA "buono" "buona" "buoni" "buone" "bene") ;
AWant p obj = mkCl p.name want_V2 obj ;
ALike p item = mkCl item (mkV2 (mkV (piacere_64 "piacere")) dative) p.name ;
AHave p kind = mkCl p.name have_V2 (mkNP kind) ;
ASpeak p lang = mkCl p.name (mkV2 (mkV "parlare")) lang ;
ALove p q = mkCl p.name (mkV2 (mkV "amare")) q.name ;
ACitizen p n = mkCl p.name n ;
AHungry p = mkCl p.name (E.ComplCN have_V2 (mkCN (mkN "fame" feminine))) ;
AThirsty p = mkCl p.name (E.ComplCN have_V2 (mkCN (mkN "sete" feminine))) ;
ATired p = mkCl p.name (mkA "stanco") ;
@@ -75,7 +73,6 @@ Good = prefixA (mkA "buono" "buona" "buoni" "buone" "bene") ;
AKnow p = mkCl p.name (mkV (sapere_78 "sapere")) ;
AWantGo p place =
mkCl p.name want_VV (mkVP (mkVP L.go_V) place.to) ;
ABePlace p place = mkCl p.name place.at ;
AHasName p name = mkCl p.name (mkV2 (reflV (mkV "chiamare"))) name ;
ALive p co =
mkCl p.name (mkVP (mkVP (mkV "abitare"))

View File

@@ -44,7 +44,6 @@ Good = mkA "bun" "bună" "buni" "bune" "bine" ;
AWant p obj = mkCl p.name want_V2 obj ;
ALike p item = mkCl p.name like_V2 item ;
AHave p kind = mkCl p.name have_V2 (SyntaxRon.mkNP kind) ;
ASpeak p lang = mkCl p.name (dirV2 (mkV "vorbi")) lang ;
ALove p q = mkCl p.name (dirV2 (mkV "iubi")) q.name ;
AUnderstand p = mkCl p.name (v_besch83 "înţelege") ;

View File

@@ -53,10 +53,8 @@ concrete WordsSwe of Words = SentencesSwe **
AWant p obj = mkCl p.name want_VV (mkVP have_V2 obj) ;
ALike p item = mkCl p.name (mkV2 (mkV "tycker") (mkPrep "om")) item ;
AHave p kind = mkCl p.name have_V2 (mkNP kind) ;
ASpeak p lang = mkCl p.name (mkV2 (mkV "tala")) lang ;
ALove p q = mkCl p.name (mkV2 (mkV "älska")) q.name ;
ACitizen p n = mkCl p.name n ;
AHungry p = mkCl p.name (mkA "hungrig") ;
AThirsty p = mkCl p.name (mkA "törstig") ;
ATired p = mkCl p.name (mkA "trött") ;
@@ -66,7 +64,6 @@ concrete WordsSwe of Words = SentencesSwe **
AKnow p = mkCl p.name (mkV "veta" "vet" "vet" "visste" "vetat" "visst") ;
---- IrregSwe.veta_V gives "missing"
AWantGo p place = mkCl p.name want_VV (mkVP (mkVP IrregSwe.gå_V) place.to) ;
ABePlace p place = mkCl p.name place.at ;
AHasName p name = mkCl (nameOf p) name ;
ALive p co =
mkCl p.name (mkVP (mkVP (mkV "bo")) (SyntaxSwe.mkAdv in_Prep co)) ;

View File

@@ -1,8 +1,8 @@
DisambPhrasebookEng :
DisambPhrasebookRon : ABePlace ACitizen AHasName AHungry AIll AKnow ALive AScared AThirsty ATired AWantGo Airport Belgian Belgium Church Coffee English Finnish Flemish French Friday GExcusePol GPleaseGivePol GSorryPol Hospital Italian Monday Museum PropClosed PropClosedDate PropClosedDay PropOpen PropOpenDate PropOpenDay QWhatName Romanian Saturday Station Sunday Swedish Tea Thursday Tuesday Wednesday
DisambPhrasebookRon : AHasName AHungry AIll AKnow ALive AScared AThirsty ATired AWantGo Airport Belgian Belgium Church Coffee English Finnish Flemish French Friday GExcusePol GPleaseGivePol GSorryPol Hospital Italian Monday Museum PropClosed PropClosedDate PropClosedDay PropOpen PropOpenDate PropOpenDay QWhatName Romanian Saturday Station Sunday Swedish Tea Thursday Tuesday Wednesday
PhrasebookEng :
PhrasebookFin :
PhrasebookFre :
PhrasebookIta : GNiceToMeetYou GSeeYouSoon
PhrasebookRon : ABePlace ACitizen AHasName AHungry AIll AKnow ALive AScared AThirsty ATired AWantGo Airport Belgian Belgium Church Coffee English Finnish Flemish French Friday GExcusePol GPleaseGivePol GSorryPol Hospital Italian Monday Museum PropClosed PropClosedDate PropClosedDay PropOpen PropOpenDate PropOpenDay QWhatName Romanian Saturday Station Sunday Swedish Tea Thursday Tuesday Wednesday
PhrasebookRon : AHasName AHungry AIll AKnow ALive AScared AThirsty ATired AWantGo Airport Belgian Belgium Church Coffee English Finnish Flemish French Friday GExcusePol GPleaseGivePol GSorryPol Hospital Italian Monday Museum PropClosed PropClosedDate PropClosedDay PropOpen PropOpenDate PropOpenDay QWhatName Romanian Saturday Station Sunday Swedish Tea Thursday Tuesday Wednesday
PhrasebookSwe :

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -92,6 +92,13 @@ Quasi-incremental translation: many basic types are also used as phrases.
<P>
Disambiguation, esp. of politeness distinctions.
</P>
<H1>Ontology</H1>
<P>
The abstract syntax defines the <B>ontology</B> behind the phrasebook. The ontology
consists of the following <B>categories</B>. Some explanations can be found in the
abstract syntax file
<A HREF="http://code.haskell.org/gf/examples/phrasebook/Sentences.gf"><CODE>Sentences.gf</CODE></A>.
</P>
<H1>Files</H1>
<P>
<CODE>Sentences</CODE>: general syntactic structures implementable in a uniform way.
@@ -117,7 +124,7 @@ Separate concrete syntaxes.
the input language is ambiguous.
</P>
<P>
Here is the module structure produced by
Here is the module structure as produced by
</P>
<PRE>
&gt; i -retain DisambPhrasebookEng.gf

View File

@@ -56,8 +56,6 @@ The source code resides in
[``code.haskell.org/gf/examples/phrasebook/`` http://code.haskell.org/gf/examples/phrasebook/]
%The abstract syntax defines an [ontology of phrases ontology.html].
Current status (6 April 2010):
- available in English, Finnish, French, Italian, Romanian, Swedish
- small coverage
@@ -78,6 +76,15 @@ Quasi-incremental translation: many basic types are also used as phrases.
Disambiguation, esp. of politeness distinctions.
=Ontology=
The abstract syntax defines the **ontology** behind the phrasebook. The ontology
consists of the following **categories**. Some explanations can be found in the
abstract syntax file
[``Sentences.gf`` http://code.haskell.org/gf/examples/phrasebook/Sentences.gf].
=Files=
``Sentences``: general syntactic structures implementable in a uniform way.
@@ -97,7 +104,7 @@ Separate concrete syntaxes.
``DisambPhrasebook``: disambiguation grammars generating feedback phrases if
the input language is ambiguous.
Here is the module structure produced by
Here is the module structure as produced by
```
> i -retain DisambPhrasebookEng.gf
> dg -only=Phrasebook*,Sentences*,Words*,Greetings*,DiffP*,DisambPhrasebookEng
@@ -175,3 +182,6 @@ Here are the steps to follow for contributors: