disambiguation in Phrasebook grammars, PGF server, and the GUI

This commit is contained in:
aarne
2010-03-30 15:39:11 +00:00
parent 4bae49c634
commit de909a4e44
23 changed files with 151 additions and 129 deletions

View File

@@ -0,0 +1,10 @@
--# -path=.:present
concrete DisambPhrasebookEng of Phrasebook = PhrasebookEng - [Polite,Familiar] **
open
(R = Roles) in {
lin
Polite = {s = "(polite)" ; p = R.PPolite} ;
Familiar = {s = "(familiar)" ; p = R.PFamiliar} ;
}

View File

@@ -1,7 +1,7 @@
concrete GreetingsSwe of Greetings = open Prelude in { concrete GreetingsSwe of Greetings = open Roles, Prelude in {
lincat lincat
Greeting, Politeness = SS ; Greeting = SS ;
lin lin
GHello = ss "hej" ; GHello = ss "hej" ;
@@ -12,7 +12,6 @@ lin
GSorry = ss "förlåt" ; GSorry = ss "förlåt" ;
GGoodbye = ss "hej då" ; GGoodbye = ss "hej då" ;
GBye = ss "hej då" ; GBye = ss "hej då" ;
GWhatsYourName = ss "vad heter du" ;
GNiceToMeetYou = ss "trevligt att träffas" ; GNiceToMeetYou = ss "trevligt att träffas" ;
GSeeYouSoon = ss "vi ses snart" ; GSeeYouSoon = ss "vi ses snart" ;
GHelp = ss "hjälp" ; GHelp = ss "hjälp" ;
@@ -21,11 +20,14 @@ lin
GGoodDay = ss "god dag" ; GGoodDay = ss "god dag" ;
GGoodEvening = ss "god afton" ; GGoodEvening = ss "god afton" ;
GGoodNight = ss "god natt" ; GGoodNight = ss "god natt" ;
GWhatsYourName = ss "vad heter du" ;
GImHungry = ss "jag är hungrig" ; GImHungry = ss "jag är hungrig" ;
GImThirsty = ss "jag är törstig" ; GImThirsty = ss "jag är törstig" ;
GImTired = ss "jag är trött" ; GImTired = ss "jag är trött" ;
GImScared = ss "jag är rädd" ; GImScared = ss "jag är rädd" ;
GIdontUnderstand = ss "jag förstår inte" ; GIdontUnderstand = ss "jag förstår inte" ;
GTheCheck = ss "notan" ; GTheCheck = ss "notan" ;
GYes = ss "ja" ; GYes = ss "ja" ;

View File

@@ -1,7 +1,7 @@
all: pgf missing all: pgf missing
pgf: pgf:
gf -make PhrasebookEng.gf PhrasebookFin.gf PhrasebookFre.gf PhrasebookIta.gf PhrasebookRon.gf PhrasebookSwe.gf gf -make PhrasebookEng.gf PhrasebookFin.gf PhrasebookFre.gf PhrasebookIta.gf PhrasebookRon.gf PhrasebookSwe.gf DisambPhrasebookEng.gf
missing: missing:
echo "pg -missing | wf -file=missing.txt" | gf Phrasebook.pgf echo "pg -missing | wf -file=missing.txt" | gf Phrasebook.pgf

View File

@@ -5,18 +5,11 @@ abstract Phrasebook =
flags startcat = Phrase ; flags startcat = Phrase ;
cat
Politeness ; Gender ; -- abstract parameters
fun fun
-- here rather than Sentences, because not functorial -- here rather than Sentences, because not functorial
PSentence : Sentence -> Phrase ; PGreeting : Politeness -> Greeting -> Phrase ;
PQuestion : Question -> Phrase ;
PGreeting : Greeting -> Phrase ;
---- PGreeting : Politeness -> Gender -> Gender -> Greeting -> Phrase ; ---- PGreeting : Politeness -> Gender -> Gender -> Greeting -> Phrase ;
-- politeness level, speaker, hearer -- politeness level, speaker, hearer
Polite, Familiar : Politeness ;
Male, Female : Gender ;
} }

View File

