extensions by Codex

This commit is contained in:
Krasimir Angelov committed 2026-10-12 10:58:25 +02:00
1 parent bd11a65fd5
commit 970860d11a
12 files changed
+270 -7

No files matched your search

+5
View File
@@ -49,6 +49,11 @@ concrete AdjectiveIna of Adjective = CatIna ** open ResIna, Prelude in {
isPre = ap.isPre
} ;
AdvAP ap adv = {
s = \\a => ap.s ! a ++ adv.s ;
isPre = False
} ;
UseA2 a = {
s = \\_ => a.s ! AAdj Posit ;
-- isPre = a.isPre -- TODO: support adjectives that can be optionally placed before.
+2 -1
View File
@@ -2,7 +2,8 @@ concrete AdverbIna of Adverb = CatIna ** open ResIna, Prelude in {
lin
PositAdvAdj a = {s = a.s ! AAdv} ;
PrepNP prep np = {s = prep.s ++ np.s ! Acc} ;
PositAdAAdj a = {s = a.s ! AAdv} ;
PrepNP prep np = {s = prep.s ++ np.s ! prep.c} ;
ComparAdvAdj cadv a np = {
s = cadv.s ++ a.s ! AAdv ++ "que" ++ np.s ! Nom
+2
View File
@@ -48,8 +48,10 @@ concrete CatIna of Cat = CommonX ** open ResIna, Prelude in {
Det = {s : Case => Str ; n : Number} ;
Predet, Ord = {s : Str};
Card = {s : Str; n : Number } ;
ACard = {s : Str} ;
Num = {s : Str; n : Number } ;
Quant = {s : Number => Case => Str} ;
DAP = {s : Case => Str ; n : Number} ;
-- Numeral
+5
View File
@@ -20,6 +20,8 @@ concrete ConjunctionIna of Conjunction =
ConjRS = conjunctDistrTable Agr ;
ConjCN = conjunctDistrTable Number ;
-- These fun's are generated from the list cat's.
BaseS = twoSS ;
@@ -32,6 +34,8 @@ concrete ConjunctionIna of Conjunction =
ConsAP xs x = consrTable Agr comma xs x ** {isPre = andB xs.isPre x.isPre} ;
BaseRS x y = twoTable Agr x y ;
ConsRS xs x = consrTable Agr comma xs x ;
BaseCN x y = twoTable Number x y ;
ConsCN xs x = consrTable Number comma xs x ;
lincat
[S] = {s1,s2 : Str} ;
@@ -39,5 +43,6 @@ concrete ConjunctionIna of Conjunction =
[NP] = {s1,s2 : Case => Str ; a : Agr} ;
[AP] = {s1,s2 : Agr => Str ; isPre : Bool} ;
[RS] = {s1,s2 : Agr => Str} ;
[CN] = {s1,s2 : Number => Str} ;
}
+170 -4
View File
@@ -1,9 +1,175 @@
--# -path=.:../abstract:../common:prelude
--# -path=.:../abstract:../common:../prelude
concrete ExtendIna of Extend = CatIna **
ExtendFunctor
with (Grammar = GrammarIna)
** {
ExtendFunctor - [
VPS, BaseVPS, ConsVPS, MkVPS, ConjVPS, PredVPS,
VPI, BaseVPI, ConsVPI, MkVPI, ConjVPI, ComplVPIVV,
BaseComp, ConsComp, ConjComp, BaseImp, ConsImp, ConjImp,
PassVPSlash, PassAgentVPSlash, PresPartAP, PastPartAP,
PastPartAgentAP, ProgrVPSlash,
RNP, RNPList, ReflRNP, ReflPron, ReflPoss, PredetRNP,
AdvRNP, AdvRVP, AdvRAP, ReflA2RNP, PossPronRNP,
ConjRNP, Base_rr_RNP, Base_nr_RNP, Base_rn_RNP,
Cons_rr_RNP, Cons_nr_RNP,
CompoundN, CompoundAP, GerundCN, GerundNP, GerundAdv,
ByVP, InOrderToVP, ApposNP, PositAdVAdj, UttVPShort,
ComplSlashPartLast, UseDAP, UseDAPMasc, UseDAPFem
]
with (Grammar = GrammarIna) **
open GrammarIna, ResIna, Coordination, Prelude in {
flags coding=utf8 ;
lincat
VPS = {s : Agr => Str} ;
[VPS] = {s1,s2 : Agr => Str} ;
VPI = {s : Agr => Str} ;
[VPI] = {s1,s2 : Agr => Str} ;
lin
MkVPS temp pol vp = {
s = \\a => (mkClause [] a vp).s ! variants {True;False}
! temp.t ! temp.a ! pol.p ! ODir
} ;
BaseVPS = twoTable Agr ;
ConsVPS = consrTable Agr comma ;
ConjVPS = conjunctDistrTable Agr ;
PredVPS np vps = {s = np.s ! Nom ++ vps.s ! np.a} ;
MkVPI vp = {s = \\a => infVPAg vp a} ;
BaseVPI = twoTable Agr ;
ConsVPI = consrTable Agr comma ;
ConjVPI = conjunctDistrTable Agr ;
ComplVPIVV vv vpi = insertInvarObj (vpi.s ! Sp3) (predV vv) ;
lincat
[Comp] = {s1,s2 : Agr => Str} ;
[Imp] = {s1,s2 : Polarity => Number => Str} ;
lin
BaseComp = twoTable Agr ;
ConsComp = consrTable Agr comma ;
ConjComp = conjunctDistrTable Agr ;
BaseImp = twoTable2 Polarity Number ;
ConsImp = consrTable2 Polarity Number comma ;
ConjImp = conjunctDistrTable2 Polarity Number ;
PassVPSlash vps =
insertInvarObj (partVP vps Sp3) (predV_ esserV) ;
PassAgentVPSlash vps np =
insertInvarObj (partVP vps Sp3 ++ "per" ++ np.s ! Acc)
(predV_ esserV) ;
PresPartAP vp = {
s = \\a => vp.prp ++ vp.clitics ! a ++ vp.rest ! a ;
isPre = False
} ;
PastPartAP vps = {
s = \\a => partVP vps a ;
isPre = False
} ;
PastPartAgentAP vps np = {
s = \\a => partVP vps a ++ "per" ++ np.s ! Acc ;
isPre = False
} ;
ProgrVPSlash vps = vps ;
lincat
RNP = {s : Agr => Case => Str ; isPronoun : Bool} ;
RNPList = {s1,s2 : Agr => Case => Str} ;
lin
ReflRNP vps rnp = insertReflObj vps.p2 vps.c2 rnp vps ;
ReflPron = {
s = \\a,c => casePrep [] c ++ reflPron ! a ;
isPronoun = True
} ;
ReflPoss num cn = {
s = \\a,c => casePrep [] c ++ reflPoss a ++ cn.s ! num.n ;
isPronoun = False
} ;
PredetRNP pred rnp = {
s = \\a,c => pred.s ++ rnp.s ! a ! c ;
isPronoun = False
} ;
AdvRNP np prep rnp = {
s = \\a,c => np.s ! c ++ prep.s ++ rnp.s ! a ! prep.c ;
isPronoun = False
} ;
AdvRVP vp prep rnp = vp ** {
rest = \\a => vp.rest ! a ++ prep.s ++ rnp.s ! a ! prep.c
} ;
AdvRAP ap prep rnp = {
s = \\a => ap.s ! a ++ prep.s ++ rnp.s ! a ! prep.c ;
isPre = False
} ;
ReflA2RNP a rnp = {
s = \\agr => a.s ! AAdj Posit ++ a.c2 ++ rnp.s ! agr ! Acc ;
isPre = False
} ;
PossPronRNP pron num cn rnp = {
s = \\c => casePrep [] c ++ pron.possForm ++ cn.s ! num.n ++
rnp.s ! pron.a ! Gen ;
a = agrP3 num.n ;
isPronoun = False
} ;
ConjRNP conj rnps = conjunctDistrTable2 Agr Case conj rnps ** {
isPronoun = False
} ;
Base_rr_RNP = twoTable2 Agr Case ;
Base_nr_RNP np rnp = twoTable2 Agr Case
{s = \\_,c => np.s ! c} rnp ;
Base_rn_RNP rnp np = twoTable2 Agr Case
rnp {s = \\_,c => np.s ! c} ;
Cons_rr_RNP = consrTable2 Agr Case comma ;
Cons_nr_RNP np rnps = consrTable2 Agr Case comma
{s = \\_,c => np.s ! c} rnps ;
CompoundN n1 n2 = {
s = \\n => n2.s ! n ++ "de" ++ n1.s ! Sg
} ;
CompoundAP noun adj = {
s = \\a => adj.s ! AAdj Posit ++ "de" ++ noun.s ! Sg ;
isPre = False
} ;
GerundCN vp = {s = \\_ => infVPAg vp Sp3} ;
GerundNP vp = {
s = \\_ => infVPAg vp Sp3 ;
a = Sp3 ;
isPronoun = False
} ;
GerundAdv vp = {s = vp.prp ++ vp.clitics ! Sp3 ++ vp.rest ! Sp3} ;
ByVP vp = {s = "per" ++ infVPAg vp Sp3} ;
InOrderToVP vp = {s = "pro" ++ infVPAg vp Sp3} ;
ApposNP np1 np2 = {
s = \\c => np1.s ! c ++ comma ++ np2.s ! c ;
a = np1.a ;
isPronoun = False
} ;
PositAdVAdj a = {s = a.s ! AAdv} ;
UttVPShort vp = {s = infVPAg vp Sp3} ;
ComplSlashPartLast vps np = insertObj vps.p2 vps.c2 np vps ;
UseDAP dap = {
s = dap.s ;
a = agrP3 dap.n ;
isPronoun = False
} ;
UseDAPMasc = UseDAP ;
UseDAPFem = UseDAP ;
oper
infVPAg : ResIna.VP -> Agr -> Str = \vp,a -> variants {
vp.clitics ! a ++ vp.inf ++ vp.rest ! a ;
vp.inf ++ vp.clitics ! a ++ vp.rest ! a
} ;
partVP : ResIna.VP -> Agr -> Str = \vp,a ->
vp.part ++ vp.clitics ! a ++ vp.rest ! a ;
reflPoss : Agr -> Str = \a -> case <a.n,a.p> of {
<Sg,P1> => "mi" ; <Sg,P2> => "tu" ; <Sg,P3> => "su" ;
<Pl,P1> => "nostre" ; <Pl,P2> => "vostre" ; <Pl,P3> => "lor"
} ;
}
+4
View File
@@ -19,6 +19,10 @@ concrete IdiomIna of Idiom = CatIna ** open Prelude, ResIna in {
ExistNP np =
mkClause "il" Sp3 ((insertObj "" Acc np) (predV_ haberV)) ;
ExistNPAdv np adv =
mkClause "il" Sp3 (insertInvarObj adv.s
((insertObj "" Acc np) (predV_ haberV))) ;
-- Il ha colonias que non pote reclamar mesmo un tal origine. (sample text 3)
ExistIP ip = mkQuestion {s=ip.s ! Acc} (mkClause "il" Sp3 (predV_ haberV)) ;
+1 -1
View File
@@ -54,7 +54,7 @@ oper
-- However, most adjectives can be inflected using the final character.
regAdjective : Str -> Adjective = \clar ->
mkAdjective clar ("plus" ++ clar) ("le" ++ "plus" ++ clar) ;
mkAdjective clar ("plus" ++ clar) ("plus" ++ clar) ;
--3 Verbs
+25
View File
@@ -35,6 +35,12 @@ concrete NounIna of Noun = CatIna ** open ResIna, Prelude in {
a = Sp3;
} ;
ExtAdvNP np adv = {
isPronoun = False ;
s = \\c => np.s ! c ++ "," ++ adv.s ;
a = np.a
} ;
-- version 1.4 changes by AR 16/6/2008
DetNP det = {
@@ -72,6 +78,10 @@ concrete NounIna of Noun = CatIna ** open ResIna, Prelude in {
OrdSuperl a = {s = a.s ! AAdj Superl} ;
OrdNumeralSuperl numeral a = {
s = numeral.s ! NOrd ++ a.s ! AAdj Superl
} ;
DefArt = {s = \\_ => table {
Dat => "al";
Gen | Abl => "del";
@@ -118,6 +128,21 @@ concrete NounIna of Noun = CatIna ** open ResIna, Prelude in {
isPronoun = np.isPronoun ---- ?? AR
} ;
PossNP cn np = {s = \\n => cn.s ! n ++ "de" ++ np.s ! Acc} ;
PartNP cn np = {s = \\n => cn.s ! n ++ "de" ++ np.s ! Acc} ;
CountNP det np = {
s = \\c => det.s ! c ++ "de" ++ np.s ! c ;
a = agrP3 det.n ;
isPronoun = False
} ;
DetDAP det = det ;
AdjDAP dap ap = {
s = \\c => dap.s ! c ++ ap.s ! agrP3 dap.n ;
n = dap.n
} ;
QuantityNP n m = {
s = \\c => preOrPost m.isPre m.s (n.s ! NCard) ;
a = agrP3 n.n ;
+28 -1
View File
@@ -5,7 +5,8 @@ concrete NumeralIna of Numeral = CatIna [Numeral,Digits,Decimal] ** open ResIna,
Sub10 = {s : DForm => CardOrd => Str ; n : Number} ;
Sub100 = {s : CardOrd => Str ; n : Number} ;
Sub1000 = {s : CardOrd => Str ; n : Number} ;
Sub1000000 = {s : CardOrd => Str ; n : Number} ;
Sub1000000, Sub1000000000, Sub1000000000000 =
{s : CardOrd => Str ; n : Number} ;
lin num x = x ;
@@ -32,11 +33,37 @@ concrete NumeralIna of Numeral = CatIna [Numeral,Digits,Decimal] ** open ResIna,
lin pot2plus d e = {
s = \\c => d.s ! unit ! NCard ++ "cento" ++ e.s ! c ; n = Pl} ;
lin pot2as3 n = n ;
lin pot21 = regCardOrd "cento" ** {n = Pl} ;
lin pot3 n = {
s = \\c => n.s ! NCard ++ mkCard c "mille" ; n = Pl} ;
lin pot3plus n m = {
s = \\c => n.s ! NCard ++ "mille" ++ m.s ! c ; n = Pl} ;
lin pot31 = regCardOrd "mille" ** {n = Pl} ;
lin pot3as4 n = n ;
lin pot3decimal d = d ;
lin pot41 = regCardOrd "un million" ** {n = Pl} ;
lin pot4 n = {
s = \\c => n.s ! NCard ++ mkCard c "million" ; n = Pl
} ;
lin pot4plus n m = {
s = \\c => n.s ! NCard ++ "million" ++ m.s ! c ; n = Pl
} ;
lin pot4as5 n = n ;
lin pot4decimal d = {
s = \\c => d.s ! NCard ++ mkCard c "million" ; n = Pl
} ;
lin pot51 = regCardOrd "un milliardo" ** {n = Pl} ;
lin pot5 n = {
s = \\c => n.s ! NCard ++ mkCard c "milliardo" ; n = Pl
} ;
lin pot5plus n m = {
s = \\c => n.s ! NCard ++ "milliardo" ++ m.s ! c ; n = Pl
} ;
lin pot5decimal d = {
s = \\c => d.s ! NCard ++ mkCard c "milliardo" ; n = Pl
} ;
-- numerals as sequences of digits
lincat
+4
View File
@@ -216,6 +216,7 @@ resource ResIna = ParamX ** open Prelude in {
rest : Agr => Str; -- comes after the infinite part
clitics : Agr => Str; -- can be placed just before the finite or right after the infinite
prp : Str ; -- present participle (unused at the moment ???)
part : Str ; -- past participle, needed by passive constructions
inf : Str ; -- the infinitive form ; VerbForms would be the logical place
} ;
NP : Type = {
@@ -238,6 +239,7 @@ resource ResIna = ParamX ** open Prelude in {
Anter => \\t,use_irreg => {fin = (haberV!use_irreg).s ! (tenseToVFrom!t); inf = (verb!use_irreg).s!VPPart} --# notpresent
};
prp = (verb!False).s ! VPresPart;
part = (verb!False).s ! VPPart;
inf = (verb!False).s ! VInf;
};
@@ -263,12 +265,14 @@ resource ResIna = ParamX ** open Prelude in {
True => {
inf = vp.inf;
prp = vp.prp;
part = vp.part;
s = vp.s;
clitics = \\agr => obj.s!agr!c ++ vp.clitics!agr; -- clitics are inserted in reverse order.
rest = vp.rest};
False => {
inf = vp.inf;
prp = vp.prp;
part = vp.part;
s = vp.s;
clitics = vp.clitics;
rest = \\agr => vp.rest!agr ++ prep ++ obj.s!agr!c;
+8
View File
@@ -40,6 +40,14 @@ lin
AdvS a s = {s = a.s ++ "," ++ s.s} ;
ExtAdvS a s = {s = a.s ++ "," ++ s.s} ;
SSubjS s1 subj s2 = {s = s1.s ++ subj.s ++ s2.s} ;
AdvImp adv imp = {
s = \\p,n => imp.s ! p ! n ++ adv.s
} ;
RelS s r = {s = s.s ++ "," ++ r.s ! agrP3 Sg} ;
}
+16
View File
@@ -57,6 +57,22 @@ concrete VerbIna of Verb = CatIna ** open ResIna, Prelude in {
ReflVP vp = insertReflObj vp.p2 vp.c2
{isPronoun = True; s = \\agr,c => reflPron!agr} vp ;
AdvVPSlash vp adv = vp ** {
rest = \\a => vp.rest ! a ++ adv.s
} ;
AdVVPSlash adv vp = vp ** {
rest = \\a => adv.s ++ vp.rest ! a
} ;
ExtAdvVP vp adv = vp ** {
rest = \\a => vp.rest ! a ++ "," ++ adv.s
} ;
VPSlashPrep vp prep = vp ** {p2 = prep.s ; c2 = prep.c} ;
UseCopula = predV_ esserV ;
PassV2 v = insertInvarObj (v.s ! VPPart) (predV_ esserV);
CompAP ap = ap ;