extensions by Codex

This commit is contained in:
Krasimir Angelov committed 2026-10-05 11:46:15 +02:00
1 parent 5b67a65ea9
commit 95d86fc0d3
12 files changed
+386 -15

No files matched your search

+1 -1
View File
@@ -32,7 +32,7 @@ lin
-- e.g. "very quickly"
AdAdv ada adv = {s = ada.s ++ adv.s ; isPron = False} ;
-- TODO: PositAdAAdj : A -> AdA
PositAdAAdj a = {s = a.s ! (AAdv Posit)} ;
-- Subj -> S -> Adv
-- e.g. "when she sleeps"
+3
View File
@@ -73,6 +73,9 @@ lincat
Ord = {s : Gender => Case => Str} ;
-- A determiner phrase without an overt noun ("these", "the larger ones").
DAP = {s : Gender => Case => Str ; num : Number ; pol : Polarity} ;
-- Numerals
Numeral = {s : CardOrd => Gender => Case => Str ; num : Number} ;
+13 -1
View File
@@ -18,6 +18,11 @@ lin
ConjAP conj ss = conjunctDistrTable4 Definiteness Gender Number Case conj ss ;
ConjCN conj ss = conjunctDistrTable3 Definiteness Number Case conj ss ** {
gend = ss.gend ;
isRel = False
} ;
-- Conj -> [NP] -> NP
-- e.g. "she or we"
ConjNP conj ss = conjunctDistrTable Case conj ss ** {
@@ -43,6 +48,13 @@ lin
BaseAP x y = twoTable4 Definiteness Gender Number Case x y ;
ConsAP xs x = consrTable4 Definiteness Gender Number Case comma xs x ;
BaseCN x y = twoTable3 Definiteness Number Case x y ** {
gend = conjGender x.gend y.gend
} ;
ConsCN x xs = consrTable3 Definiteness Number Case comma x xs ** {
gend = conjGender x.gend xs.gend
} ;
BaseRS x y = twoTable Agreement x y ;
ConsRS xs x = consrTable Agreement comma xs x ;
@@ -52,9 +64,9 @@ lincat
[RS] = {s1, s2 : Agreement => Str} ;
[NP] = {s1, s2 : Case => Str ; agr : Agreement} ;
[AP] = {s1, s2 : Definiteness => Gender => Number => Case => Str} ;
[CN] = {s1, s2 : Definiteness => Number => Case => Str ; gend : Gender} ;
[Adv] = {s1, s2 : Str} ;
-- TODO: [AdV]{2}
-- TODO: [IAdv]{2}
-- TODO: [CN] {2}
}
+99
View File
@@ -0,0 +1,99 @@
--# -path=.:../abstract:../common:../prelude
concrete ConstructionLav of Construction = CatLav ** open
ResLav, ParadigmsLav, StructuralLav, GrammarLav, Prelude in {
lincat
Timeunit = N ;
Hour = {s : Str} ;
Weekday = N ;
Monthday = NP ;
Month = N ;
Year = NP ;
Language = N ;
lin
hungry_VP = UseComp (CompAP (PositA (mkA "izsalcis"))) ;
thirsty_VP = UseComp (CompAP (PositA (mkA "izslāpis"))) ;
tired_VP = UseComp (CompAP (PositA (mkA "noguris"))) ;
scared_VP = UseComp (CompAP (PositA (mkA "nobijies"))) ;
ill_VP = UseComp (CompAP (PositA (mkA "slims"))) ;
ready_VP = UseComp (CompAP (PositA (mkA "gatavs"))) ;
has_age_VP card = UseComp {s = \\agr =>
card.s ! (fromAgr agr).gend ! Acc ++ "gadus" ++
(mkA "vecs").s ! (AAdj Posit Indef (fromAgr agr).gend
(fromAgr agr).num Nom)} ;
n_units_AP card unit adj = {
s = \\d,g,n,c => card.s ! g ! c ++ unit.s ! Indef ! Pl ! Gen ++
adj.s ! (AAdj Posit d g n c)
} ;
n_units_of_NP card unit np = {
s = \\c => card.s ! unit.gend ! c ++ unit.s ! Indef ! Pl ! Gen ++
np.s ! Gen ;
agr = AgrP3 card.num unit.gend ; pol = Pos ; isRel = False ; isPron = False
} ;
n_unit_CN card unit cn = {
s = \\d,n,c => card.s ! cn.gend ! c ++ unit.s ! Indef ! Sg ! Gen ++ cn.s ! d ! n ! c ;
gend = cn.gend ; isRel = cn.isRel
} ;
bottle_of_CN np = containerCN "pudele" np ;
cup_of_CN np = containerCN "tase" np ;
glass_of_CN np = containerCN "glāze" np ;
weekdayPunctualAdv w = {s = w.s ! Sg ! Loc ; isPron = False} ;
weekdayHabitualAdv w = {s = w.s ! Pl ! Loc ; isPron = False} ;
weekdayLastAdv w = {s = "pagājušajā" ++ w.s ! Sg ! Loc ; isPron = False} ;
weekdayNextAdv w = {s = "nākamajā" ++ w.s ! Sg ! Loc ; isPron = False} ;
monthAdv m = {s = m.s ! Sg ! Loc ; isPron = False} ;
yearAdv y = {s = y.s ! Loc ++ "gadā" ; isPron = False} ;
dayMonthAdv d m = {s = d.s ! Loc ++ m.s ! Sg ! Loc ; isPron = False} ;
monthYearAdv m y = {s = m.s ! Sg ! Loc ++ y.s ! Loc ++ "gadā" ; isPron = False} ;
dayMonthYearAdv d m y = {
s = d.s ! Loc ++ m.s ! Sg ! Loc ++ y.s ! Loc ++ "gadā" ; isPron = False
} ;
intYear i = mkSymbolNP i.s ;
intMonthday i = mkSymbolNP i.s ;
weekdayN w = w ;
monthN m = m ;
weekdayPN w = {s = w.s ! Sg ; gend = w.gend ; num = Sg} ;
monthPN m = {s = m.s ! Sg ; gend = m.gend ; num = Sg} ;
monday_Weekday = mkN "pirmdiena" ;
tuesday_Weekday = mkN "otrdiena" ;
wednesday_Weekday = mkN "trešdiena" ;
thursday_Weekday = mkN "ceturtdiena" ;
friday_Weekday = mkN "piektdiena" ;
saturday_Weekday = mkN "sestdiena" ;
sunday_Weekday = mkN "svētdiena" ;
january_Month = mkN "janvāris" ;
february_Month = mkN "februāris" ;
march_Month = mkN "marts" ;
april_Month = mkN "aprīlis" ;
may_Month = mkN "maijs" ;
june_Month = mkN "jūnijs" ;
july_Month = mkN "jūlijs" ;
august_Month = mkN "augusts" ;
september_Month = mkN "septembris" ;
october_Month = mkN "oktobris" ;
november_Month = mkN "novembris" ;
december_Month = mkN "decembris" ;
oper
containerCN : Str -> NP -> CN = \x,np -> lin CN {
s = \\d,n,c => (mkN x).s ! n ! c ++ np.s ! Gen ;
gend = Fem ; isRel = False
} ;
mkSymbolNP : Str -> NP = \s -> lin NP {
s = \\_ => s ; agr = AgrP3 Sg Masc ; pol = Pos ;
isRel = False ; isPron = False
} ;
}
+172 -2
View File
@@ -5,13 +5,39 @@ concrete ExtendLav of Extend =
[
iFem_Pron, weFem_Pron, youFem_Pron, youPolFem_Pron, youPlFem_Pron,
theyFem_Pron,
ComplDirectVQ, ComplDirectVS
ComplDirectVQ, ComplDirectVS,
VPS, BaseVPS, ConsVPS, MkVPS, ConjVPS, PredVPS,
VPI, BaseVPI, ConsVPI, MkVPI, ConjVPI, ComplVPIVV,
ConjComp, BaseComp, ConsComp, ConjImp, BaseImp, ConsImp,
PresPartAP, PastPartAP, PastPartAgentAP, PassVPSlash,
PassAgentVPSlash, ProgrVPSlash,
RNP, RNPList, ReflRNP, ReflPron, ReflPoss, PredetRNP,
AdvRNP, AdvRVP, AdvRAP, 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, UseDAP, UseDAPMasc, UseDAPFem
]
with
(Grammar = GrammarLav) **
open
ResLav,
ParadigmsPronounsLav in {
ParadigmsPronounsLav,
ParadigmsLav,
StructuralLav,
VerbLav,
Coordination,
Prelude in {
lincat
VPS = {s : Agreement => Str} ;
[VPS] = {s1, s2 : Agreement => Str} ;
VPI = {s : Agreement => Str} ;
[VPI] = {s1, s2 : Agreement => Str} ;
[Comp] = {s1, s2 : Agreement => Str} ;
[Imp] = {s1, s2 : Polarity => Number => Str} ;
RNP = {s : Agreement => Case => Str ; isPron : Bool} ;
RNPList = {s1, s2 : Agreement => Case => Str} ;
lin iFem_Pron = mkPronoun_I Fem ;
weFem_Pron = mkPronoun_We Fem ;
@@ -22,4 +48,148 @@ lin iFem_Pron = mkPronoun_I Fem ;
theyFem_Pron = mkPronoun_They Fem ;
UseDAP dap = {
s = dap.s ! Masc ; agr = AgrP3 dap.num Masc ; pol = dap.pol ;
isRel = False ; isPron = True
} ;
UseDAPMasc = UseDAP ;
UseDAPFem dap = {
s = dap.s ! Fem ; agr = AgrP3 dap.num Fem ; pol = dap.pol ;
isRel = False ; isPron = True
} ;
MkVPS temp pol vp = {
s = \\agr => temp.s ++ pol.s ++
buildVerb vp.v (Ind temp.a temp.t) pol.p agr Pos vp.rightPol ++
vp.compl ! agr
} ;
BaseVPS x y = {s1 = x.s ; s2 = y.s} ;
ConsVPS x xs = {
s1 = \\agr => x.s ! agr ++ "," ++ xs.s1 ! agr ; s2 = xs.s2
} ;
ConjVPS conj xs = {
s = \\agr => conj.s1 ++ xs.s1 ! agr ++ conj.s2 ++ xs.s2 ! agr
} ;
PredVPS np vps = {s = np.s ! Nom ++ closeRelCl np.isRel ++ vps.s ! np.agr} ;
MkVPI vp = {s = \\agr => buildVP vp Pos VInf agr} ;
BaseVPI x y = {s1 = x.s ; s2 = y.s} ;
ConsVPI x xs = {
s1 = \\agr => x.s ! agr ++ "," ++ xs.s1 ! agr ; s2 = xs.s2
} ;
ConjVPI conj xs = {
s = \\agr => conj.s1 ++ xs.s1 ! agr ++ conj.s2 ++ xs.s2 ! agr
} ;
ComplVPIVV vv vpi = {
v = vv ; compl = vpi.s ; voice = Act ; leftVal = vv.leftVal ;
rightAgr = AgrP3 Sg Masc ; rightPol = Pos ; objPron = False
} ;
BaseComp x y = {s1 = x.s ; s2 = y.s} ;
ConsComp x xs = {
s1 = \\agr => x.s ! agr ++ "," ++ xs.s1 ! agr ; s2 = xs.s2
} ;
ConjComp conj xs = {
s = \\agr => conj.s1 ++ xs.s1 ! agr ++ conj.s2 ++ xs.s2 ! agr
} ;
BaseImp x y = {s1 = x.s ; s2 = y.s} ;
ConsImp x xs = {
s1 = \\pol,num => x.s ! pol ! num ++ "," ++ xs.s1 ! pol ! num ;
s2 = xs.s2
} ;
ConjImp conj xs = {
s = \\pol,num => conj.s1 ++ xs.s1 ! pol ! num ++
conj.s2 ++ xs.s2 ! pol ! num
} ;
PresPartAP vp = {
s = \\_,g,n,c => vp.v.s ! Pos ! (VPart Act g n c) ++
vp.compl ! AgrP3 n g
} ;
PastPartAP vp = {
s = \\_,g,n,c => vp.v.s ! Pos ! (VPart Pass g n c) ++
vp.compl ! AgrP3 n g
} ;
PastPartAgentAP vp np = {
s = \\_,g,n,c => vp.v.s ! Pos ! (VPart Pass g n c) ++
vp.compl ! AgrP3 n g ++ "no" ++ np.s ! Gen
} ;
PassVPSlash vp = {
v = vp.v ; compl = vp.compl ; voice = Pass ;
leftVal = vp.rightVal.c ! Sg ; rightAgr = vp.rightAgr ;
rightPol = vp.rightPol ; objPron = False
} ;
PassAgentVPSlash vp np =
insertObjReg (\\_ => "no" ++ np.s ! Gen) False (PassVPSlash vp) ;
ProgrVPSlash vp = vp ;
ReflPron = {s = \\_,c => reflPron ! c ; isPron = True} ;
ReflPoss num cn = {
s = \\agr,c => (mkPronoun_Gend "savs").s ! (fromAgr agr).gend ! num.num ! c ++
cn.s ! Def ! num.num ! c ;
isPron = False
} ;
PredetRNP pred rnp = {
s = \\agr,c => pred.s ! (fromAgr agr).gend ++ rnp.s ! agr ! c ;
isPron = False
} ;
AdvRNP np prep rnp = {
s = \\agr,c => np.s ! c ++ prep.s ++
rnp.s ! agr ! (prep.c ! (fromAgr agr).num) ;
isPron = False
} ;
AdvRVP vp prep rnp = insertObjReg
(\\agr => prep.s ++ rnp.s ! agr ! (prep.c ! (fromAgr agr).num)) False vp ;
AdvRAP ap prep rnp = {
s = \\d,g,n,c => ap.s ! d ! g ! n ! c ++ prep.s ++
rnp.s ! AgrP3 n g ! (prep.c ! n)
} ;
ReflRNP vp rnp = insertObjPre
(\\agr => vp.rightVal.s ++
rnp.s ! agr ! (vp.rightVal.c ! (fromAgr agr).num)) vp ;
PossPronRNP pron num cn rnp = {
s = \\c => pron.poss ! (fromAgr pron.agr).gend ! num.num ! c ++
cn.s ! Def ! num.num ! c ++ rnp.s ! pron.agr ! Gen ;
agr = AgrP3 num.num cn.gend ; pol = Pos ; isRel = False ; isPron = False
} ;
Base_rr_RNP x y = {s1 = x.s ; s2 = y.s} ;
Base_nr_RNP x y = {s1 = \\_,c => x.s ! c ; s2 = y.s} ;
Base_rn_RNP x y = {s1 = x.s ; s2 = \\_,c => y.s ! c} ;
Cons_rr_RNP x xs = {
s1 = \\agr,c => x.s ! agr ! c ++ "," ++ xs.s1 ! agr ! c ; s2 = xs.s2
} ;
Cons_nr_RNP x xs = {
s1 = \\agr,c => x.s ! c ++ "," ++ xs.s1 ! agr ! c ; s2 = xs.s2
} ;
ConjRNP conj xs = {
s = \\agr,c => conj.s1 ++ xs.s1 ! agr ! c ++ conj.s2 ++ xs.s2 ! agr ! c ;
isPron = False
} ;
CompoundN modifier head = {
s = \\n,c => modifier.s ! Sg ! Gen ++ head.s ! n ! c ;
gend = head.gend
} ;
CompoundAP noun adj = {
s = \\d,g,n,c => noun.s ! Sg ! Gen ++ adj.s ! (AAdj Posit d g n c)
} ;
GerundCN vp = {
s = \\_,_,_ => buildVP vp Pos VInf (AgrP3 Sg Masc) ;
gend = Fem ; isRel = False
} ;
GerundNP vp = {
s = \\_ => buildVP vp Pos VInf (AgrP3 Sg Masc) ;
agr = AgrP3 Sg Fem ; pol = Pos ; isRel = False ; isPron = False
} ;
GerundAdv vp = {s = buildVP vp Pos VInf (AgrP3 Sg Masc) ; isPron = False} ;
ByVP vp = {s = buildVP vp Pos VInf (AgrP3 Sg Masc) ; isPron = False} ;
InOrderToVP vp = {
s = "lai" ++ buildVP vp Pos VInf (AgrP3 Sg Masc) ; isPron = False
} ;
ApposNP x y = {
s = \\c => x.s ! c ++ "," ++ y.s ! c ; agr = x.agr ; pol = x.pol ;
isRel = y.isRel ; isPron = False
} ;
PositAdVAdj a = {s = a.s ! (AAdv Posit)} ;
}
+5
View File
@@ -34,6 +34,11 @@ lin
s = \\mood,pol => buildVerb (mkV "būt") mood pol np.agr np.pol Pos ++ np.s ! Nom
} ;
ExistNPAdv np adv = {
s = \\mood,pol => buildVerb (mkV "būt") mood pol np.agr np.pol Pos ++
np.s ! Nom ++ adv.s
} ;
ExistIP ip = {
s = \\mood,pol => ip.s ! Nom ++ buildVerb (mkV "būt") mood pol (AgrP3 ip.num Masc) Pos Pos
} ;
+1
View File
@@ -3,6 +3,7 @@
concrete LangLav of Lang =
GrammarLav,
LexiconLav
,ConstructionLav
,DocumentationLav --# notpresent
** {
+7
View File
@@ -46,4 +46,11 @@ lin
isPron = False
} ;
InLN ln = {s = ln.s ! Loc ; isPron = False} ;
AdjLN ap ln = {
s = \\c => ap.s ! Def ! ln.gend ! ln.num ! c ++ ln.s ! c ;
gend = ln.gend ; num = ln.num
} ;
}
+45 -7
View File
@@ -71,6 +71,11 @@ lin
isPron = False
} ;
ExtAdvNP np adv = {
s = \\c => np.s ! c ++ "," ++ adv.s ;
agr = np.agr ; pol = np.pol ; isRel = np.isRel ; isPron = False
} ;
-- NP -> RS -> NP
-- e.g. 'Paris, which is here'
RelNP np rs = {
@@ -254,15 +259,48 @@ lin
isRel = np.isRel
} ;
-- TODO: Possessive and partitive constructs
-- Latvian possessors normally precede the head and are in the genitive.
PossNP cn np = {
s = \\defin,num,c => np.s ! Gen ++ closeRelCl np.isRel ++
cn.s ! defin ! num ! c ;
gend = cn.gend ;
isRel = False
} ;
-- PossNP : CN -> NP -> CN
-- e.g. 'house of Paris', 'house of mine'
-- Partitives retain the lexical head first: "glāze vīna".
PartNP cn np = {
s = \\defin,num,c => cn.s ! defin ! num ! c ++ np.s ! Gen ++
closeRelCl np.isRel ;
gend = cn.gend ;
isRel = False
} ;
-- PartNP : CN -> NP -> CN
-- e.g. 'glass of wine'
CountNP det np = {
s = \\c => det.s ! (fromAgr np.agr).gend ! c ++ "no" ++ np.s ! Gen ;
agr = AgrP3 det.num (fromAgr np.agr).gend ;
pol = det.pol ;
isRel = False ;
isPron = False
} ;
-- CountNP : Det -> NP -> NP
-- e.g. 'three of them', 'some of the boys'
DetDAP det = {
s = det.s ;
num = det.num ;
pol = det.pol
} ;
AdjDAP dap ap = {
s = \\g,c => dap.s ! g ! c ++ ap.s ! Def ! g ! dap.num ! c ;
num = dap.num ;
pol = dap.pol
} ;
QuantityNP decimal mu = {
s = \\_ => decimal.s ! NCard ++ mu.s ;
agr = AgrP3 decimal.num Masc ;
pol = Pos ;
isRel = False ;
isPron = False
} ;
}
+27
View File
@@ -59,6 +59,8 @@ lin
pot1as2 n = n ;
pot21 = {s = \\_,_,_ => "simts" ; num = Pl} ;
-- FIXME: nav īsti labi, kārtas skaitlim ir jābūt 'trīssimtais' utml
pot2 d = {
s = \\o,g,c => d.s ! NCard ! Masc ! Nom ++ simts ! o ! g ! d.num ! c ;
@@ -72,6 +74,8 @@ lin
pot2as3 n = n ;
pot31 = {s = \\_,_,_ => "tūkstotis" ; num = Pl} ;
pot3 d = {
s = \\o,g,c => d.s ! NCard ! Masc ! Nom ++ tuukstotis ! o ! g ! d.num ! c ;
num = Pl
@@ -83,8 +87,31 @@ lin
} ;
pot3as4 n = n ;
pot3decimal d = {s = \\_,_,_ => d.s ! NCard ++ "tūkstoši" ; num = Pl} ;
pot41 = {s = \\_,_,_ => "miljons" ; num = Pl} ;
pot4 n = {
s = \\_,_,_ => n.s ! NCard ! Masc ! Nom ++ "miljoni" ; num = Pl
} ;
pot4plus n m = {
s = \\o,g,c => n.s ! NCard ! Masc ! Nom ++ "miljoni" ++ m.s ! o ! g ! c ;
num = m.num
} ;
pot4decimal d = {s = \\_,_,_ => d.s ! NCard ++ "miljoni" ; num = Pl} ;
pot4as5 n = n ;
pot51 = {s = \\_,_,_ => "miljards" ; num = Pl} ;
pot5 n = {
s = \\_,_,_ => n.s ! NCard ! Masc ! Nom ++ "miljardi" ; num = Pl
} ;
pot5plus n m = {
s = \\o,g,c => n.s ! NCard ! Masc ! Nom ++ "miljardi" ++ m.s ! o ! g ! c ;
num = m.num
} ;
pot5decimal d = {s = \\_,_,_ => d.s ! NCard ++ "miljardi" ; num = Pl} ;
-- Numerals as sequences of digits:
lincat
+8
View File
@@ -63,6 +63,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 = \\pol,num => adv.s ++ imp.s ! pol ! num
} ;
oper
-- TODO: PassV2 verbs jāsaskaņo ar objektu, nevis subjektu (by8means_Prep: AgP3 Sg Masc)
mkClause : NP -> CatLav.VP -> Cl = \np,vp ->
+5 -4
View File
@@ -272,15 +272,16 @@ lin
-- e.g. 'sleep here'
AdvVP vp adv = insertObjReg (\\_ => adv.s) adv.isPron vp ;
ExtAdvVP vp adv = insertObjReg (\\_ => "," ++ adv.s) False vp ;
-- AdV -> VP -> VP
-- e.g. 'always sleep'
AdVVP adv vp = insertObjPre (\\_ => adv.s) vp ;
-- TODO: AdvVPSlash : VPSlash -> Adv -> VPSlash
-- e.g. 'use (it) here'
AdvVPSlash vp adv = insertObjSlash (\\_ => adv.s) vp ;
-- TODO: AdVVPSlash : AdV -> VPSlash -> VPSlash
-- e.g. 'always use (it)'
AdVVPSlash adv vp =
(insertObjPre (\\_ => adv.s) vp) ** {rightVal = vp.rightVal} ;
-- VP -> Prep -> VPSlash
-- e.g. 'live in (it)'