@@ -8,14 +8,6 @@ concrete PhrasebookEng of Phrasebook =
Prelude in { Prelude in {
lin lin
PSentence s = mkText s | lin Text (mkUtt s) ; -- optional . PGreeting p g = mkText (lin Text g) (lin Text (ss p.s)) ;
PQuestion s = mkText s | lin Text (mkUtt s) ; -- optional ?
PGreeting g = lin Text (ss g.s) ;
---- PGreeting p s h g = mkPhrase (g.s ++ p.s ++ s.s ++ h.s) ;
Male = {s = [] ; g = R.Male} ;
Female = {s = [] ; g = R.Female} ;
Polite = {s = [] ; p = R.Polite} ;
Familiar = {s = [] ; p = R.Familiar} ;
} }

View File

@@ -7,8 +7,6 @@ concrete PhrasebookFin of Phrasebook =
Prelude in { Prelude in {
lin lin
PSentence s = mkText s | lin Text (mkUtt s) ; -- optional . PGreeting p g = mkText (lin Text (ss g.s)) (lin Text (ss p.s)) ;
PQuestion s = mkText s | lin Text (mkUtt s) ; -- optional ?
PGreeting g = mkPhrase g ;
} }

View File

@@ -6,22 +6,10 @@ concrete PhrasebookFre of Phrasebook =
** open ** open
(R = Roles), (R = Roles),
SyntaxFre, SyntaxFre,
ParadigmsFre,
Prelude in { Prelude in {
lincat
Gender = {s : Str ; g : R.Gender} ;
Politeness = {s : Str ; p : R.Politeness} ;
lin lin
PSentence s = mkText s | lin Text (mkUtt s) ; -- optional . PGreeting p g = mkText (lin Text (ss (g.s ! p.p ! R.Male ! R.Male))) (lin Text (ss p.s)) ;
PQuestion s = mkText s | lin Text (mkUtt s) ; -- optional ?
PGreeting g = lin Text (ss (g.s ! R.Polite ! R.Male ! R.Male)) ;
---- PGreeting p s h g = mkPhrase (g.s ! p.p ! s.g ! h.g ++ p.s ++ s.s ++ h.s) ; ---- PGreeting p s h g = mkPhrase (g.s ! p.p ! s.g ! h.g ++ p.s ++ s.s ++ h.s) ;
Male = {s = [] ; g = R.Male} ;
Female = {s = [] ; g = R.Female} ;
Polite = {s = [] ; p = R.Polite} ;
Familiar = {s = [] ; p = R.Familiar} ;
} }

View File

@@ -9,19 +9,8 @@ concrete PhrasebookIta of Phrasebook =
ParadigmsIta, ParadigmsIta,
Prelude in { Prelude in {
lincat
Gender = {s : Str ; g : R.Gender} ;
Politeness = {s : Str ; p : R.Politeness} ;
lin lin
PSentence s = mkText s | lin Text (mkUtt s) ; -- optional . PGreeting p g = mkText (lin Text (ss (g.s ! p.p ! R.Male ! R.Male))) (lin Text (ss p.s)) ;
PQuestion s = mkText s | lin Text (mkUtt s) ; -- optional ?
PGreeting g = lin Text (ss (g.s ! R.Polite ! R.Male ! R.Male)) ;
---- PGreeting p s h g = mkPhrase (g.s ! p.p ! s.g ! h.g ++ p.s ++ s.s ++ h.s) ;
Male = {s = [] ; g = R.Male} ;
Female = {s = [] ; g = R.Female} ;
Polite = {s = [] ; p = R.Polite} ;
Familiar = {s = [] ; p = R.Familiar} ;
} }

View File

@@ -8,8 +8,6 @@ concrete PhrasebookRon of Phrasebook =
Prelude in { Prelude in {
lin lin
PSentence s = mkText s | lin Text (mkUtt s) ; -- optional . PGreeting p g = mkText (lin Text (ss g.s)) (lin Text (ss p.s)) ;
PQuestion s = mkText s | lin Text (mkUtt s) ; -- optional ?
PGreeting g = lin Text g ;
} }

View File

