modified mkPN and added preliminary structure of compounds (#452)

* modified mkPN and added preliminary structure of compounds

* added PassAgentVPSlash

* fixed PassAgentVPSlash and mkN
This commit is contained in:
Ekaterina Voloshina
2024-02-29 11:14:13 +01:00
committed by GitHub
parent 600af2b8bf
commit 4b4fbbb401
9 changed files with 251 additions and 211 deletions

View File

@@ -140,7 +140,9 @@ concrete ConjunctionRus of Conjunction =
s = \\n,cas => conj.s1 ++ xs.s1 ! n ! cas ++ conj.s2 ++ xs.s2 ! n ! cas ;
g = xs.g ;
mayben = JustPl ;
anim = xs.anim
anim = xs.anim ;
rel = (guessAdjectiveForms "");
rt = GenType ;
} ;
-- : NP -> NP -> ListNP ; -- John, Mary

View File

@@ -1,4 +1,4 @@
--# -path=../common:../abstract
--# -path=../common:../abstract:../common
concrete ExtendRus of Extend =
CatRus ** ExtendFunctor - [
@@ -36,7 +36,7 @@ concrete ExtendRus of Extend =
-- GerundAdv, GerundCN, GerundNP, IAdvAdv, ICompAP,
InOrderToVP,
-- NominalizeVPSlashNP,
-- PassAgentVPSlash,
PassAgentVPSlash,
PassVPSlash,
-- ProgrVPSlash,
PastPartAP,
@@ -102,7 +102,42 @@ lin
youFem_Pron = personalPron (Ag (GSg Fem) P2) ;
-- : N -> N -> N ;
CompoundN n1 n2 = mkCompoundN n1 "-" n2 ;
-- CompoundN n1 n2 = mkCompoundN n1 n2 ;
CompoundN n1 n2 = case n1.rt of {
GenType => n2 ** {snom = n2.snom ++ n1.sgen ;
sgen = n2.sgen ++ n1.sgen ;
sdat = n2.sdat ++ n1.sgen;
sacc = n2.sacc ++ n1.sgen;
sins = n2.sins ++ n1.sgen;
sprep = n2.sprep ++ n1.sgen;
sloc = n2.sloc ++ n1.sgen;
sptv = n2.sptv ++ n1.sgen;
svoc = n2.svoc ++ n1.sgen;
pnom = n2.pnom ++ n1.sgen;
pgen = n2.pgen ++ n1.sgen;
pdat = n2.pdat ++ n1.sgen;
pacc = n2.pacc ++ n1.sgen;
pins = n2.pins ++ n1.sgen;
pprep = n2.pprep ++ n1.sgen;
} ;
AdjType => n2 ** {snom = (adjFormsAdjective n1.rel).s ! (gennum n2.g Sg) ! n2.anim ! Nom ++ n2.snom;
sgen = (adjFormsAdjective n1.rel).s ! (gennum n2.g Sg) ! n2.anim ! Gen ++ n2.sgen ;
sdat = (adjFormsAdjective n1.rel).s ! (gennum n2.g Sg) ! n2.anim ! Dat ++ n2.sdat ;
sacc = (adjFormsAdjective n1.rel).s ! (gennum n2.g Sg) ! n2.anim ! Acc ++ n2.sacc ;
sins = (adjFormsAdjective n1.rel).s ! (gennum n2.g Sg) ! n2.anim ! Ins ++ n2.sins ;
sprep = (adjFormsAdjective n1.rel).s ! (gennum n2.g Sg) ! n2.anim ! Loc ++ n2.sprep ;
sloc = (adjFormsAdjective n1.rel).s ! (gennum n2.g Sg) ! n2.anim ! Loc ++ n2.sloc ;
sptv = (adjFormsAdjective n1.rel).s ! (gennum n2.g Sg) ! n2.anim ! Gen ++ n2.sptv ;
svoc = (adjFormsAdjective n1.rel).s ! (gennum n2.g Sg) ! n2.anim ! Nom ++ n2.svoc ;
pnom = (adjFormsAdjective n1.rel).s ! (gennum n2.g Pl) ! n2.anim ! Nom ++ n2.pnom ;
pgen = (adjFormsAdjective n1.rel).s ! (gennum n2.g Pl) ! n2.anim ! Gen ++ n2.pgen ;
pdat = (adjFormsAdjective n1.rel).s ! (gennum n2.g Pl) ! n2.anim ! Dat ++ n2.pdat ;
pacc = (adjFormsAdjective n1.rel).s ! (gennum n2.g Pl) ! n2.anim ! Acc ++ n2.pacc ;
pins = (adjFormsAdjective n1.rel).s ! (gennum n2.g Pl) ! n2.anim ! Ins ++ n2.pins ;
pprep = (adjFormsAdjective n1.rel).s ! (gennum n2.g Pl) ! n2.anim ! Loc ++ n2.pprep ;
}
} ;
-- VPSlash -> AP ; -- lost (opportunity) ; (opportunity) lost in space
PastPartAP vps = {
@@ -147,6 +182,14 @@ lin
-- PresPartAP : VP -> AP ; -- (the man) looking at Mary
-- use PlP2 + "ый"
-- : VPSlash -> VP
PassAgentVPSlash vps np =
vps ** {
verb=copulaEll ;
compl=\\p,a => vps.compl ! p ! a ++ shortPastPassPart vps.verb (agrGenNum a) ++ vps.c.s ++ np.s ! Ins
} ;
-- : Pron -> Pron ; -- unstressed subject pronoun becomes empty: "am tired"
ProDrop pron = {
nom,gen,dat,acc,ins,prep=[] ;

View File

@@ -15,6 +15,7 @@ param
Conjug = I | I' | II ; -- first, first with stressed ending, second conjugation
VerbStressSchema = VSS VerbSS VerbSS ; -- Pres / Imp and Past forms respectively. By default, _A as second
ZVIndex = ZV ConjType AlterType VerbStressSchema ;
oper
--------
@@ -43,7 +44,9 @@ oper
= \s, g, anim -> {
snom=s;pnom=s;sgen=s;pgen=s;sdat=s;pdat=s;sacc=s;pacc=s;sins=s;pins=s;sprep=s;pprep=s;
anim=anim;
g=g
g=g;
rel=immutableAdjectiveCases s;
rt=GenType;
} ;
immutableCasesS1 : NounEndFormsS1 = {
@@ -255,14 +258,14 @@ oper
<Fem, _> => mobileTwo s nef dt ss
} ;
doAlternations : Str -> NounEndForms -> Gender -> Animacy -> DeclType -> StressSchema -> NounFormsBase
= \s, nef, g, anim, dt, ss ->
(alterStems s nef g dt ss) ** {g=g; anim=anim} ;
doAlternations : Str -> NounEndForms -> Gender -> Animacy -> DeclType -> StressSchema -> AdjForms -> NRelType -> NounFormsBase
= \s, nef, g, anim, dt, ss, rel, rt ->
(alterStems s nef g dt ss) ** {g=g; anim=anim; rel=rel; rt=rt} ;
alterForms : Str -> NounEndForms -> Gender -> Animacy -> DeclType -> AlterType -> StressSchema -> NounFormsBase
= \s, nef, g, anim, dt, at, ss ->
alterForms : Str -> NounEndForms -> Gender -> Animacy -> DeclType -> AlterType -> StressSchema -> AdjForms -> NRelType -> NounFormsBase
= \s, nef, g, anim, dt, at, ss, rel, rt ->
case at of {
Ast => doAlternations s nef g anim dt ss ;
Ast => doAlternations s nef g anim dt ss rel rt;
_ => {
snom = s + nef.snom ;
pnom = s + nef.pnom ;
@@ -277,18 +280,20 @@ oper
sprep= s + nef.sprep ;
pprep= s + nef.pprep ;
g=g ;
anim=anim
anim=anim ;
rel=rel;
rt=rt ;
}
} ;
makeNoun : Str -> Gender -> Animacy -> ZNIndex -> NounFormsBase
= \word, g, anim, z ->
makeNoun : Str -> Gender -> Animacy -> AdjForms -> NRelType -> ZNIndex -> NounFormsBase
= \word, g, anim, rel, rt, z ->
case z of {
ZN0 => immutableNounCases word g anim ;
ZN 3 Deg ss NoC => formsSelectionOnok word g anim 3 Deg ss NoC ;
ZN 1 Deg ss ci => formsSelectionAnin word g anim 3 Deg ss ci ;
ZN 8 Deg ss NoC => formsSelectionMya word g anim 8 Deg ss NoC ;
ZN dt at ss ci => formsSelectionNoun word g anim dt at ss ci
ZN 3 Deg ss NoC => formsSelectionOnok word g anim 3 Deg ss rel rt NoC ;
ZN 1 Deg ss ci => formsSelectionAnin word g anim 3 Deg ss rel rt ci ;
ZN 8 Deg ss NoC => formsSelectionMya word g anim 8 Deg ss rel rt NoC ;
ZN dt at ss ci => formsSelectionNoun word g anim dt at ss rel rt ci
} ;
myaCases : Str -> NounEndForms
@@ -310,28 +315,28 @@ oper
pprep=stem + suffix + "ах"
} ;
formsSelectionMya : Str -> Gender -> Animacy -> DeclType -> AlterType -> StressSchema -> ZCirc -> NounFormsBase
= \word, g, anim, dt, at, ss, ci ->
formsSelectionMya : Str -> Gender -> Animacy -> DeclType -> AlterType -> StressSchema -> AdjForms -> NRelType -> ZCirc -> NounFormsBase
= \word, g, anim, dt, at, ss, rel, rt, ci ->
let butLast = Predef.tk 1 word in
(myaCases butLast) ** {anim=anim; g=g} ;
(myaCases butLast) ** {anim=anim; g=g; rel=rel; rt=rt} ;
formsSelectionOnok : Str -> Gender -> Animacy -> DeclType -> AlterType -> StressSchema -> ZCirc -> NounFormsBase
= \word, g, anim, dt, at, ss, ci ->
let sgForms = formsSelectionNoun word g anim dt Ast ss ci in
formsSelectionOnok : Str -> Gender -> Animacy -> DeclType -> AlterType -> StressSchema -> AdjForms -> NRelType -> ZCirc -> NounFormsBase
= \word, g, anim, dt, at, ss, rel, rt, ci ->
let sgForms = formsSelectionNoun word g anim dt Ast ss rel rt ci in
case word of {
_ + "ёнок" => combineDiffSgPlStems sgForms (formsSelectionNoun (Predef.tk 4 word + "ята") Neut anim 8 Ast ss NoC) ;
_ + "онок" => combineDiffSgPlStems sgForms(formsSelectionNoun (Predef.tk 4 word + "ата") Neut anim 8 Ast ss NoC) ;
_ + "ёночек" => combineDiffSgPlStems sgForms (formsSelectionNoun (Predef.tk 6 word + "ятка") Fem anim 3 Ast ss NoC) ;
_ + "оночек" => combineDiffSgPlStems sgForms (formsSelectionNoun (Predef.tk 6 word + "атка") Fem anim 3 Ast ss NoC) ;
_ + "ёнок" => combineDiffSgPlStems sgForms (formsSelectionNoun (Predef.tk 4 word + "ята") Neut anim 8 Ast ss rel rt NoC) ;
_ + "онок" => combineDiffSgPlStems sgForms(formsSelectionNoun (Predef.tk 4 word + "ата") Neut anim 8 Ast ss rel rt NoC) ;
_ + "ёночек" => combineDiffSgPlStems sgForms (formsSelectionNoun (Predef.tk 6 word + "ятка") Fem anim 3 Ast ss rel rt NoC) ;
_ + "оночек" => combineDiffSgPlStems sgForms (formsSelectionNoun (Predef.tk 6 word + "атка") Fem anim 3 Ast ss rel rt NoC) ;
_ => sgForms
} ;
formsSelectionAnin : Str -> Gender -> Animacy -> DeclType -> AlterType -> StressSchema -> ZCirc -> NounFormsBase
= \word, g, anim, dt, at, ss, ci ->
formsSelectionAnin : Str -> Gender -> Animacy -> DeclType -> AlterType -> StressSchema -> AdjForms -> NRelType -> ZCirc -> NounFormsBase
= \word, g, anim, dt, at, ss, rel, rt, ci ->
let butTwolast = Predef.tk 2 word in
let sgForms = formsSelectionNoun word g anim dt Ast ss ci in
let sgForms = formsSelectionNoun word g anim dt Ast ss rel rt ci in
case word of {
_ + ("анин"|"янин") => combineDiffSgPlStems sgForms (formsSelectionNoun (butTwolast + "н") Neut anim 8 Ast ss NoC)
_ + ("анин"|"янин") => combineDiffSgPlStems sgForms (formsSelectionNoun (butTwolast + "н") Neut anim 8 Ast ss rel rt NoC)
** {pnom=butTwolast + "е"};
_ => sgForms
} ;
@@ -346,12 +351,12 @@ oper
pprep= pln.pprep
} ;
formsSelectionNoun : Str -> Gender -> Animacy -> DeclType -> AlterType -> StressSchema -> ZCirc -> NounFormsBase
= \word, g, anim, dt, at, ss, ci ->
formsSelectionNoun : Str -> Gender -> Animacy -> DeclType -> AlterType -> StressSchema -> AdjForms -> NRelType -> ZCirc -> NounFormsBase
= \word, g, anim, dt, at, ss, rel, rt, ci ->
let stem = stemFromNoun word g dt in
let nef = endingsSelectionNoun g anim dt at ss ci in
let nef' = specialEndingsNoun word stem nef g dt in
let alternated = alterForms stem nef' g anim dt at ss in
let alternated = alterForms stem nef' g anim dt at ss rel rt in
animacySelectionNoun dt alternated nef' g anim
;

View File

@@ -68,15 +68,19 @@ lin
s=\\n,cas=> (nounFormsNoun n2).s ! n ! cas ++ n2.c2.s ++ np.s ! n2.c2.c ;
g=n2.g ;
mayben=n2.mayben ;
anim=n2.anim
anim=n2.anim ;
rel=n2.rel;
rt=n2.rt;
} ;
-- : N3 -> NP -> N2 ; -- distance from this city (to Paris)
ComplN3 n3 np = let n3_noun = nounFormsNoun n3 in nounToNounForm {
s=\\n,g=>n3_noun.s ! n ! g ++ n3.c2.s ++ np.s ! n3.c2.c ;
g=n3.g ;
mayben=n3.mayben ;
anim=n3.anim
} ** {c2=n3.c3} ;
anim=n3.anim ;
rel=n3.rel;
rt=n3.rt ;
} ** {c2=n3.c3; rt = n3.rt} ;
--------------
-- Determiners
@@ -168,6 +172,7 @@ lin
-- : N3 -> N2 ; -- distance (to Paris)
Use3N3 n3 = lin N2 n3 ;
-- : CN -> RS -> CN ; -- house that John bought
RelCN cn rs = cn ** {
s = \\n,c => cn.s ! n ! c ++ embedInCommas (rs.s ! gennum cn.g (forceMaybeNum cn.mayben n) ! cn.anim ! c)

View File

@@ -1,3 +1,4 @@
--# -path=.:../abstract:../common
--1 Russian Lexical Paradigms
resource ParadigmsRus = open CatRus, ResRus, (R=ResRus), ParamRus, (Z=InflectionRus), Prelude, Maybe, MorphoRus in {
@@ -102,9 +103,13 @@ oper
mkN : overload {
mkN : Str -> N ; -- can guess declension and gender of some nouns given nominative
mkN : Str -> Gender -> Animacy -> N ; -- can guess declension of more nouns
mkN : Str -> Str -> NRelType -> N ;
mkN : Str -> Gender -> Animacy -> N ;
mkN : Str -> Gender -> Animacy -> Str -> NRelType -> N ; -- can guess declension of more nouns
mkN : Str -> Gender -> Animacy -> (idx : Str) -> N ; -- Fourth parameter is a declension type index (based on Zaliznyak's dictionary), for example, "1*a(1)"
mkN : Str -> Gender -> Animacy -> (idx : Str) -> MaybeNumber -> N ; -- Same, but number restrictions can be added
mkN : Str -> Gender -> Animacy -> Str -> NRelType -> (idx : Str) -> N ;
mkN : Str -> Gender -> Animacy -> (idx : Str) -> MaybeNumber -> N ;
mkN : Str -> Gender -> Animacy -> Str -> NRelType -> (idx : Str) -> MaybeNumber -> N ; -- Same, but number restrictions can be added
mkN : A -> Gender -> Animacy -> N ; -- for nouns, which decline as adjective
mkN : A -> Gender -> Animacy -> MaybeNumber -> N ; -- same, with possibility to limit number (usually to only_singular)
mkN : N -> (link : Str) -> N -> N ; -- compound noun. Link can end on "-", in which case parts are glued together. First one characterizes the whole.
@@ -124,6 +129,8 @@ oper
mkPN : overload {
mkPN : N -> PN ;
mkPN : N -> Str -> N -> PN ; -- see compound noun
mkPN : A -> PN -> PN ;
} ;
--2 Adjectives
@@ -241,17 +248,27 @@ oper
mkN = overload {
mkN : Str -> N
= \nom -> lin N (guessNounForms nom) ;
mkN : Str -> Animacy -> N
= \nom,anim -> lin N ((guessNounForms nom) ** {anim=anim}) ;
= \nom -> lin N (guessNounForms nom (guessAdjectiveForms "") GenType); -- the default type of compound
mkN : Str -> Str-> NRelType -> N
= \nom, rel, rt -> lin N (guessNounForms nom (guessAdjectiveForms rel) rt) ;
mkN : Str -> Animacy -> Str -> NRelType -> N
= \nom,anim,rel,rt -> lin N (guessNounForms nom (guessAdjectiveForms rel) rt) ** {anim=anim} ;
mkN : Str -> Gender -> Animacy -> N
= \nom, g, anim -> lin N (guessLessNounForms nom g anim) ;
= \nom, g, anim -> lin N (guessLessNounForms nom g anim (guessAdjectiveForms "") GenType) ;
mkN : Str -> Gender -> Animacy -> Str -> NRelType -> N
= \nom, g, anim, rel, rt -> lin N (guessLessNounForms nom g anim (guessAdjectiveForms rel) rt) ;
mkN : Str -> Gender -> Animacy -> Z.ZNIndex -> N
= \word, g, anim, z -> lin N (noMinorCases (Z.makeNoun word g anim z)) ;
= \word, g, anim, z -> lin N (noMinorCases (Z.makeNoun word g anim (guessAdjectiveForms "") GenType z)) ;
mkN : Str -> Gender -> Animacy -> Str -> NRelType -> Z.ZNIndex -> N
= \word, g, anim, rel, rt, z -> lin N (noMinorCases (Z.makeNoun word g anim (guessAdjectiveForms rel) rt z)) ;
mkN : Str -> Gender -> Animacy -> Str -> N
= \word, g, anim, zi -> lin N (noMinorCases (Z.makeNoun word g anim (Z.parseIndex zi))) ;
= \word, g, anim, zi -> lin N (noMinorCases (Z.makeNoun word g anim (guessAdjectiveForms "") GenType (Z.parseIndex zi))) ;
mkN : Str -> Gender -> Animacy -> Str -> NRelType -> Str -> N
= \word, g, anim, rel, rt, zi -> lin N (noMinorCases (Z.makeNoun word g anim (guessAdjectiveForms rel) rt (Z.parseIndex zi))) ;
mkN : Str -> Gender -> Animacy -> Str -> MaybeNumber -> N
= \word, g, anim, zi, mbn -> lin N (applyMaybeNumber ((noMinorCases (Z.makeNoun word g anim (Z.parseIndex zi))) ** {mayben=mbn})) ;
= \word, g, anim, zi, mbn -> lin N (applyMaybeNumber ((noMinorCases (Z.makeNoun word g anim (guessAdjectiveForms "") GenType (Z.parseIndex zi))) ** {mayben=mbn})) ;
mkN : Str -> Gender -> Animacy -> Str -> NRelType -> Str -> MaybeNumber -> N
= \word, g, anim, rel, rt, zi, mbn -> lin N (applyMaybeNumber ((noMinorCases (Z.makeNoun word g anim (guessAdjectiveForms rel) rt (Z.parseIndex zi))) ** {mayben=mbn})) ;
mkN : A -> Gender -> Animacy -> N
= \a, g, anim -> lin N (makeNFFromAF a g anim) ;
mkN : A -> Gender -> Animacy -> MaybeNumber -> N
@@ -267,86 +284,9 @@ oper
sloc=prepos2Sg; sptv=genSg ; svoc=nomSg ;
anim=anim;
mayben=BothSgPl ;
g=g
} ;
} ;
compoundN = overload {
compoundN : A -> N -> N
= \a, n -> applyMaybeNumber
{snom = case n.g of {
Fem => preOrPost (notB a.p) a.fsnom n.snom ;
Masc => preOrPost (notB a.p) a.msnom n.snom ;
Neut => preOrPost (notB a.p) a.nsnom n.snom
} ;
sgen = case n.g of {
Fem => preOrPost (notB a.p) a.fsgen n.sgen ;
_ => preOrPost (notB a.p) a.msgen n.sgen
} ;
sdat = case n.g of {
Fem => preOrPost (notB a.p) a.fsgen n.sdat ;
_ => preOrPost (notB a.p) a.msdat n.sdat
} ;
sacc = case n.g of {
Fem => preOrPost (notB a.p) a.fsacc n.sacc ;
Masc => case n.anim of {
Inanimate => preOrPost (notB a.p) a.msnom n.sacc ;
Animate => preOrPost (notB a.p) a.msgen n.sacc
} ;
Neut => preOrPost (notB a.p) a.nsnom n.sacc
} ;
sins = case n.g of {
Fem => preOrPost (notB a.p) a.fsins n.sins ;
_ => preOrPost (notB a.p) a.msins n.sins
} ;
sprep= case n.g of {
Fem => preOrPost (notB a.p) a.fsgen n.sprep ;
_ => preOrPost (notB a.p) a.msprep n.sprep
} ;
sloc = case n.g of {
Fem => preOrPost (notB a.p) a.fsgen n.sloc ;
_ => preOrPost (notB a.p) a.msprep n.sloc
} ;
sptv = case n.g of {
Fem => preOrPost (notB a.p) a.fsgen n.sptv ;
_ => preOrPost (notB a.p) a.msgen n.sptv
} ;
svoc = case n.g of {
Fem => preOrPost (notB a.p) a.fsnom n.svoc ;
Masc => preOrPost (notB a.p) a.msnom n.svoc ;
Neut => preOrPost (notB a.p) a.nsnom n.svoc
} ;
pnom = preOrPost (notB a.p) a.pnom n.pnom ;
pgen = preOrPost (notB a.p) a.pgen n.pgen ;
pdat = preOrPost (notB a.p) a.msins n.pdat ;
pacc = case n.anim of {
Inanimate => preOrPost (notB a.p) a.pnom n.pacc ;
Animate => preOrPost (notB a.p) a.pgen n.pacc
} ;
pins = preOrPost (notB a.p) a.pins n.pins ;
pprep= preOrPost (notB a.p) a.pgen n.sprep ;
anim=n.anim;
mayben=n.mayben ;
g=n.g
} ;
compoundN : N -> Str -> N
= \n, adv -> n ** {
snom = n.snom ++ adv;
sgen = n.sgen ++ adv;
sdat = n.sdat ++ adv;
sacc = n.sacc ++ adv;
sins = n.sins ++ adv;
sprep = n.sprep ++ adv;
sloc = n.sloc ++ adv;
sptv = n.sptv ++ adv;
svoc = n.svoc ++ adv;
pnom = n.pnom ++ adv;
pgen = n.pgen ++ adv;
pdat = n.pdat ++ adv;
pacc = n.pacc ++ adv;
pins = n.pins ++ adv;
pprep = n.pprep ++ adv
g=g ;
rel=(guessAdjectiveForms "") ;
rt=GenType
} ;
} ;
@@ -356,7 +296,9 @@ oper
mkN2 : N -> Prep -> N2
= \n, p -> lin N2 (mkFun n p) ;
mkN2 : Str -> Gender -> Animacy -> Str -> Prep -> N2
= \word, g, anim, zi, p -> lin N2 (mkFun (noMinorCases (Z.makeNoun word g anim (Z.parseIndex zi))) p) ;
= \word, g, anim, zi, p -> lin N2 (mkFun (noMinorCases (Z.makeNoun word g anim (guessAdjectiveForms "") GenType (Z.parseIndex zi))) p) ;
mkN2 : Str -> Gender -> Animacy -> Str -> NRelType -> Str -> Prep -> N2
= \word, g, anim, rel, rt, zi, p -> lin N2 (mkFun (noMinorCases (Z.makeNoun word g anim (guessAdjectiveForms rel) rt (Z.parseIndex zi))) p) ;
} ;
nullPrep : Prep = lin Prep {s=[] ; c=Gen ; neggen=False ; hasPrep=False} ;
@@ -365,7 +307,10 @@ oper
mkN3 : N -> Prep -> Prep -> N3
= \n, p2, p3 -> lin N3 (mkFun2 n p2 p3) ;
mkN3 : Str -> Gender -> Animacy -> Str -> Prep -> Prep -> N3
= \word, g, anim, zi, p2, p3 -> lin N3 (mkFun2 (noMinorCases (Z.makeNoun word g anim (Z.parseIndex zi))) p2 p3) ;
= \word, g, anim, zi, p2, p3 -> lin N3 (mkFun2 (noMinorCases (Z.makeNoun word g anim (guessAdjectiveForms "") GenType (Z.parseIndex zi))) p2 p3) ;
mkN3 : Str -> Gender -> Animacy -> Str -> NRelType -> Str -> Prep -> Prep -> N3
= \word, g, anim, rel, rt, zi, p2, p3 -> lin N3 (mkFun2 (noMinorCases (Z.makeNoun word g anim (guessAdjectiveForms rel) rt (Z.parseIndex zi))) p2 p3) ;
} ;
mkPN = overload {
@@ -374,20 +319,38 @@ oper
mkPN : N -> Str -> N -> PN
= \n1,link,n2 -> lin PN (mkCompoundN n1 link n2) ;
mkPN : Str -> PN
= \nom -> lin PN (guessNounForms nom) ;
= \nom -> lin PN (guessNounForms nom (guessAdjectiveForms "") GenType) ;
mkPN : Str -> Gender -> Animacy -> PN
= \nom, g, anim -> lin PN (guessLessNounForms nom g anim) ;
= \nom, g, anim -> lin PN (guessLessNounForms nom g anim (guessAdjectiveForms "") GenType) ;
mkPN : Str -> Gender -> Number -> Animacy -> PN
= \nom, g, n, anim -> lin PN (guessLessNounForms nom g anim) ;
= \nom, g, n, anim -> lin PN (guessLessNounForms nom g anim (guessAdjectiveForms "") GenType) ;
mkPN : Str -> Gender -> Animacy -> Z.ZNIndex -> PN
= \word, g, anim, z -> lin PN (noMinorCases (Z.makeNoun word g anim z)) ;
= \word, g, anim, z -> lin PN (noMinorCases (Z.makeNoun word g anim (guessAdjectiveForms "") GenType z)) ;
mkPN : Str -> Gender -> Animacy -> Str -> PN
= \word, g, anim, zi -> lin PN (noMinorCases (Z.makeNoun word g anim (Z.parseIndex zi))) ;
= \word, g, anim, zi -> lin PN (noMinorCases (Z.makeNoun word g anim (guessAdjectiveForms "") GenType (Z.parseIndex zi))) ;
mkPN : A -> PN -> PN
= \a, pn -> pn ** {
snom = (adjFormsAdjective a).s ! (gennum pn.g Sg) ! pn.anim ! Nom ++ pn.snom ;
sgen = (adjFormsAdjective a).s ! (gennum pn.g Sg) ! pn.anim ! Gen ++ pn.sgen ;
sdat = (adjFormsAdjective a).s ! (gennum pn.g Sg) ! pn.anim ! Dat ++ pn.sdat ;
sacc = (adjFormsAdjective a).s ! (gennum pn.g Sg) ! pn.anim ! Acc ++ pn.sacc ;
sins = (adjFormsAdjective a).s ! (gennum pn.g Sg) ! pn.anim ! Ins ++ pn.sins ;
sprep = (adjFormsAdjective a).s ! (gennum pn.g Sg) ! pn.anim ! Loc ++ pn.sprep ;
sloc = (adjFormsAdjective a).s ! (gennum pn.g Sg) ! pn.anim ! Loc ++ pn.sloc ;
sptv = (adjFormsAdjective a).s ! (gennum pn.g Sg) ! pn.anim ! Gen ++ pn.sptv ;
svoc = (adjFormsAdjective a).s ! (gennum pn.g Sg) ! pn.anim ! Nom ++ pn.svoc ;
pnom = (adjFormsAdjective a).s ! (gennum pn.g Pl) ! pn.anim ! Nom ++ pn.pnom ;
pgen = (adjFormsAdjective a).s ! (gennum pn.g Pl) ! pn.anim ! Gen ++ pn.pgen ;
pdat = (adjFormsAdjective a).s ! (gennum pn.g Pl) ! pn.anim ! Dat ++ pn.pdat ;
pacc = (adjFormsAdjective a).s ! (gennum pn.g Pl) ! pn.anim ! Acc ++ pn.pacc ;
pins = (adjFormsAdjective a).s ! (gennum pn.g Pl) ! pn.anim ! Ins ++ pn.pins ;
pprep = (adjFormsAdjective a).s ! (gennum pn.g Pl) ! pn.anim ! Loc ++ pn.pprep ;
} ;
} ;
mkGN = overload {
mkGN : Str -> GN
= \nom -> let nf = guessNounForms nom
= \nom -> let nf = guessNounForms nom (guessAdjectiveForms "") GenType
in lin GN {
s = (nounFormsNoun nf).s ! Sg ;
g = case nf.g of {
@@ -401,7 +364,7 @@ oper
Male => Masc ;
Female => Fem
} ;
nf = guessLessNounForms nom g Animate
nf = guessLessNounForms nom g Animate (guessAdjectiveForms "") GenType
in lin GN {
s = (nounFormsNoun nf).s ! Sg ;
g = sex
@@ -412,7 +375,7 @@ oper
Male => Masc ;
Female => Fem
} ;
nf = noMinorCases (Z.makeNoun nom g Animate z)
nf = noMinorCases (Z.makeNoun nom g Animate (guessAdjectiveForms "") GenType z)
in lin GN {
s = (nounFormsNoun nf).s ! Sg ;
g = sex
@@ -423,7 +386,7 @@ oper
Male => Masc ;
Female => Fem
} ;
nf = noMinorCases (Z.makeNoun nom g Animate (Z.parseIndex zi))
nf = noMinorCases (Z.makeNoun nom g Animate (guessAdjectiveForms "") GenType (Z.parseIndex zi))
in lin GN {
s = (nounFormsNoun nf).s ! Sg ;
g = sex
@@ -434,32 +397,32 @@ oper
mkSN : Str -> SN
= \nom -> lin SN {
s = table {
Male => (nounFormsNoun (guessLessNounForms nom Masc Animate)).s ! Sg ;
Female => (nounFormsNoun (guessLessNounForms nom Fem Animate)).s ! Sg
Male => (nounFormsNoun (guessLessNounForms nom Masc Animate (guessAdjectiveForms "") GenType)).s ! Sg ;
Female => (nounFormsNoun (guessLessNounForms nom Fem Animate (guessAdjectiveForms "") GenType)).s ! Sg
} ;
p = (nounFormsNoun (guessLessNounForms nom Masc Animate)).s ! Pl ;
p = (nounFormsNoun (guessLessNounForms nom Masc Animate (guessAdjectiveForms "") GenType)).s ! Pl ;
} ;
mkSN : Str -> Str -> SN
= \male,female -> lin SN {
s = table {
Male => (nounFormsNoun (guessLessNounForms male Masc Animate)).s ! Sg ;
Female => (nounFormsNoun (guessLessNounForms female Fem Animate)).s ! Sg
Male => (nounFormsNoun (guessLessNounForms male Masc Animate (guessAdjectiveForms "") GenType)).s ! Sg ;
Female => (nounFormsNoun (guessLessNounForms female Fem Animate (guessAdjectiveForms "") GenType)).s ! Sg
} ;
p = (nounFormsNoun (guessLessNounForms male Masc Animate)).s ! Pl ;
p = (nounFormsNoun (guessLessNounForms male Masc Animate (guessAdjectiveForms "") GenType)).s ! Pl ;
} ;
mkSN : Str -> Z.ZNIndex -> Str -> Z.ZNIndex -> SN
= \male,zm,female,zf -> lin SN {
s = table {
Male => (nounFormsNoun (noMinorCases (Z.makeNoun male Masc Animate zm))).s ! Sg ;
Female => (nounFormsNoun (noMinorCases (Z.makeNoun female Masc Animate zf))).s ! Sg
Male => (nounFormsNoun (noMinorCases (Z.makeNoun male Masc Animate (guessAdjectiveForms "") GenType zm))).s ! Sg ;
Female => (nounFormsNoun (noMinorCases (Z.makeNoun female Masc Animate (guessAdjectiveForms "") GenType zf))).s ! Sg
} ;
p = (nounFormsNoun (noMinorCases (Z.makeNoun male Masc Animate zm))).s ! Pl ;
p = (nounFormsNoun (noMinorCases (Z.makeNoun male Masc Animate (guessAdjectiveForms "") GenType zm))).s ! Pl ;
} ;
} ;
mkLN = overload {
mkLN : Str -> LN
= \nom -> let nf = guessNounForms nom
= \nom -> let nf = guessNounForms nom (guessAdjectiveForms "") GenType
in lin LN {
s = (nounFormsNoun nf).s ! Sg ;
anim = nf.anim ;
@@ -469,7 +432,7 @@ oper
} ;
mkLN : Str -> Gender -> LN
= \nom, g ->
let nf = guessLessNounForms nom g Animate
let nf = guessLessNounForms nom g Animate (guessAdjectiveForms "") GenType
in lin LN {
s = (nounFormsNoun nf).s ! Sg ;
anim = nf.anim ;
@@ -479,7 +442,7 @@ oper
} ;
mkLN : Str -> Gender -> Number -> LN
= \nom, g, n ->
let nf = guessLessNounForms nom g Animate
let nf = guessLessNounForms nom g Animate (guessAdjectiveForms "") GenType
in lin LN {
s = (nounFormsNoun nf).s ! n ;
anim = nf.anim ;
@@ -489,7 +452,7 @@ oper
} ;
mkLN : Str -> Gender -> Number -> Z.ZNIndex -> LN
= \nom, g, n, z ->
let nf = noMinorCases (Z.makeNoun nom g Animate z)
let nf = noMinorCases (Z.makeNoun nom g Animate (guessAdjectiveForms "") GenType z)
in lin LN {
s = (nounFormsNoun nf).s ! n ;
anim = nf.anim ;
@@ -499,7 +462,7 @@ oper
} ;
mkLN : Str -> Gender -> Number -> Str -> LN
= \nom, g, n, zi ->
let nf = noMinorCases (Z.makeNoun nom g Animate (Z.parseIndex zi))
let nf = noMinorCases (Z.makeNoun nom g Animate (guessAdjectiveForms "") GenType (Z.parseIndex zi))
in lin LN {
s = (nounFormsNoun nf).s ! n ;
anim = nf.anim ;

View File

@@ -33,6 +33,9 @@ param
CopulaType = NomCopula | InsCopula | EllCopula | ExplicitCopula ;
SpecialFuture = NormalFuture | BeFuture | BeFuture2 | CanFuture | WantFuture | NullFuture ;
DetType = NormalDet | EmptyDef | EmptyIndef ; -- artificial parameter to side-step DetNP parsing issues
NRelType = GenType | AdjType ;
AForm ;
oper
MaybeAgr = Maybe Agr ;
MaybeNumber = Maybe Number ;
@@ -60,7 +63,9 @@ oper
snom, sgen, sdat, sacc, sins, sprep,
pnom, pgen, pdat, pacc, pins, pprep : Str ;
g : Gender ;
anim : Animacy
anim : Animacy ;
rel : AdjForms ;
rt : NRelType ;
} ;
AdjForms : Type = {

View File

@@ -1,3 +1,4 @@
--# -path=.:../abstract:../common
resource ResRus = ParamRus ** open Prelude, InflectionRus, Maybe in {
flags coding=utf8 ; optimize=all ;
@@ -31,7 +32,9 @@ oper
pnom, pgen, pdat, pacc, pins, pprep : Str ;
g : Gender ;
mayben : MaybeNumber ;
anim : Animacy
anim : Animacy ;
rel : AdjForms ;
rt : NRelType ;
} ;
Noun2Forms = NounForms ** {c2 : ComplementCase} ;
Noun3Forms = NounForms ** {c2,c3 : ComplementCase} ;
@@ -43,7 +46,9 @@ oper
s : Number => Case => Str ;
g : Gender ;
mayben : MaybeNumber ; -- used to control dependent words
anim : Animacy
anim : Animacy ;
rel : AdjForms ;
rt : NRelType ;
} ;
NounPhrase = {
@@ -80,61 +85,63 @@ oper
} ;
g = forms.g ;
mayben=forms.mayben ;
anim = forms.anim
anim = forms.anim ;
rel = forms.rel ;
rt = forms.rt ;
} ;
guessNounForms : Str -> NounForms
= \word ->
guessNounForms : Str -> AdjForms -> NRelType -> NounForms
= \word, rel, rt ->
let nfb : NounFormsBase =
case word of {
_ + "уть" => makeNoun word Masc Inanimate (ZN 8 No B NoC) ;
_ + "ий" => makeNoun word Masc Inanimate (ZN 7 No A NoC) ;
_ + "ия" => makeNoun word Fem Inanimate (ZN 7 No A NoC) ;
_ + "ие" => makeNoun word Neut Inanimate (ZN 7 No A NoC) ;
_ + "ье" => makeNoun word Neut Inanimate (ZN 6 Ast A NoC) ;
_ + "тель" => makeNoun word Masc Inanimate (ZN 2 No A NoC) ;
_ + "ь" => makeNoun word Fem Inanimate (ZN 8 No A NoC) ;
_ + "и" => makeNoun word Neut Inanimate ZN0 ;
_ + #consonant + ("к"|"х"|"г") + "а" => makeNoun word Fem Inanimate (ZN 3 Ast A NoC) ;
_ + ("к" | "х" | "г") => makeNoun word Masc Inanimate (ZN 3 No A NoC) ;
_ + ("к" | "х" | "г") + "а" => makeNoun word Fem Inanimate (ZN 3 No A NoC) ;
_ + "ца" => makeNoun word Fem Animate (ZN 5 No A NoC) ;
_ + "й" => makeNoun word Masc Inanimate (ZN 6 No A NoC) ;
_ + ("ж" | "ш" | "ч" | "щ") => makeNoun word Masc Inanimate (ZN 4 No A NoC) ;
_ + "ша" => makeNoun word Fem Animate (ZN 4 No A NoC) ;
_ + ("ж" | "ш" | "ч" | "щ") + "а" => makeNoun word Fem Inanimate (ZN 4 No A NoC) ;
_ + "ц" => makeNoun word Masc Inanimate (ZN 5 Ast A NoC) ;
_ + "о" => makeNoun word Neut Inanimate (ZN 1 No A NoC) ;
_ + "а" => makeNoun word Fem Inanimate (ZN 1 No A NoC) ;
_ => makeNoun word Masc Inanimate (ZN 1 No A NoC)
_ + "уть" => makeNoun word Masc Inanimate rel rt (ZN 8 No B NoC) ;
_ + "ий" => makeNoun word Masc Inanimate rel rt (ZN 7 No A NoC) ;
_ + "ия" => makeNoun word Fem Inanimate rel rt (ZN 7 No A NoC) ;
_ + "ие" => makeNoun word Neut Inanimate rel rt (ZN 7 No A NoC) ;
_ + "ье" => makeNoun word Neut Inanimate rel rt (ZN 6 Ast A NoC) ;
_ + "тель" => makeNoun word Masc Inanimate rel rt (ZN 2 No A NoC) ;
_ + "ь" => makeNoun word Fem Inanimate rel rt (ZN 8 No A NoC) ;
_ + "и" => makeNoun word Neut Inanimate rel rt ZN0 ;
_ + #consonant + ("к"|"х"|"г") + "а" => makeNoun word Fem Inanimate rel rt (ZN 3 Ast A NoC) ;
_ + ("к" | "х" | "г") => makeNoun word Masc Inanimate rel rt (ZN 3 No A NoC) ;
_ + ("к" | "х" | "г") + "а" => makeNoun word Fem Inanimate rel rt (ZN 3 No A NoC) ;
_ + "ца" => makeNoun word Fem Animate rel rt (ZN 5 No A NoC) ;
_ + "й" => makeNoun word Masc Inanimate rel rt (ZN 6 No A NoC) ;
_ + ("ж" | "ш" | "ч" | "щ") => makeNoun word Masc Inanimate rel rt (ZN 4 No A NoC) ;
_ + "ша" => makeNoun word Fem Animate rel rt (ZN 4 No A NoC) ;
_ + ("ж" | "ш" | "ч" | "щ") + "а" => makeNoun word Fem Inanimate rel rt (ZN 4 No A NoC) ;
_ + "ц" => makeNoun word Masc Inanimate rel rt (ZN 5 Ast A NoC) ;
_ + "о" => makeNoun word Neut Inanimate rel rt (ZN 1 No A NoC) ;
_ + "а" => makeNoun word Fem Inanimate rel rt (ZN 1 No A NoC) ;
_ => makeNoun word Masc Inanimate rel rt (ZN 1 No A NoC)
} in
noMinorCases nfb ;
guessLessNounForms : Str -> Gender -> Animacy -> NounForms
= \word, g, anim ->
guessLessNounForms : Str -> Gender -> Animacy -> AdjForms -> NRelType -> NounForms
= \word, g, anim, rel, rt ->
let nfb : NounFormsBase =
case word of {
_ + "уть" => makeNoun word g anim (ZN 8 No B NoC) ;
_ + "ий" => makeNoun word g anim (ZN 7 No A NoC) ;
_ + "ия" => makeNoun word g anim (ZN 7 No A NoC) ;
_ + "ие" => makeNoun word g anim (ZN 7 No A NoC) ;
_ + "ье" => makeNoun word g anim (ZN 6 Ast A NoC) ;
_ + "тель" => makeNoun word g anim (ZN 2 No A NoC) ;
_ + "ь" => makeNoun word g anim
_ + "уть" => makeNoun word g anim rel rt (ZN 8 No B NoC) ;
_ + "ий" => makeNoun word g anim rel rt (ZN 7 No A NoC) ;
_ + "ия" => makeNoun word g anim rel rt (ZN 7 No A NoC) ;
_ + "ие" => makeNoun word g anim rel rt (ZN 7 No A NoC) ;
_ + "ье" => makeNoun word g anim rel rt (ZN 6 Ast A NoC) ;
_ + "тель" => makeNoun word g anim rel rt (ZN 2 No A NoC) ;
_ + "ь" => makeNoun word g anim rel rt
(case g of {Fem => (ZN 8 No A NoC); _ => (ZN 2 No A NoC)});
_ + "и" => makeNoun word g anim ZN0 ;
_ + #consonant + ("к"|"х"|"г") + "а" => makeNoun word g anim (ZN 3 Ast A NoC) ;
_ + ("к" | "х" | "г") => makeNoun word g anim (ZN 3 No A NoC) ;
_ + ("к" | "х" | "г") + "а" => makeNoun word g anim (ZN 3 No A NoC) ;
_ + "ца" => makeNoun word g anim (ZN 5 No A NoC) ;
_ + "й" => makeNoun word g anim (ZN 6 No A NoC) ;
_ + ("ж" | "ш" | "ч" | "щ") => makeNoun word g anim (ZN 4 No A NoC) ;
_ + "ша" => makeNoun word g anim (ZN 4 No A NoC) ;
_ + ("ж" | "ш" | "ч" | "щ") + "а" => makeNoun word g anim (ZN 4 No A NoC) ;
_ + "ц" => makeNoun word g anim (ZN 5 Ast A NoC) ;
_ + "о" => makeNoun word g anim (ZN 1 No A NoC) ;
_ + "а" => makeNoun word g anim (ZN 1 No A NoC) ;
_ => makeNoun word g anim (ZN 1 No A NoC)
_ + "и" => makeNoun word g anim rel rt ZN0 ;
_ + #consonant + ("к"|"х"|"г") + "а" => makeNoun word g anim rel rt (ZN 3 Ast A NoC) ;
_ + ("к" | "х" | "г") => makeNoun word g anim rel rt (ZN 3 No A NoC) ;
_ + ("к" | "х" | "г") + "а" => makeNoun word g anim rel rt (ZN 3 No A NoC) ;
_ + "ца" => makeNoun word g anim rel rt (ZN 5 No A NoC) ;
_ + "й" => makeNoun word g anim rel rt (ZN 6 No A NoC) ;
_ + ("ж" | "ш" | "ч" | "щ") => makeNoun word g anim rel rt (ZN 4 No A NoC) ;
_ + "ша" => makeNoun word g anim rel rt (ZN 4 No A NoC) ;
_ + ("ж" | "ш" | "ч" | "щ") + "а" => makeNoun word g anim rel rt (ZN 4 No A NoC) ;
_ + "ц" => makeNoun word g anim rel rt (ZN 5 Ast A NoC) ;
_ + "о" => makeNoun word g anim rel rt (ZN 1 No A NoC) ;
_ + "а" => makeNoun word g anim rel rt (ZN 1 No A NoC) ;
_ => makeNoun word g anim rel rt (ZN 1 No A NoC)
} in
noMinorCases nfb ;
@@ -146,7 +153,8 @@ oper
sloc = base.sprep ;
sptv = base.sgen ;
svoc = base.snom ;
mayben = BothSgPl
mayben = BothSgPl ;
rt = base.rt ;
} ;
mkNAltPl : NounForms -> NounForms -> NounForms
@@ -219,9 +227,10 @@ oper
pdat = n1.pdat ++ l ++ n2.pdat ;
pacc = n1.pacc ++ l ++ n2.pacc ;
pins = n1.pins ++ l ++ n2.pins ;
pprep = n1.pprep ++ l ++ n2.pprep
pprep = n1.pprep ++ l ++ n2.pprep ;
} ;
---------------------------
-- Adjectives -- Прилагательные
@@ -496,6 +505,8 @@ oper
sloc = af.fsgen ;
sptv = af.fsgen ;
svoc = af.fsnom ;
rel = af ;
rt = GenType ;
g=g ;
mayben=BothSgPl ;
anim=anim
@@ -516,6 +527,8 @@ oper
sloc = af.msprep ;
sptv = af.msgen ;
svoc = af.msnom ;
rel = af ;
rt = GenType ;
g=g ;
mayben=BothSgPl ;
anim=anim
@@ -536,6 +549,8 @@ oper
sloc = af.msprep ;
sptv = af.msgen ;
svoc = af.nsnom ;
rel = af ;
rt = GenType ;
g=g ;
mayben=BothSgPl ;
anim=anim
@@ -1319,7 +1334,9 @@ oper
pvoc=n.s ! Pl ! VocRus ;
g=n.g ;
mayben=n.mayben ;
anim=n.anim
anim=n.anim ;
rel=n.rel ;
rt =n.rt ;
} ;
caseTableToRecord : (Case => Str) -> Agr -> Animacy -> IPronounForms
@@ -1465,7 +1482,7 @@ oper
param DForm = unit | teen | ten | hund ;
param Place = attr | indep ;
oper
mille : Noun = nounFormsNoun ((guessNounForms "тысяча") ** {sins=variants {"тысячей" ; "тысячью"}});
mille : Noun = nounFormsNoun ((guessNounForms "тысяча" (doGuessAdjectiveForms "тысячный") AdjType) ** {sins=variants {"тысячей" ; "тысячью"}});
ith_forms : Str -> AdjForms
= \s -> {

View File

@@ -142,7 +142,7 @@ lin
} ;
only_Predet = (adjFormsAdjective (pronToAdj only_Pron)) ** {size=Num1} ;
most_Predet = (makeAdjectiveFromNoun (nounFormsNoun (guessNounForms "большинство"))) ** {size=Num5} ;
most_Predet = (makeAdjectiveFromNoun (nounFormsNoun (guessNounForms "большинство" (guessAdjectiveForms "") GenType))) ** {size=Num5} ;
all_Predet = (adjFormsAdjective (pronToAdj all_Pron)) ** {size=NumAll};
not_Predet = (adjFormsAdjective (mkA "не" "" "0")) ** {size=Num1} ;