added api/Combinators for Eng

This commit is contained in:
aarne
2008-06-27 16:48:28 +00:00
parent 9aaf53dba1
commit 070d198e7e
15 changed files with 571 additions and 329 deletions

View File

@@ -0,0 +1,190 @@
--1 Combinators: a High-Level Syntax API
-- This module defines some "grammatical functions" that give shortcuts to
-- typical constructions. [``Constructors`` Constructors.html] and the
-- language-specific ``Paradigms`` modules are usually needed
-- to construct arguments of these functions.
incomplete resource Combinators = open Grammar in {
oper
--2 Predication
pred : overload {
pred : V -> NP -> Cl ; -- x converges
pred : V2 -> NP -> NP -> Cl ; -- x intersects y
pred : V3 -> NP -> NP -> NP -> Cl ; -- x intersects y at z
pred : V -> NP -> NP -> Cl ; -- x and y intersect
pred : A -> NP -> Cl ; -- x is even
pred : A2 -> NP -> NP -> Cl ; -- x is divisible by y
pred : A -> NP -> NP -> Cl ; -- x and y are equal
pred : N -> NP -> Cl ; -- x is a maximum
pred : CN -> NP -> Cl ; -- x is a local maximum
pred : NP -> NP -> Cl ; -- x is the neutral element
pred : N -> NP -> NP -> Cl ; -- x and y are inverses
pred : Adv -> NP -> Cl ; -- x is in scope
pred : Prep -> NP -> NP -> Cl -- x is outside y
} ;
--2 Function application
app : overload {
app : N -> NP ;
app : N2 -> NP -> NP ;
app : N3 -> NP -> NP -> NP ;
app : N2 -> NP -> NP -> NP ;
app : N2 -> N -> CN
} ;
--2 Coordination
coord : overload {
coord : Conj -> Adv -> Adv -> Adv ;
coord : Conj -> AP -> AP -> AP ;
coord : Conj -> NP -> NP -> NP ;
coord : Conj -> S -> S -> S ;
coord : Conj -> ListAdv -> Adv ;
coord : Conj -> ListAP -> AP ;
coord : Conj -> ListNP -> NP ;
coord : Conj -> ListS -> S ;
} ;
--2 Modification
mod : overload {
mod : A -> N -> CN ;
mod : AP -> CN -> CN ;
mod : AdA -> A -> AP ;
mod : Det -> N -> NP ;
mod : Det -> CN -> NP ;
mod : Quant -> N -> NP ;
mod : Quant -> CN -> NP ;
mod : Predet -> N -> NP ;
mod : Numeral -> N -> NP
} ;
--2 Negation
neg : overload {
neg : Imp -> Utt ;
neg : Cl -> S ;
neg : QCl -> QS ;
neg : RCl -> RS
};
--2 Text append
-- This is not in ground API, because it would destroy parsing.
appendText : Text -> Text -> Text ;
--.
pred = overload {
pred : V -> NP -> Cl
= \v,np -> PredVP np (UseV v) ;
pred : V2 -> NP -> NP -> Cl
= \v,np,ob -> PredVP np (ComplSlash (SlashV2a v) ob) ;
pred : V3 -> NP -> NP -> NP -> Cl
= \v,np,ob,ob2 ->
PredVP np (ComplSlash (Slash2V3 v ob) ob2) ;
pred : V -> NP -> NP -> Cl
= \v,x,y -> PredVP (ConjNP and_Conj (BaseNP x y)) (UseV v) ;
pred : A -> NP -> Cl
= \a,np -> PredVP np (UseComp (CompAP (PositA a))) ;
pred : A2 -> NP -> NP -> Cl
= \a,x,y -> PredVP x (UseComp (CompAP (ComplA2 a y))) ;
pred : A -> NP -> NP -> Cl
= \a,x,y -> PredVP (ConjNP and_Conj (BaseNP x y)) (UseComp (CompAP (PositA a))) ;
pred : N -> NP -> Cl
= \n,x -> PredVP x (UseComp (CompNP (DetArtSg (IndefArt) (UseN n)))) ;
pred : CN -> NP -> Cl
= \n,x -> PredVP x (UseComp (CompNP (DetArtSg (IndefArt) n))) ;
pred : NP -> NP -> Cl
= \n,x -> PredVP x (UseComp (CompNP n)) ; pred : N2 -> NP -> NP -> Cl
= \n,x,y -> PredVP x (UseComp (CompNP (DetArtSg (IndefArt) (ComplN2 n y)))) ;
pred : N -> NP -> NP -> Cl
= \n,x,y -> PredVP (ConjNP and_Conj (BaseNP x y)) (UseComp (CompNP (DetArtPl (IndefArt) (UseN n)))) ;
pred : Adv -> NP -> Cl
= \a,x -> PredVP x (UseComp (CompAdv a)) ;
pred : Prep -> NP -> NP -> Cl
= \p,x,y -> PredVP x (UseComp (CompAdv (PrepNP p y)))
} ;
app = overload {
app : N -> NP
= \n -> (DetArtSg (DefArt) (UseN n)) ;
app : N2 -> NP -> NP
= \n,x -> (DetArtSg (DefArt) (ComplN2 n x)) ;
app : N3 -> NP -> NP -> NP
= \n,x,y -> (DetArtSg (DefArt) (ComplN2 (ComplN3 n x) y)) ;
app : N2 -> NP -> NP -> NP
= \n,x,y -> (DetArtSg DefArt (ComplN2 n (ConjNP and_Conj (BaseNP x y)))) ;
app : N2 -> N -> CN
= \f,n -> ComplN2 f (DetArtPl (IndefArt) (UseN n))
} ;
coord = overload {
coord : Conj -> Adv -> Adv -> Adv
= \c,x,y -> ConjAdv c (BaseAdv x y) ;
coord : Conj -> AP -> AP -> AP
= \c,x,y -> ConjAP c (BaseAP x y) ;
coord : Conj -> NP -> NP -> NP
= \c,x,y -> ConjNP c (BaseNP x y) ;
coord : Conj -> S -> S -> S
= \c,x,y -> ConjS c (BaseS x y) ;
coord : Conj -> ListAdv -> Adv
= \c,xy -> ConjAdv c xy ;
coord : Conj -> ListAP -> AP
= \c,xy -> ConjAP c xy ;
coord : Conj -> ListNP -> NP
= \c,xy -> ConjNP c xy ;
coord : Conj -> ListS -> S
= \c,xy -> ConjS c xy
} ;
mod = overload {
mod : A -> N -> CN
= \a,n -> AdjCN (PositA a) (UseN n) ;
mod : AP -> CN -> CN
= \a,n -> AdjCN a n ;
mod : AdA -> A -> AP
= \m,a -> AdAP m (PositA a) ;
mod : Det -> N -> NP
= \d,n -> DetCN d (UseN n) ;
mod : Det -> CN -> NP
= \d,n -> DetCN d n ;
mod : Quant -> N -> NP
= \q,n -> DetCN (DetQuant (q) NumSg) (UseN n) ;
mod : Quant -> CN -> NP
= \q,n -> DetCN (DetQuant (q) NumSg) n ;
mod : Predet -> N -> NP
= \q,n -> PredetNP q (DetArtPl (IndefArt) (UseN n)) ;
mod : Numeral -> N -> NP
= \nu,n -> DetCN (DetArtCard (IndefArt) (NumNumeral nu)) (UseN n)
} ;
neg = overload {
neg : Imp -> Utt
= UttImpSg PNeg ;
neg : Cl -> S
= UseCl TPres ASimul PNeg;
neg : QCl -> QS
= UseQCl TPres ASimul PNeg;
neg : RCl -> RS
= UseRCl TPres ASimul PNeg
};
-- This is not in ground API, because it would destroy parsing.
appendText : Text -> Text -> Text
= \x,y -> {s = x.s ++ y.s ; lock_Text = <>} ;
}

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsEng = Combinators with (Grammar = GrammarEng) ;