@@ -7,8 +7,6 @@ concrete PhrasebookSwe of Phrasebook =
Prelude in { Prelude in {
lin lin
PSentence s = mkText s | lin Text (mkUtt s) ; -- optional . PGreeting p g = mkText (lin Text (ss g.s)) (lin Text (ss p.s)) ;
PQuestion s = mkText s | lin Text (mkUtt s) ; -- optional ?
PGreeting g = mkPhrase g ;
} }

View File

@@ -2,15 +2,15 @@ resource Roles = {
param param
Gender = Male | Female ; Gender = Male | Female ;
Politeness = Polite | Familiar ; Politeness = PPolite | PFamiliar ;
oper oper
RolePhrase : Type = {s : Politeness => Gender => Gender => Str} ; RolePhrase : Type = {s : Politeness => Gender => Gender => Str} ;
politeDistinct : (_,_ : Str) -> RolePhrase = \pol,fam -> { politeDistinct : (_,_ : Str) -> RolePhrase = \pol,fam -> {
s = table { s = table {
Polite => \\_,_ => pol ; PPolite => \\_,_ => pol ;
Familiar => \\_,_ => fam PFamiliar => \\_,_ => fam
} }
} ; } ;

View File

@@ -7,8 +7,15 @@ abstract Sentences = Numeral ** {
Place ; PlaceKind ; Currency ; Price ; Language ; Place ; PlaceKind ; Currency ; Price ; Language ;
Person ; Action ; Person ; Action ;
-- abstract parameters
Politeness ;
-- Gender ;
fun fun
-- these phrases are formed here, not in Phrasebook, as they are functorial -- these phrases are formed here, not in Phrasebook, as they are functorial
PSentence : Politeness -> Sentence -> Phrase ;
PQuestion : Politeness -> Question -> Phrase ;
PObject : Object -> Phrase ; PObject : Object -> Phrase ;
PKind : Kind -> Phrase ; PKind : Kind -> Phrase ;
PQuality : Quality -> Phrase ; PQuality : Quality -> Phrase ;
@@ -41,8 +48,11 @@ abstract Sentences = Numeral ** {
Very : Quality -> Quality ; Very : Quality -> Quality ;
Too : Quality -> Quality ; Too : Quality -> Quality ;
I, You : Person ;
ThePlace : PlaceKind -> Place ; ThePlace : PlaceKind -> Place ;
I, You : Person ;
Polite, Familiar : Politeness ;
-- Male, Female : Gender ;
} }

View File

@@ -1,9 +1,12 @@
concrete SentencesFre of Sentences = NumeralFre ** SentencesI - [WhetherIs] concrete SentencesFre of Sentences = NumeralFre ** SentencesI - [WhetherIs, QAction]
with with
(DiffPhrasebook = DiffPhrasebookFre), (DiffPhrasebook = DiffPhrasebookFre),
(Syntax = SyntaxFre) ** open SyntaxFre, ExtraFre in { (Syntax = SyntaxFre) ** open SyntaxFre, ExtraFre in {
lin WhetherIs item quality = lin
lin QS {s = \\_ => (EstcequeS (mkS (mkCl item quality))).s} ; WhetherIs item quality =
{s = \\_ => lin QS {s = \\_ => (EstcequeS (mkS (mkCl item quality))).s}} ;
QAction a =
{s = \\r => lin QS {s = \\_ => (EstcequeS (mkS (a.s ! r))).s}} ;
} }

View File

@@ -1,12 +1,15 @@
incomplete concrete SentencesI of Sentences = Numeral ** incomplete concrete SentencesI of Sentences = Numeral **
open open
DiffPhrasebook, DiffPhrasebook,
Syntax Syntax,
(R = Roles),
Prelude
in { in {
lincat lincat
Phrase = Text ; Phrase = Text ;
Sentence = S ; Politeness = {s : Str ; p : R.Politeness} ;
Question = QS ; Sentence = {s : R.Politeness => S} ;
Question = {s : R.Politeness => QS} ;
Item = NP ; Item = NP ;
Kind = CN ; Kind = CN ;
Quality = AP ; Quality = AP ;
@@ -15,10 +18,16 @@ incomplete concrete SentencesI of Sentences = Numeral **
PlaceKind = CN ; PlaceKind = CN ;
Currency = CN ; Currency = CN ;
Price = NP ; Price = NP ;
Action = Cl ; Action = {s : R.Politeness => Cl} ;
Person = NP ; Person = {s : R.Politeness => NP} ;
Language = NP ; Language = NP ;
lin lin
--- todo: add speaker and hearer genders
PSentence p g = let s = g.s ! p.p in
mkText (mkText s | lin Text (mkUtt s)) (lin Text (ss p.s)) ; -- optional '.'
PQuestion p g = let s = g.s ! p.p in
mkText (mkText s | lin Text (mkUtt s)) (lin Text (ss p.s)) ; -- optional '?'
PObject x = mkPhrase (mkUtt x) ; PObject x = mkPhrase (mkUtt x) ;
PKind x = mkPhrase (mkUtt x) ; PKind x = mkPhrase (mkUtt x) ;
PQuality x = mkPhrase (mkUtt x) ; PQuality x = mkPhrase (mkUtt x) ;
@@ -29,17 +38,18 @@ incomplete concrete SentencesI of Sentences = Numeral **
PPrice x = mkPhrase (mkUtt x) ; PPrice x = mkPhrase (mkUtt x) ;
PLanguage x = mkPhrase (mkUtt x) ; PLanguage x = mkPhrase (mkUtt x) ;
Is item quality = mkS (mkCl item quality) ; Is item quality = neutralS (mkS (mkCl item quality)) ;
IsNot item quality = mkS negativePol (mkCl item quality) ; IsNot item quality = neutralS (mkS negativePol (mkCl item quality)) ;
WhetherIs item quality = mkQS (mkQCl (mkCl item quality)) ; WhetherIs item quality = neutralQS (mkQS (mkQCl (mkCl item quality))) ;
WhereIs place = mkQS (mkQCl where_IAdv place) ; WhereIs place = neutralQS (mkQS (mkQCl where_IAdv place)) ;
SAction = mkS ; SAction a = {s = \\p => mkS (a.s ! p)} ;
SNotAction = mkS negativePol ; SNotAction a = {s = \\p => mkS negativePol (a.s ! p)} ;
QAction a = mkQS (mkQCl a) ; QAction a = {s = \\p => mkQS (mkQCl (a.s ! p))} ;
HowMuchCost item = mkQS (mkQCl how8much_IAdv (mkCl item cost_V)) ; HowMuchCost item = neutralQS (mkQS (mkQCl how8much_IAdv (mkCl item cost_V))) ;
ItCost item price = mkS (mkCl item cost_V2 price) ; ItCost item price = neutralS (mkS (mkCl item cost_V2 price)) ;
AmountCurrency num curr = mkNP <lin Numeral num : Numeral> curr ; AmountCurrency num curr = mkNP <lin Numeral num : Numeral> curr ;
ObjItem i = i ; ObjItem i = i ;
@@ -57,10 +67,23 @@ incomplete concrete SentencesI of Sentences = Numeral **
Too quality = mkAP too_AdA quality ; Too quality = mkAP too_AdA quality ;
ThePlace kind = mkNP the_Quant kind ; ThePlace kind = mkNP the_Quant kind ;
I = mkNP i_Pron ; I = {s = \\_ => mkNP i_Pron} ;
You = mkNP youPol_Pron ; You = {s = table {R.PPolite => mkNP youPol_Pron ; R.PFamiliar => mkNP youSg_Pron}} ;
Polite = {s = [] ; p = R.PPolite} ;
Familiar = {s = [] ; p = R.PFamiliar} ;
-- Male = {s = [] ; g = R.Male} ;
-- Female = {s = [] ; g = R.Female} ;
oper oper
mkPhrase : Utt -> Text = \u -> lin Text u ; -- no punctuation mkPhrase : Utt -> Text = \u -> lin Text u ; -- no punctuation
politeS : S -> S -> {s : R.Politeness => S} = \pol,fam ->
{s = table {R.PPolite => pol ; R.PFamiliar => fam}} ;
neutralS : S -> {s : R.Politeness => S} = \pol -> politeS pol pol ;
politeQS : QS -> QS -> {s : R.Politeness => QS} = \pol,fam ->
{s = table {R.PPolite => pol ; R.PFamiliar => fam}} ;
neutralQS : QS -> {s : R.Politeness => QS} = \pol -> politeQS pol pol ;
---- it would be greate to use overloading here
} }

View File

@@ -1,7 +1,7 @@
-- (c) 2009 Aarne Ranta under LGPL -- (c) 2009 Aarne Ranta under LGPL
concrete WordsEng of Words = SentencesEng ** concrete WordsEng of Words = SentencesEng **
open SyntaxEng, ParadigmsEng, IrregEng in { open SyntaxEng, ParadigmsEng, IrregEng, (R = Roles) in {
lin lin
Wine = mkCN (mkN "wine") ; Wine = mkCN (mkN "wine") ;
Beer = mkCN (mkN "beer") ; Beer = mkCN (mkN "beer") ;
@@ -33,11 +33,13 @@ concrete WordsEng of Words = SentencesEng **
Romanian = mkNP (mkPN "Romanian") ; Romanian = mkNP (mkPN "Romanian") ;
Swedish = mkNP (mkPN "Swedish") ; Swedish = mkNP (mkPN "Swedish") ;
AWant p obj = mkCl p (mkV2 (mkV "want")) obj ; AWant p obj = neutralA (mkCl (np p) (mkV2 (mkV "want")) obj) ;
ALike p item = mkCl p (mkV2 (mkV "like")) item ; ALike p item = neutralA (mkCl (np p) (mkV2 (mkV "like")) item) ;
AHave p kind = mkCl p have_V2 (mkNP kind) ; AHave p kind = neutralA (mkCl (np p) have_V2 (mkNP kind)) ;
ASpeak p lang = mkCl p (mkV2 IrregEng.speak_V) lang ; ASpeak p lang = neutralA (mkCl (np p) (mkV2 IrregEng.speak_V) lang) ;
ALove p q = mkCl p (mkV2 (mkV "love")) q ; ALove p q = neutralA (mkCl (np p) (mkV2 (mkV "love")) (np q)) ;
oper
neutralA : Cl -> {s : R.Politeness => Cl} = \pol -> {s = \\_ => pol} ;
np : {s : R.Politeness => NP} -> NP = \p -> p.s ! R.PPolite ;
} }

View File

@@ -31,15 +31,16 @@ concrete WordsFin of Words = SentencesFin **
Dollar = mkCN (mkN "dollari") ; Dollar = mkCN (mkN "dollari") ;
Lei = mkCN (mkN "lei") ; Lei = mkCN (mkN "lei") ;
AWant p obj = mkCl p want_V2 obj ;
ALike p item = mkCl p like_V2 item ;
AHave p kind = mkCl p have_V2 (mkNP kind) ;
ASpeak p lang = mkCl p (mkV2 (mkV "puhua") partitive) lang ;
ALove p q = mkCl p (mkV2 (mkV "rakastaa") partitive) q ;
English = mkNP (mkPN "englanti") ; English = mkNP (mkPN "englanti") ;
Finnish = mkNP (mkPN (mkN "suomi" "suomia")) ; Finnish = mkNP (mkPN (mkN "suomi" "suomia")) ;
French = mkNP (mkPN "ranska") ; French = mkNP (mkPN "ranska") ;
Romanian = mkNP (mkPN "romania") ; Romanian = mkNP (mkPN "romania") ;
Swedish = mkNP (mkPN "ruotsi") ; Swedish = mkNP (mkPN "ruotsi") ;
AWant p obj = {s = \\r => mkCl (p.s ! r) want_V2 obj} ;
ALike p item = {s = \\r => mkCl (p.s ! r) like_V2 item} ;
AHave p kind = {s = \\r => mkCl (p.s ! r) have_V2 (mkNP kind)} ;
ASpeak p lang = {s = \\r => mkCl (p.s ! r) (mkV2 (mkV "puhua") partitive) lang} ;
ALove p q = {s = \\r => mkCl (p.s ! r) (mkV2 (mkV "rakastaa") partitive) (q.s ! r)} ;
} }

View File

@@ -35,19 +35,21 @@ Boring = mkAPA "ennuyeux" ;
Dollar = mkCN (mkN "dollar") ; Dollar = mkCN (mkN "dollar") ;
Lei = mkCN (mkN "lei") ; ---- ? Lei = mkCN (mkN "lei") ; ---- ?
AWant p obj = mkCl p want_V2 obj ;
ALike p item = mkCl item plaire_V2 p ;
AHave p kind = mkCl p have_V2 (mkNP kind) ;
ASpeak p lang = mkCl p (mkV2 (mkV "parler")) lang ;
ALove p q = mkCl p (mkV2 (mkV "aimer")) q ;
English = mkNP (mkPN "anglais") ; English = mkNP (mkPN "anglais") ;
Finnish = mkNP (mkPN "finnois") ; Finnish = mkNP (mkPN "finnois") ;
French = mkNP (mkPN "français") ; French = mkNP (mkPN "français") ;
Romanian = mkNP (mkPN "roumain") ; Romanian = mkNP (mkPN "roumain") ;
Swedish = mkNP (mkPN "suédois") ; Swedish = mkNP (mkPN "suédois") ;
oper AWant p obj = {s = \\r => mkCl (p.s ! r) want_V2 obj} ;
mkAPA : (_ : Str) -> AP = \x -> mkAP (mkA x) ; ALike p item = {s = \\r => mkCl item plaire_V2 (p.s ! r)} ;
AHave p kind = {s = \\r => mkCl (p.s ! r) have_V2 (mkNP kind)} ;
ASpeak p lang = {s = \\r => mkCl (p.s ! r) (mkV2 (mkV "parler")) lang} ;
ALove p q = {s = \\r => mkCl (p.s ! r) (mkV2 (mkV "aimer")) (q.s ! r)} ;
oper
mkAPA : (_ : Str) -> AP = \x -> mkAP (mkA x) ;
} }