View File

@@ -5,6 +5,8 @@
resource BeschCat = open Prelude, CommonRomance in {
flags coding=utf8 ;
--flags optimize=noexpand ; -- faster than values
--
oper Verbum = {s : VFB => Str} ;

View File

@@ -2,7 +2,7 @@
instance DiffFre of DiffRomance = open CommonRomance, PhonoFre, Prelude in {
flags optimize=noexpand ;
flags optimize=noexpand ; coding=utf8 ;
-- flags optimize=all ;
param
@@ -16,7 +16,7 @@ instance DiffFre of DiffRomance = open CommonRomance, PhonoFre, Prelude in {
prepCase : Case -> Str = \c -> case c of {
Nom => [] ;
Acc => [] ;
CPrep P_a => "à" ;
CPrep P_a => "à" ;
CPrep P_de => elisDe ;
CPrep PNul => []
} ;
@@ -24,7 +24,7 @@ instance DiffFre of DiffRomance = open CommonRomance, PhonoFre, Prelude in {
artDef : Gender -> Number -> Case -> Str = \g,n,c ->
case <g,n,c> of {
<Masc,Sg, CPrep P_de> => pre {"du" ; ["de l'"] / voyelle} ;
<Masc,Sg, CPrep P_a> => pre {"au" ; ["à l'"] / voyelle} ;
<Masc,Sg, CPrep P_a> => pre {"au" ; ["à l'"] / voyelle} ;
<Masc,Sg, _> => elisLe ;
<Fem, Sg, _> => prepCase c ++ elisLa ;
<_, Pl, CPrep P_de> => "des" ;
@@ -205,8 +205,8 @@ instance DiffFre of DiffRomance = open CommonRomance, PhonoFre, Prelude in {
auxPassive : Verb = copula ;
copula : Verb = {s = table VF ["être";"être";"suis";"es";"est";"sommes";"êtes";"sont";"sois";"sois";"soit";"soyons";"soyez";"soient";"étais";"étais";"était";"étions";"étiez";"étaient";"fusse";"fusses";"fût";"fussions";"fussiez";"fussent";"fus";"fus";"fut";"fûmes";"fûtes";"furent";"serai";"seras";"sera";"serons";"serez";"seront";"serais";"serais";"serait";"serions";"seriez";"seraient";"sois";"soyons";"soyez";"été";"étés";"étée";"étées";"étant"]; vtyp=VHabere} ;
copula : Verb = {s = table VF ["être";"être";"suis";"es";"est";"sommes";"êtes";"sont";"sois";"sois";"soit";"soyons";"soyez";"soient";"étais";"étais";"était";"étions";"étiez";"étaient";"fusse";"fusses";"fût";"fussions";"fussiez";"fussent";"fus";"fus";"fut";"fûmes";"fûtes";"furent";"serai";"seras";"sera";"serons";"serez";"seront";"serais";"serais";"serait";"serions";"seriez";"seraient";"sois";"soyons";"soyez";"été";"étés";"étée";"étées";"étant"]; vtyp=VHabere} ;
avoir_V : Verb = {s=table VF ["avoir";"avoir";"ai";"as";"a";"avons";"avez";"ont";"aie";"aies";"ait";"ayons";"ayez";"aient";"avais";"avais";"avait";"avions";"aviez";"avaient";"eusse";"eusses";"eût";"eussions";"eussiez";"eussent";"eus";"eus";"eut";"eûmes";"eûtes";"eurent";"aurai";"auras";"aura";"aurons";"aurez";"auront";"aurais";"aurais";"aurait";"aurions";"auriez";"auraient";"aie";"ayons";"ayez";"eu";"eus";"eue";"eues";"ayant"];vtyp=VHabere};
avoir_V : Verb = {s=table VF ["avoir";"avoir";"ai";"as";"a";"avons";"avez";"ont";"aie";"aies";"ait";"ayons";"ayez";"aient";"avais";"avais";"avait";"avions";"aviez";"avaient";"eusse";"eusses";"eût";"eussions";"eussiez";"eussent";"eus";"eus";"eut";"eûmes";"eûtes";"eurent";"aurai";"auras";"aura";"aurons";"aurez";"auront";"aurais";"aurais";"aurait";"aurions";"auriez";"auraient";"aie";"ayons";"ayez";"eu";"eus";"eue";"eues";"ayant"];vtyp=VHabere};
}

View File

@@ -4,7 +4,7 @@ concrete LexiconFre of Lexicon = CatFre **
open (M = MorphoFre), ParadigmsFre, IrregFre in {
flags
optimize=values ;
optimize=values ;
lin
airplane_N = regGenN "avion" masculine ;

View File

@@ -1,10 +1,12 @@
resource PhonoFre = open Prelude in {
flags coding=utf8 ;
oper
voyelle : Strs = strs {
"a" ; "à" ; "â" ; "e" ; "é" ; "è" ; "ê¨" ;
"a" ; "à" ; "â" ; "e" ; "é" ; "è" ; "ê¨" ;
"h" ;
"i" ; "î" ; "o" ; "ô" ; "u" ; "û" ; "y"
"i" ; "î" ; "o" ; "ô" ; "u" ; "û" ; "y"
} ;
elision : Str -> Str = \d -> d + pre {"e" ; "'" / voyelle} ;

View File

@@ -3,7 +3,7 @@
concrete StructuralFre of Structural = CatFre **
open PhonoFre, MorphoFre, ParadigmsFre, IrregFre, Prelude in {
flags optimize=all ;
flags optimize=all ; coding=utf8 ;
lin

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@ concrete LexiconIta of Lexicon = CatIta ** open
MorphoIta, ParadigmsIta, BeschIta in {
flags
optimize=values ;
optimize=values ; coding=utf8 ;
lin
airplane_N = regN "aereo" ;
@@ -24,7 +24,7 @@ lin
bike_N = regN "bicicletta" ;
bird_N = regN "uccello" ;
black_A = regADeg "nero" ;
blue_A = mkA "blù" "blù" "blù" "blù" "blumente" ;
blue_A = mkA "blù" "blù" "blù" "blù" "blumente" ;
boat_N = regN "batello" ;
book_N = regN "libro" ;
boot_N = regN "stivale" ;
@@ -47,7 +47,7 @@ lin
cheese_N = regN "formaggio" ;
child_N = regN "bambino" ;
church_N = regN "chiesa" ;
city_N = regN "città" ;
city_N = regN "città" ;
clean_A = regADeg "proprio" ;
clever_A = regADeg "saggio" ;
close_V2 = dirV2 (verboV (chiudere_30 "chiudere")) ;
@@ -102,7 +102,7 @@ lin
industry_N = regN "industria" ;
iron_N = regN "ferro" ;
john_PN = mkPN "Giovanni" masculine ;
king_N = regN "ré" ;
king_N = regN "ré" ;
know_V2 = dirV2 (verboV (conoscere_37 "conoscere")) ; --- savoir_V2 : VS
lake_N = regN "lago" ;
lamp_N = regN "lampa" ;
@@ -197,7 +197,7 @@ lin
--- trousers_N = regN "pantalon" ;
ugly_A = regADeg "brutto" ;
understand_V2 = dirV2 (regV "capire") ;
university_N = regN "università" ;
university_N = regN "università" ;
village_N = regN "paese" ;
wait_V2 = mkV2 (regV "aspettare") ParadigmsIta.dative ;
walk_V = regV "camminare" ;
@@ -218,7 +218,7 @@ lin
do_V2 = dirV2 (verboV (fare_52 "fare")) ;
now_Adv = mkAdv "adesso" ;
already_Adv = mkAdv "già" ;
already_Adv = mkAdv "già" ;
song_N = femN (regN "canzone") ;
add_V3 = dirV3 (verboV (giungere_55 "aggiungere")) ParadigmsIta.dative ;
number_N = regN "numero" ;

View File

@@ -1,7 +1,7 @@
concrete StructuralIta of Structural = CatIta **
open PhonoIta, MorphoIta, ParadigmsIta, BeschIta, Prelude in {
flags optimize=all ;
flags optimize=all ; coding=utf8 ;
lin
@@ -13,9 +13,9 @@ lin
} ;
almost_AdA, almost_AdN = ss "quasi" ;
always_AdV = ss "sempre" ;
although_Subj = ss "benché" ** {m = Conjunct} ;
although_Subj = ss "benché" ** {m = Conjunct} ;
and_Conj = {s1 = [] ; s2 = "e" ; n = Pl} ;
because_Subj = ss "perché" ** {m = Indic} ;
because_Subj = ss "perché" ** {m = Indic} ;
before_Prep = mkPrep "prima" ;
behind_Prep = mkPrep "dietro" ;
between_Prep = mkPrep "fra" ;
@@ -39,9 +39,9 @@ lin
mkPronoun
"lui" "lo" "gli" "glie" "lui" "suo" "sua" "suoi" "sue"
Masc Sg P3 ;
here7from_Adv = ss ["da quì"] ;
here7to_Adv = ss "quì" ;
here_Adv = ss "quì" ;
here7from_Adv = ss ["da quì"] ;
here7to_Adv = ss "quì" ;
here_Adv = ss "quì" ;
how_IAdv = ss "come" ;
how8many_IDet = {s = \\g,c => prepCase c ++ genForms "quanti" "quante" ! g ; n = Pl} ;
if_Subj = ss "se" ** {m = Indic} ;
@@ -57,7 +57,7 @@ lin
Masc Sg P3 ;
less_CAdv = ss "meno" ;
many_Det = {s = \\g,c => prepCase c ++ genForms "molti" "molte" ! g ; n = Pl} ;
more_CAdv = ss "più" ;
more_CAdv = ss "più" ;
most_Predet = {s = \\_,c => prepCase c ++ ["la maggior parte"] ; c = CPrep P_di} ;
much_Det = {s = \\g,c => prepCase c ++ genForms "molto" "molta" ! g ; n = Sg} ;
must_VV = mkVV (verboV (dovere_47 "dovere")) ;
@@ -75,7 +75,7 @@ lin
mkPronoun
"lei" "la" "le" "glie" "lei" "suo" "sua" "suoi" "sue"
Fem Sg P3 ;
so_AdA = ss "così" ;
so_AdA = ss "così" ;
somebody_NP = pn2np (mkPN ["qualcuno"] Masc) ;
somePl_Det = {s = \\_,c => prepCase c ++ "qualche" ; n = Pl} ;
someSg_Det = {s = \\_,c => prepCase c ++ "qualche" ; n = Sg} ;
@@ -87,9 +87,9 @@ lin
Pl => \\g,c => prepCase c ++ genForms "quelli" "quelle" ! g ---- quegli
}
} ;
there7from_Adv = ss ["di là"] ;
there7to_Adv = ss "là" ; --- ci
there_Adv = ss "là" ;
there7from_Adv = ss ["di là"] ;
there7to_Adv = ss "là" ; --- ci
there_Adv = ss "là" ;
therefore_PConj = ss "quindi" ;
they_Pron = mkPronoun
"loro" "loro" "li" "glie" "loro" "loro" "loro" "loro" "loro"
@@ -121,10 +121,10 @@ lin
} ;
whoPl_IP = {s = \\c => prepCase c ++ "chi" ; a = aagr Masc Pl} ;
whoSg_IP = {s = \\c => prepCase c ++ "chi" ; a = aagr Masc Sg} ;
why_IAdv = ss "perché" ;
why_IAdv = ss "perché" ;
without_Prep = mkPrep "senza" ;
with_Prep = {s = [] ; c = CPrep P_con ; isDir = False} ;
yes_Utt = ss "sì" ;
yes_Utt = ss "sì" ;
youSg_Pron = mkPronoun
"tu" "ti" "ti" "te" "te" "tuo" "tua" "tuoi" "tue"
Masc Sg P2 ;