View File

@@ -33,18 +33,18 @@ Boring = mkAPA "noioso" ;
Dollar = mkCN (mkN "dollar") ; Dollar = mkCN (mkN "dollar") ;
Lei = mkCN (mkN "lei") ; ---- ? Lei = mkCN (mkN "lei") ; ---- ?
AWant p obj = mkCl p want_V2 obj ;
ALike p item = mkCl item (mkV2 (mkV (piacere_64 "piacere")) dative) p ;
AHave p kind = mkCl p have_V2 (mkNP kind) ;
ASpeak p lang = mkCl p (mkV2 (mkV "parlare")) lang ;
ALove p q = mkCl p (mkV2 (mkV "amare")) q ;
English = mkNP (mkPN "inglese") ; English = mkNP (mkPN "inglese") ;
Finnish = mkNP (mkPN "finnico") ; Finnish = mkNP (mkPN "finnico") ;
Itanch = mkNP (mkPN "francese") ; Itanch = mkNP (mkPN "francese") ;
Romanian = mkNP (mkPN "romano") ; Romanian = mkNP (mkPN "romano") ;
Swedish = mkNP (mkPN "svedese") ; Swedish = mkNP (mkPN "svedese") ;
AWant p obj = {s = \\r => mkCl (p.s ! r) want_V2 obj} ;
ALike p item = {s = \\r => mkCl item (mkV2 (mkV (piacere_64 "piacere")) dative) (p.s ! r)} ;
AHave p kind = {s = \\r => mkCl (p.s ! r) have_V2 (mkNP kind)} ;
ASpeak p lang = {s = \\r => mkCl (p.s ! r) (mkV2 (mkV "parlare")) lang} ;
ALove p q = {s = \\r => mkCl (p.s ! r) (mkV2 (mkV "amare")) (q.s ! r)} ;
oper oper
mkAPA : (_ : Str) -> AP = \x -> mkAP (mkA x) ; mkAPA : (_ : Str) -> AP = \x -> mkAP (mkA x) ;

View File

@@ -3,7 +3,8 @@
concrete WordsRon of Words = SentencesRon ** open concrete WordsRon of Words = SentencesRon ** open
SyntaxRon, SyntaxRon,
ParadigmsRon, ParadigmsRon,
DiffPhrasebookRon in DiffPhrasebookRon,
(R = Roles) in
{ {
flags coding=utf8 ; flags coding=utf8 ;
@@ -34,18 +35,18 @@ Boring = mkAPA "plictisitor" "plictisitoare" "plictisitori" "plictisitoare" ;
Dollar = mkCN (mkN "dolar" masculine) ; Dollar = mkCN (mkN "dolar" masculine) ;
Lei = mkCN (mkN "leu" "lei") ; Lei = mkCN (mkN "leu" "lei") ;
AWant p obj = mkCl p want_V2 obj ;
ALike p item = mkCl p like_V2 item ;
AHave p kind = mkCl p have_V2 (SyntaxRon.mkNP kind) ;
ASpeak p lang = mkCl p (dirV2 (mkV "vorbi")) lang ;
ALove p q = mkCl p (dirV2 (mkV "iubi")) q ;
English = SyntaxRon.mkNP (mkPN "engleză") ; ---- ? English = SyntaxRon.mkNP (mkPN "engleză") ; ---- ?
-- Finnish = mkNP (mkPN "finnois") ; -- Finnish = mkNP (mkPN "finnois") ;
-- French = mkNP (mkPN "français") ; -- French = mkNP (mkPN "français") ;
Romanian = SyntaxRon.mkNP (mkPN "română") ; ---- ? Romanian = SyntaxRon.mkNP (mkPN "română") ; ---- ?
-- Swedish = mkNP (mkPN "suédois") ; -- Swedish = mkNP (mkPN "suédois") ;
AWant p obj = {s = \\r => mkCl (p.s ! r) want_V2 obj} ;
ALike p item = {s = \\r => mkCl (p.s ! r) like_V2 item} ;
AHave p kind = {s = \\r => mkCl (p.s ! r) have_V2 (SyntaxRon.mkNP kind)} ;
ASpeak p lang = {s = \\r => mkCl (p.s ! r) (dirV2 (mkV "vorbi")) lang} ;
ALove p q = {s = \\r => mkCl (p.s ! R.PPolite) (dirV2 (mkV "iubi")) (q.s ! r)} ; ---- linking slow
oper oper
mkAPA : (_,_,_,_ : Str) -> AP = \x,y,z,u -> mkAP (mkA x y z u) ; mkAPA : (_,_,_,_ : Str) -> AP = \x,y,z,u -> mkAP (mkA x y z u) ;

View File

@@ -33,11 +33,11 @@ concrete WordsSwe of Words = SentencesSwe **
Romanian = mkNP (mkPN "rumänska") ; Romanian = mkNP (mkPN "rumänska") ;
Swedish = mkNP (mkPN "svenska") ; Swedish = mkNP (mkPN "svenska") ;
AWant p obj = mkCl p want_VV (mkVP have_V2 obj) ; AWant p obj = {s = \\r => mkCl (p.s ! r) want_VV (mkVP have_V2 obj)} ;
ALike p item = mkCl p (mkV2 (mkV "tycker") (mkPrep "om")) item ; ALike p item = {s = \\r => mkCl (p.s ! r) (mkV2 (mkV "tycker") (mkPrep "om")) item} ;
AHave p kind = mkCl p have_V2 (mkNP kind) ; AHave p kind = {s = \\r => mkCl (p.s ! r) have_V2 (mkNP kind)} ;
ASpeak p lang = mkCl p (mkV2 (mkV "tala")) lang ; ASpeak p lang = {s = \\r => mkCl (p.s ! r) (mkV2 (mkV "tala")) lang} ;
ALove p q = mkCl p (mkV2 (mkV "älska")) q ; ALove p q = {s = \\r => mkCl (p.s ! r) (mkV2 (mkV "älska")) (q.s ! r)} ;
} }

View File

@@ -1,6 +1,7 @@
DisambPhrasebookEng :
PhrasebookEng : PhrasebookEng :
PhrasebookFin : Familiar Female Male Polite PhrasebookFin :
PhrasebookFre : PhrasebookFre :
PhrasebookIta : French Fresh GNiceToMeetYou GSeeYouSoon Tea PhrasebookIta : French Fresh GNiceToMeetYou GSeeYouSoon Tea
PhrasebookRon : Coffee Familiar Female Finnish French Male Polite Swedish Tea PhrasebookRon : Coffee Finnish French Swedish Tea
PhrasebookSwe : Familiar Female Male Polite PhrasebookSwe :

View File

@@ -53,7 +53,7 @@ function show_languages(grammar) {
menu.setAttribute("onchange","new_language(this)"); menu.setAttribute("onchange","new_language(this)");
menu.grammar=grammar; menu.grammar=grammar;
menu.innerHTML=""; menu.innerHTML="";
for(var i=0; i<lang.length; i++) { for(var i=1; i<lang.length; i++) { // 1, to hide Disamb...
if(lang[i].canParse) { if(lang[i].canParse) {
var opt=empty("option"); var opt=empty("option");
opt.setAttribute("value",""+i); opt.setAttribute("value",""+i);
@@ -188,8 +188,10 @@ function show_translations(translations) {
var lin=t.linearizations; var lin=t.linearizations;
var tbody=empty("tbody"); var tbody=empty("tbody");
tbody.appendChild(tr([th(text(t.to+":"))])); tbody.appendChild(tr([th(text(t.to+":"))]));
for(var i=0;i<lin.length;i++) for(var i=0;i<lin.length;i++) {
tbody.appendChild(tr([(text(lin[i].text))])); tbody.appendChild(tr([(text(lin[i].text))]));
if (lin.length > 1) tbody.appendChild(tr([(text(lin[i].tree))]));
}
trans.appendChild(wrap("table",tbody)); trans.appendChild(wrap("table",tbody));
} }
} }

View File

@@ -129,18 +129,20 @@ doTranslateGroup pgf input mcat mfrom mto =
[toJSObject [("from", showJSON (langOnly (PGF.showLanguage from))), [toJSObject [("from", showJSON (langOnly (PGF.showLanguage from))),
("to", showJSON (langOnly (PGF.showLanguage to))), ("to", showJSON (langOnly (PGF.showLanguage to))),
("linearizations",showJSON ("linearizations",showJSON
[toJSObject [("text", doText (doBind alt))] | alt <- output]) [toJSObject (("text", doText (doBind alt)) : disamb lg from t) |
(t,alt) <- output, let lg = length output])
] ]
| |
(from,trees) <- parse' pgf input mcat mfrom, (from,trees) <- parse' pgf input mcat mfrom,
(to,output) <- groupResults (map (linearize' pgf mto) trees) (to,output) <- groupResults [(t, linearize' pgf mto t) | t <- trees]
] ]
where where
groupResults = Map.toList . foldr more Map.empty . start . concat groupResults = Map.toList . foldr more Map.empty . start . collect
where where
start ls = [(l,[s]) | (l,s) <- ls] collect tls = [(t,(l,s)) | (t,ls) <- tls, (l,s) <- ls, notDisamb l]
start ls = [(l,[(t,s)]) | (t,(l,s)) <- ls]
more (l,s) = more (l,s) =
Map.insertWith (\ [x] xs -> if elem x xs then xs else (x : xs)) l s Map.insertWith (\ [(t,x)] xs -> if elem x (map snd xs) then xs else ((t,x) : xs)) l s
doBind = unwords . bind . words doBind = unwords . bind . words
doText s = case s of doText s = case s of
c:cs | elem (last s) ".?!" -> toUpper c : init (init cs) ++ [last s] c:cs | elem (last s) ".?!" -> toUpper c : init (init cs) ++ [last s]
@@ -152,6 +154,13 @@ doTranslateGroup pgf input mcat mfrom mto =
_ -> ws _ -> ws
langOnly = reverse . take 3 . reverse langOnly = reverse . take 3 . reverse
disamb lg from t =
if lg < 2
then []
else [("tree", "-- " ++ doText (doBind PGF.linearize pgf (disambLang from)) t)]
disambLang f = maybe f id $ PGF.readLanguage $ "Disamb" ++ PGF.showLanguage f
notDisamb = (/="Disamb") . take 6 . PGF.showLanguage
doParse :: PGF -> String -> Maybe PGF.Type -> Maybe PGF.Language -> JSValue doParse :: PGF -> String -> Maybe PGF.Type -> Maybe PGF.Language -> JSValue
doParse pgf input mcat mfrom = showJSON $ map toJSObject doParse pgf input mcat mfrom = showJSON $ map toJSObject