Latvian: a lot of code refactoring

This commit is contained in:
normundsg
2013-06-21 12:04:26 +00:00
parent e720d47700
commit e7b22ac609
11 changed files with 316 additions and 302 deletions

View File

@@ -61,20 +61,11 @@ lincat
Pron = Pronoun ;
Det = {
s : Gender => Case => Str ;
num : Number ;
defin : Definiteness ;
pol : Polarity
} ;
Det = { s : Gender => Case => Str ; num : Number ; defin : Definiteness ; pol : Polarity } ;
Predet = { s : Gender => Str } ;
Quant = {
s : Gender => Number => Case => Str ;
defin : Definiteness ;
pol : Polarity
} ;
Quant = { s : Gender => Number => Case => Str ; defin : Definiteness ; pol : Polarity } ;
Num = { s : Gender => Case => Str ; num : Number ; hasCard : Bool } ;
@@ -100,13 +91,13 @@ lincat
V, VV, VQ, VA = Verb ;
V2, V2V, V2Q, V2A = Verb ** { focus : Preposition } ;
V2, V2V, V2Q, V2A = Verb ** { rightVal : Preposition } ;
V3 = Verb ** { focus1, focus2 : Preposition } ;
V3 = Verb ** { rightVal1, rightVal2 : Preposition } ;
VS = Verb ** { conj : Subj } ;
V2S = Verb ** { conj : Subj ; focus : Preposition } ;
V2S = Verb ** { conj : Subj ; rightVal : Preposition } ;
A = Adjective ;

View File

@@ -80,7 +80,7 @@ lin
s = \\agrAgr =>
temp.s ++
-- TODO: verb moods other than Ind
buildVerb vp.v (Ind temp.a temp.t) pol.p agrAgr.agr agrAgr.pol vp.agr.focus ++
buildVerb vp.v (Ind temp.a temp.t) pol.p agrAgr.agr agrAgr.pol vp.rightPol ++
vp.compl ! agrAgr.agr
} ;

View File

@@ -18,7 +18,7 @@ lin
let agr = AgrP3 Sg Masc
in {
s = \\mood,pol =>
buildVerb vp.v mood pol agr Pos vp.agr.focus ++ -- Verb
buildVerb vp.v mood pol agr Pos vp.rightPol ++ -- Verb
vp.compl ! agr -- Object(s), complements, adverbial modifiers
} ;
@@ -26,7 +26,7 @@ lin
let agr = AgrP3 Sg Masc
in {
s = \\mood,pol =>
buildVerb vp.v mood pol agr Pos vp.agr.focus ++
buildVerb vp.v mood pol agr Pos vp.rightPol ++
vp.compl ! agr
} ;
@@ -53,7 +53,7 @@ lin
;
ImpP3 np vp = {
s = "lai" ++ np.s ! Nom ++ buildVerb vp.v (Ind Simul Pres) Pos np.agr np.pol vp.agr.focus ++ vp.compl ! np.agr ;
s = "lai" ++ np.s ! Nom ++ buildVerb vp.v (Ind Simul Pres) Pos np.agr np.pol vp.rightPol ++ vp.compl ! np.agr ;
} ;
-- FIXME: placeholder

View File

@@ -1,12 +1,12 @@
--# -path=.:abstract:common:prelude
resource ParadigmsLav = open
ResLav,
CatLav,
ParadigmsVerbsLav,
ParadigmsNounsLav,
ParadigmsPronounsLav,
ParadigmsAdjectivesLav,
ParadigmsVerbsLav,
ResLav,
CatLav,
Prelude,
Predef
in {
@@ -15,8 +15,10 @@ flags coding = utf8 ;
oper
-- Parameters
masculine : Gender = Masc ;
feminine : Gender = Fem ;
feminine : Gender = Fem ;
singular : Number = Sg ;
plural : Number = Pl ;
@@ -30,134 +32,137 @@ oper
second_conjugation : Conjugation = C2 ;
third_conjugation : Conjugation = C3 ;
active_voice : Voice = Act ;
active_voice : Voice = Act ;
passive_voice : Voice = Pass ;
-- Nouns
mkN = overload {
mkN : (lemma : Str) -> N = \l -> lin N (mkNoun l) ;
mkN : (lemma : Str) -> Bool -> N = \l,p -> lin N (mkNounByPal l p) ;
mkN : (lemma : Str) -> Gender -> N = \l,g -> lin N (mkNounByGend l g) ;
mkN : (lemma : Str) -> Declension -> N = \l,d -> lin N (mkNounByDecl l d) ;
mkN : (lemma : Str) -> Gender -> Bool -> N = \l,g,p -> lin N (mkNounByGendPal l g p) ;
mkN : (lemma : Str) -> Declension -> Bool -> N = \l,d,p -> lin N (mkNounByDeclPal l d p) ;
mkN : (lemma : Str) -> Gender -> Declension -> N = \l,g,d -> lin N (mkNounByGendDecl l g d) ;
mkN : (lemma : Str) -> Gender -> Declension -> Bool -> N = \l,g,d,p ->
lin N (mkNounByGendDeclPal l g d p) ;
mkN : (lemma : Str) -> N = \l -> lin N (mkNoun l) ;
mkN : (lemma : Str) -> Bool -> N = \l,p -> lin N (mkNounByPal l p) ;
mkN : (lemma : Str) -> Gender -> N = \l,g -> lin N (mkNounByGend l g) ;
mkN : (lemma : Str) -> Declension -> N = \l,d -> lin N (mkNounByDecl l d) ;
mkN : (lemma : Str) -> Gender -> Bool -> N = \l,g,p -> lin N (mkNounByGendPal l g p) ;
mkN : (lemma : Str) -> Declension -> Bool -> N = \l,d,p -> lin N (mkNounByDeclPal l d p) ;
mkN : (lemma : Str) -> Gender -> Declension -> N = \l,g,d -> lin N (mkNounByGendDecl l g d) ;
mkN : (lemma : Str) -> Gender -> Declension -> Bool -> N = \l,g,d,p -> lin N (mkNounByGendDeclPal l g d p) ;
} ;
mkPN = overload {
mkN : (lemma : Str) -> PN = \l -> lin PN (mkProperNoun l Sg) ;
mkN : (lemma : Str) -> PN = \l -> lin PN (mkProperNoun l Sg) ;
mkN : (lemma : Str) -> Number -> PN = \l,n -> lin PN (mkProperNoun l n) ;
} ;
mkN2 = overload {
mkN2 : N -> Preposition -> N2 = \n,p -> lin N2 n ** { prep = p ; isPre = True } ;
mkN2 : N -> Preposition -> Bool -> N2 = \n,p,pp -> lin N2 n ** { prep = p ; isPre = pp } ;
mkN2 : N -> Prep -> N2 = \n,p -> lin N2 (n ** {prep = p ; isPre = True}) ;
mkN2 : N -> Prep -> Bool -> N2 = \n,p,pos -> lin N2 (n ** {prep = p ; isPre = pos}) ;
} ;
mkN3 : N -> Preposition -> Preposition -> N3 = \n,p1,p2 ->
lin N3 n ** { prep1 = p1 ; prep2 = p2 ; isPre1 = False ; isPre2 = False } ;
mkN3 : N -> Prep -> Prep -> N3 = \n,p1,p2 ->
lin N3 (n ** {prep1 = p1 ; prep2 = p2 ; isPre1 = False ; isPre2 = False}) ;
-- Adjectives
mkA = overload {
mkA : (lemma : Str) -> A = \s -> lin A (mkAdjective s) ;
mkA : (lemma : Str) -> A = \s -> lin A (mkAdjective s) ;
mkA : (lemma : Str) -> AType -> A = \s,t -> lin A (mkAdjectiveByType s t) ;
-- TODO: nav forši, ka jānorāda Voice, bet kā lai aptiet?
-- TODO: drīzāk jānorāda Str (divdabja forma) + Voice - pārējais iekšēji (auto)
-- Turklāt Adj f-cijā iespējams būtu ok, ja pa tiešo izsauktu mkAdjective?!
-- Tomēr diez vai: IsUsi...
-- mkA2 gadījumā: vai Voice var noteikt pēc obj_Prep? Diez vai...
mkA : (v : Verb) -> Voice -> A = \v,p -> lin A (mkAdjective_Participle v p) ;
mkA : (v : V) -> Voice -> A = \v,p -> lin A (mkAdjective_Participle v p) ;
} ;
AS, AV = A ;
mkAS : A -> AS = \a -> lin A a ;
mkAV : A -> AV = \a -> lin A a ;
mkA2 : A -> Prep -> A2 = \a,p -> lin A2 (a ** { prep = p }) ;
mkAS : A -> AS = \a -> lin A a ;
mkAV : A -> AV = \a -> lin A a ;
mkA2 : A -> Prep -> A2 = \a,p -> lin A2 (a ** {prep = p}) ;
A2S, A2V = A2 ;
mkA2S : A -> Prep -> A2S =\a,p -> lin A2 (a ** { prep = p }) ;
mkA2V : A -> Prep -> A2V = \a,p -> lin A2 (a ** { prep = p }) ;
mkA2S : A -> Prep -> A2S = \a,p -> lin A2 (a ** {prep = p}) ;
mkA2V : A -> Prep -> A2V = \a,p -> lin A2 (a ** {prep = p}) ;
-- Verbs
mkV = overload {
mkV : Str -> V = \s -> lin V (mkVerb_Irreg s Nom) ;
mkV : Str -> V = \s -> lin V (mkVerb_Irreg s Nom) ;
mkV : Str -> Case -> V = \s,c -> lin V (mkVerb_Irreg s c) ;
mkV : Str -> Conjugation -> V = \s,c -> lin V (mkVerb s c Nom) ;
mkV : Str -> Conjugation -> V = \s,conj -> lin V (mkVerb s conj Nom) ;
mkV : Str -> Conjugation -> Case -> V = \s,conj,c -> lin V (mkVerb s conj c) ;
mkV : Str -> Str -> Str -> V = \s1,s2,s3 -> lin V (mkVerbC1 s1 s2 s3 Nom) ;
mkV : Str -> Str -> Str -> V = \s1,s2,s3 -> lin V (mkVerbC1 s1 s2 s3 Nom) ;
mkV : Str -> Str -> Str -> Case -> V = \s1,s2,s3,c -> lin V (mkVerbC1 s1 s2 s3 c) ;
} ;
mkV2 = overload {
mkV2 : V -> V2 = \v -> lin V2 v ** { focus = acc_Prep } ;
mkV2 : V -> Preposition -> V2 = \v,p -> lin V2 v ** { focus = p } ;
--mkV2 : V -> V2 = \v -> lin V2 (v ** {rightVal = acc_Prep}) ;
--mkV2 : V -> Prep -> V2 = \v,p -> lin V2 (v ** {rightVal = p}) ;
mkV2 : V -> V2 = \v -> lin V2 {s = v.s ; leftVal = v.leftVal ; rightVal = acc_Prep} ;
mkV2 : V -> Prep -> V2 = \v,p -> lin V2 {s = v.s ; leftVal = v.leftVal ; rightVal = p} ;
} ;
mkVS = overload {
mkVS : V -> Subj -> VS = \v,c -> lin VS v ** { conj = c ; topic = Nom } ;
mkVS : V -> Subj -> Case -> VS = \v,c,s -> lin VS v ** { conj = c ; topic = s } ;
mkVS : V -> Subj -> VS = \v,c -> lin VS {s = v.s ; leftVal = Nom ; conj = c} ;
mkVS : V -> Subj -> Case -> VS = \v,c,s -> lin VS {s = v.s ; leftVal = s ; conj = c} ;
} ;
mkVQ = overload {
mkVQ : V -> VQ = \v -> lin VQ v ** { topic = Nom } ;
mkVQ : V -> Case -> VQ = \v,c -> lin VQ v ** { topic = c } ;
mkVQ : V -> VQ = \v -> lin VQ {s = v.s ; leftVal = Nom} ;
mkVQ : V -> Case -> VQ = \v,c -> lin VQ {s = v.s ; leftVal = c} ;
} ;
mkVV = overload {
mkVV : V -> VV = \v -> lin VV v ** { topic = Nom } ;
mkVV : V -> Case -> VV = \v,c -> lin VV v ** { topic = c } ;
mkVV : V -> VV = \v -> lin VV {s = v.s ; leftVal = Nom} ;
mkVV : V -> Case -> VV = \v,c -> lin VV {s = v.s ; leftVal = c} ;
} ;
mkV3 = overload {
mkV3 : V -> Preposition -> Preposition -> V3 = \v,p1,p2 ->
lin V3 v ** { topic = Nom ; focus1 = p1 ; focus2 = p2 } ;
mkV3 : V -> Case -> Preposition -> Preposition -> V3 = \v,c,p1,p2 ->
lin V3 v ** { topic = c ; focus1 = p1 ; focus2 = p2 } ;
} ;
mkVA : V -> VA = \v -> lin VA v ;
mkV2S : V -> Subj -> Preposition -> V2S = \v,c,o -> lin V2S v ** { conj = c ; focus = o } ;
mkV2A : V -> Preposition -> V2A = \v,o -> lin V2A v ** { focus = o } ;
mkV2Q : V -> Preposition -> V2Q = \v,o -> lin V2Q v ** { focus = o } ;
mkV2V : V -> Preposition -> V2V = \v,o -> lin V2V v ** { focus = o } ;
mkCAdv : Str -> Str -> Degree -> CAdv = \s,p,d -> lin CAdv { s = s ; prep = p ; deg = d } ;
mkV3 = overload {
mkV3 : V -> V3 = \v -> lin V3 (v ** {rightVal1 = acc_Prep ; rightVal2 = dat_Prep}) ;
mkV3 : V -> Prep -> Prep -> V3 = \v,p1,p2 -> lin V3 (v ** {rightVal1 = p1 ; rightVal2 = p2}) ;
} ;
mkVA : V -> VA = \v -> lin VA v ;
mkV2A : V -> Prep -> V2A = \v,p -> lin V2A (v ** {rightVal = p}) ;
mkV2Q : V -> Prep -> V2Q = \v,p -> lin V2Q (v ** {rightVal = p}) ;
mkV2V : V -> Prep -> V2V = \v,p -> lin V2V (v ** {rightVal = p}) ;
mkV2S : V -> Subj -> Prep -> V2S = \v,c,p -> lin V2S (v ** {conj = c ; rightVal = p}) ;
-- Prepositions
mkPrep = overload {
mkPrep : Str -> Case -> Case -> Preposition = \prep,sg,pl ->
lin Prep { s = prep ; c = table { Sg => sg ; Pl => pl } } ;
mkPrep : Case -> Preposition = \c -> lin Prep { s = [] ; c = table { _ => c } } ;
mkPrep : Str -> Case -> Case -> Prep = \p,sg,pl -> lin Prep {s = p ; c = table {Sg => sg ; Pl => pl}} ;
mkPrep : Case -> Prep = \c -> lin Prep {s = [] ; c = \\_ => c} ;
} ;
-- empty fake prepositions for valences
-- rections that are expressed by simple cases without any prepositions
nom_Prep = mkPrep Nom ;
gen_Prep = mkPrep Gen ;
dat_Prep = mkPrep Dat ;
acc_Prep = mkPrep Acc ;
loc_Prep = mkPrep Loc ;
nom_Prep : Prep = mkPrep Nom ;
gen_Prep : Prep = mkPrep Gen ;
dat_Prep : Prep = mkPrep Dat ;
acc_Prep : Prep = mkPrep Acc ;
loc_Prep : Prep = mkPrep Loc ;
-- Adverbs
mkAdv : Str -> Adv = \x -> lin Adv (ss x) ;
mkAdV : Str -> AdV = \x -> lin AdV (ss x) ;
mkAdA : Str -> AdA = \x -> lin AdA (ss x) ;
mkAdN : Str -> AdN = \x -> lin AdN (ss x) ;
mkCAdv : Str -> Str -> Degree -> CAdv = \s,p,d -> lin CAdv {s = s ; prep = p ; deg = d} ;
-- Conjunctions
mkConj = overload {
mkConj : Str -> Conj = \y -> mk2Conj [] y Pl ;
mkConj : Str -> Number -> Conj = \y,n -> mk2Conj [] y n ;
mkConj : Str -> Str -> Conj = \x,y -> mk2Conj x y Pl ;
mkConj : Str -> Conj = \c -> mk2Conj [] c Pl ;
mkConj : Str -> Number -> Conj = \c,n -> mk2Conj [] c n ;
mkConj : Str -> Str -> Conj = \c1,c2 -> mk2Conj c1 c2 Pl ;
mkConj : Str -> Str -> Number -> Conj = mk2Conj ;
} ;
mk2Conj : Str -> Str -> Number -> Conj = \x,y,n -> lin Conj (sd2 x y ** { num = n }) ;
mk2Conj : Str -> Str -> Number -> Conj = \c1,c2,n -> lin Conj (sd2 c1 c2 ** {num = n}) ;
viens = mkNumSpec "viens" "pirmais" "vien" "" Sg ;
-- Numerals: need review (TODO)
mkNumReg : Str -> Str -> Number -> { s : DForm => CardOrd => Gender => Case => Str } =
\pieci,piektais,n -> mkNumSpec pieci piektais (cutStem pieci) (cutStem pieci) n ;
@@ -193,6 +198,8 @@ oper
}
} ;
viens = mkNumSpec "viens" "pirmais" "vien" "" Sg ;
simts : CardOrd => Gender => Number => Case => Str =
let
card = mkNoun_D1 "simts" ;

View File

@@ -9,35 +9,35 @@ oper
Verb_TMP : Type = {s : VForm => Str} ;
-- Second and third conjugations
mkVerb : Str -> Conjugation -> Case -> Verb = \lemma,conj,topic -> {
mkVerb : Str -> Conjugation -> Case -> Verb = \lemma,conj,leftVal -> {
s = table {
Pos => (mkVerb_Pos lemma conj).s ;
Neg => (filter_Neg (mkVerb_Pos ("ne"+lemma) conj)).s
} ;
topic = topic
leftVal = leftVal
} ;
-- First conjugation
mkVerbC1 : Str -> Str -> Str -> Case -> Verb = \lemma,lemma2,lemma3,topic -> {
mkVerbC1 : Str -> Str -> Str -> Case -> Verb = \lemma,lemma2,lemma3,leftVal -> {
s = table {
Pos => (mkVerbC1_Pos lemma lemma2 lemma3).s ;
Neg => (filter_Neg (mkVerbC1_Pos ("ne"+lemma) ("ne"+lemma2) ("ne"+lemma3))).s
} ;
topic = topic
leftVal = leftVal
} ;
mkVerb_Pos : Str -> Conjugation -> Verb_TMP = \lemma,conj ->
case lemma of {
-- TODO: "ir" =>
s + ("t") => mkRegVerb lemma conj ;
s + ("ties") => mkReflVerb lemma conj
-- TODO: "ir"
s + ("ties") => mkReflVerb lemma conj ;
_ => mkRegVerb lemma conj
} ;
mkVerbC1_Pos : Str -> Str -> Str -> Verb_TMP = \lemma,lemma2,lemma3 ->
case lemma of {
-- TODO: "ir" =>
s + ("t") => mkVerb_C1 lemma lemma2 lemma3 ;
s + ("ties") => mkVerb_C1_Refl lemma lemma2 lemma3
-- TODO: "ir"
s + ("ties") => mkVerb_C1_Refl lemma lemma2 lemma3 ;
_ => mkVerb_C1 lemma lemma2 lemma3
} ;
mkRegVerb : Str -> Conjugation -> Verb_TMP = \lemma,conj ->
@@ -344,19 +344,19 @@ oper
}
} ;
mkVerb_Irreg : Str -> Case -> Verb = \lemma,topic ->
mkVerb_Irreg : Str -> Case -> Verb = \lemma,leftVal ->
case lemma of {
"būt" => mkVerb_Irreg_Be topic ;
"iet" => mkVerb_Irreg_Go topic ;
#prefix + "iet" => mkVerb_Irreg_Go_Prefix (Predef.tk 3 lemma) topic ;
"gulēt" => mkVerb_Irreg_Sleep topic
"būt" => mkVerb_Irreg_Be leftVal ;
"iet" => mkVerb_Irreg_Go leftVal ;
#prefix + "iet" => mkVerb_Irreg_Go_Prefix (Predef.tk 3 lemma) leftVal ;
"gulēt" => mkVerb_Irreg_Sleep leftVal
-- FIXME: "gulēt" should be treated as a regular verb (C3: gulēt, sēdēt etc.)
-- TODO: add "dot"/Give (+prefix, +refl)
-- TODO: multiple prefixes
-- TODO: move to IrregLav?
} ;
mkVerb_Irreg_Be : Case -> Verb = \topic -> {
mkVerb_Irreg_Be : Case -> Verb = \leftVal -> {
s = table {
Pos => table {
VInd P1 Sg Pres => "esmu" ;
@@ -378,12 +378,12 @@ oper
x => (mkVerb_C1 "nebūt" "neesu" "nebiju").s ! x -- the incorrect 'neesu' will be overriden
}
} ;
topic = topic
leftVal = leftVal
} ;
mkVerb_Irreg_Go : Case -> Verb = \topic -> mkVerb_Irreg_Go_Prefix "" topic ;
mkVerb_Irreg_Go : Case -> Verb = \leftVal -> mkVerb_Irreg_Go_Prefix "" leftVal ;
mkVerb_Irreg_Go_Prefix : Str -> Case -> Verb = \pref,topic -> {
mkVerb_Irreg_Go_Prefix : Str -> Case -> Verb = \pref,leftVal -> {
s = table {
Pos => table {
VInd P3 _ Pres => pref + "iet" ;
@@ -397,10 +397,10 @@ oper
x => (mkVerb_C1 ("ne" + pref + "iet") ("ne" + pref + "eju") ("ne" + pref + "gāju")).s ! x
}
} ;
topic = topic
leftVal = leftVal
} ;
mkVerb_Irreg_Sleep : Case -> Verb = \topic -> {
mkVerb_Irreg_Sleep : Case -> Verb = \leftVal -> {
s = table {
Pos => table {
VInd P2 Sg Pres => (mkVerb_C3 "gulēt").s ! VInd P2 Sg Pres ;
@@ -429,7 +429,7 @@ oper
x => (mkVerb_C3 "negulēt").s ! x
}
} ;
topic = topic
leftVal = leftVal
} ;
-- Auxiliaries: palatalization rules

View File

@@ -15,7 +15,7 @@ flags
lin
QuestCl cl = { s = \\m,p => "vai" ++ cl.s ! m ! p } ;
QuestVP ip vp = { s = \\m,p => ip.s ! Nom ++ buildVerb vp.v m p (AgrP3 ip.num Masc) Pos vp.agr.focus } ;
QuestVP ip vp = { s = \\m,p => ip.s ! Nom ++ buildVerb vp.v m p (AgrP3 ip.num Masc) Pos vp.rightPol } ;
QuestSlash ip slash = { s = \\m,p => slash.prep.s ++ ip.s ! (slash.prep.c ! ip.num) ++ slash.s ! m ! p } ;

View File

@@ -20,7 +20,7 @@ oper
-- TODO: PassV2 verbs jāsaskaņo ar objektu, nevis subjektu (by8means_Prep: AgP3 Sg Masc) - done?
mkRelClause : RP -> CatLav.VP -> RCl = \rp,vp ->
let subjInTopic : Bool = case <vp.voice, vp.topic> of {
let subjInTopic : Bool = case <vp.voice, vp.leftVal> of {
<Act, Nom> => True ;
<Act, _ > => False ;
<Pass, Acc> => False ;
@@ -30,11 +30,11 @@ oper
s = \\mood,pol,agr =>
case mood of { -- subject
Deb _ _ => rp.s ! Masc ! Dat ; --# notpresent
_ => rp.s ! Masc ! vp.topic
_ => rp.s ! Masc ! vp.leftVal
} ++
case subjInTopic of { -- verb
True => buildVerb vp.v mood pol (AgrP3 (fromAgr agr).num (fromAgr agr).gend) Pos vp.agr.focus ;
False => buildVerb vp.v mood pol vp.agr.subj Pos vp.agr.focus
True => buildVerb vp.v mood pol (AgrP3 (fromAgr agr).num (fromAgr agr).gend) Pos vp.rightPol ;
False => buildVerb vp.v mood pol vp.rightAgr Pos vp.rightPol
} ++
vp.compl ! agr -- object(s), complements, adverbial modifiers
} ;

View File

@@ -38,7 +38,7 @@ param
Ind Anteriority Tense
| Rel Anteriority Tense --# notpresent
| Deb Anteriority Tense --# notpresent
| Condit Anteriority --# notpresent
| Condit Anteriority --# notpresent
;
VForm =
@@ -50,7 +50,7 @@ param
| VDebRel -- the relative subtype of debitive
| VPart Voice Gender Number Case ;
-- Number and Gender has to be agreed in predicative nominal clauses
-- Number and gender has to be agreed in predicative nominal clauses
Agreement =
AgrP1 Number Gender
| AgrP2 Number Gender
@@ -74,46 +74,46 @@ oper
Adjective : Type = { s : AForm => Str } ;
Preposition : Type = { s : Str ; c : Number => Case } ;
-- For simple case-based valences, the preposition is empty ([])
-- TODO: position of prepositions (pre or post) ?
Verb : Type = { s : Polarity => VForm => Str ; topic : Case } ;
Verb : Type = { s : Polarity => VForm => Str ; leftVal : Case } ;
VP : Type = {
v : Verb ;
agr : {
subj : Agreement ; -- the verb-subject agreement (the subject can be in the focus part of a clause)
focus : Polarity -- the verb-focus agreement (for the double negation) -- TODO: jāpārsauc par pol, lai nejūk citur
} ;
compl : Agreement => Str ; -- the complement-subject agreement
voice : Voice ;
topic : Case -- the valence of the topic NP (typically, the subject)
v : Verb ;
compl : Agreement => Str ; -- the subject-complement agreement
voice : Voice ;
leftVal : Case ; -- the left valence (typically, the subject)
rightAgr : Agreement ; -- for the potential subject-verb agreement (the subject can be on the right side)
rightPol : Polarity -- for the potential double negation
} ;
VPSlash : Type = VP ** { focus : Preposition } ; -- the valence of the focus NP (typically, the object)
insertObj : (Agreement => Str) -> VP -> VP = \obj,vp -> {
v = vp.v ;
agr = vp.agr ;
compl = \\agr => vp.compl ! agr ++ obj ! agr ;
voice = vp.voice ;
topic = vp.topic
} ;
insertObjC : (Agreement => Str) -> VPSlash -> VPSlash = \obj,vp ->
insertObj obj vp ** { focus = vp.focus } ;
insertObjPre : (Agreement => Str) -> VP -> VP = \obj,vp -> {
v = vp.v ;
agr = vp.agr ;
compl = \\agr => obj ! agr ++ vp.compl ! agr ;
voice = vp.voice ;
topic = vp.topic
} ;
VPSlash : Type = VP ** { rightVal : Preposition } ; -- the right valence (typically, the object)
buildVP : VP -> Polarity -> VForm -> Agreement -> Str = \vp,pol,vf,agr ->
vp.v.s ! pol ! vf ++ vp.compl ! agr ;
insertObj : (Agreement => Str) -> VP -> VP = \obj,vp -> {
v = vp.v ;
compl = \\agr => vp.compl ! agr ++ obj ! agr ;
voice = vp.voice ;
leftVal = vp.leftVal ;
rightAgr = vp.rightAgr ;
rightPol = vp.rightPol
} ;
insertObjPre : (Agreement => Str) -> VP -> VP = \obj,vp -> {
v = vp.v ;
compl = \\agr => obj ! agr ++ vp.compl ! agr ;
voice = vp.voice ;
leftVal = vp.leftVal ;
rightAgr = vp.rightAgr ;
rightPol = vp.rightPol
} ;
insertObjSlash : (Agreement => Str) -> VPSlash -> VPSlash = \obj,vp ->
insertObj obj vp ** { rightVal = vp.rightVal } ;
getInf : Verb -> Str = \v -> v.s ! Pos ! VInf ;
toAgr : Person -> Number -> Gender -> Agreement = \pers,num,gend ->
case pers of {
P1 => AgrP1 num gend ;
@@ -132,16 +132,15 @@ oper
let
a1 = fromAgr agr1 ;
a2 = fromAgr agr2
in
toAgr
(conjPerson a1.pers a2.pers) -- FIXME: personu apvienošana ir tricky un ir jāuztaisa korekti
(conjNumber a1.num a2.num)
(conjGender a1.gend a2.gend) ;
in toAgr
(conjPerson a1.pers a2.pers)
(conjNumber a1.num a2.num)
(conjGender a1.gend a2.gend) ;
conjGender : Gender -> Gender -> Gender = \gend1,gend2 ->
case gend1 of {
Fem => gend2 ;
_ => Masc
Fem => gend2 ;
Masc => Masc
} ;
vowel : pattern Str = #("a"|"ā"|"e"|"ē"|"i"|"ī"|"o"|"u"|"ū") ;

View File

@@ -18,7 +18,7 @@ lin
ImpVP vp = { s = \\pol,num => vp.v.s ! pol ! (VImp num) ++ vp.compl ! (AgrP2 num Masc) } ;
SlashVP np vp = mkClause np vp ** { prep = vp.focus } ;
SlashVP np vp = mkClause np vp ** { prep = vp.rightVal } ;
AdvSlash slash adv = {
s = \\m,p => slash.s ! m ! p ++ adv.s ;
@@ -33,10 +33,11 @@ lin
np
(lin VP {
v = vs ;
agr = { subj = variants {} ; focus = Pos } ;
compl = \\_ => "," ++ vs.conj.s ++ sslash.s ;
voice = Act ;
topic = vs.topic
leftVal = vs.leftVal ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos ;
}) ** { prep = sslash.prep } ;
-- ComplVS v s = { v = v ; compl = \\_ => "," ++ v.subj.s ++ s.s } ;
@@ -65,27 +66,27 @@ lin
oper
-- TODO: PassV2 verbs jāsaskaņo ar objektu, nevis subjektu (by8means_Prep: AgP3 Sg Masc)
mkClause : NP -> CatLav.VP -> Cl = \np,vp ->
let agr : Agreement = case <vp.voice, vp.topic> of {
let agr : Agreement = case <vp.voice, vp.leftVal> of {
<Act, Nom> => np.agr ;
<Act, _ > => vp.agr.subj ;
<Pass, Acc> => vp.agr.subj ;
<Act, _ > => vp.rightAgr ;
<Pass, Acc> => vp.rightAgr ;
<Pass, _ > => np.agr
}
in lin Cl {
s = \\mood,pol =>
case mood of { -- subject
case mood of { -- subject
Deb _ _ => np.s ! Dat ; --# notpresent
_ => np.s ! vp.topic
_ => np.s ! vp.leftVal
} ++
buildVerb vp.v mood pol agr np.pol vp.agr.focus ++ -- verb
vp.compl ! np.agr -- object(s), complements, adverbial modifiers
buildVerb vp.v mood pol agr np.pol vp.rightPol ++ -- verb
vp.compl ! np.agr -- object(s), complements, adverbial modifiers
} ;
-- FIXME: quick&dirty - lai kompilētos pret RGL API
-- Eng: PredSCVP sc vp = mkClause sc.s (agrP3 Sg) vp
-- Ar SC nav iespējams neko saskaņot (sk. Cat.gf un Common.gf)
mkClauseSC : SC -> CatLav.VP -> Cl = \sc,vp -> lin Cl {
s = \\mood,pol => sc.s ++ buildVerb vp.v mood pol (AgrP3 Sg Masc) Pos vp.agr.focus ++ vp.compl ! (AgrP3 Sg Masc)
s = \\mood,pol => sc.s ++ buildVerb vp.v mood pol (AgrP3 Sg Masc) Pos vp.rightPol ++ vp.compl ! (AgrP3 Sg Masc)
} ;
}

View File

@@ -241,7 +241,7 @@ lin
if_Subj = ss "ja" ;
that_Subj = ss "ka" ;
all_Predet = { s = table { Masc => "visi" ; Fem => "visas" } } ;
all_Predet = { s = table { Masc => "visi" ; Fem => "visas" } } ; -- FIXME: cases
only_Predet = { s = table { _ => "tikai"} } ;
most_Predet = { s = table { _ => "vairums"} } ;

View File

@@ -25,179 +25,197 @@ lin
-- V -> VP
-- e.g. 'sleep'
UseV v = {
v = v ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\_ => [] ;
voice = Act ;
topic = v.topic
v = v ;
compl = \\_ => [] ;
voice = Act ;
leftVal = v.leftVal ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos
} ;
-- VV -> VP -> VP
-- e.g. 'want to run'
ComplVV vv vp = {
v = vv ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\agr => buildVP vp Pos VInf agr ;
voice = Act ;
topic = vv.topic
v = vv ;
compl = \\agr => buildVP vp Pos VInf agr ;
voice = Act ;
leftVal = vv.leftVal ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos
} ;
-- VS -> S -> VP
-- e.g. 'say that she runs'
ComplVS vs s = {
v = vs ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\_ => "," ++ vs.conj.s ++ s.s ;
voice = Act ;
topic = vs.topic
v = vs ;
compl = \\_ => "," ++ vs.conj.s ++ s.s ;
voice = Act ;
leftVal = vs.leftVal ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos
} ;
-- VQ -> QS -> VP
-- e.g. 'wonder who runs'
ComplVQ vq qs = {
v = vq ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\_ => "," ++ qs.s ;
voice = Act ;
topic = vq.topic
v = vq ;
compl = \\_ => "," ++ qs.s ;
voice = Act ;
leftVal = vq.leftVal ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos
} ;
-- VA -> AP -> VP
-- e.g. '(they) become red'
ComplVA va ap = {
v = va ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\agr => ap.s ! Indef ! (fromAgr agr).gend ! (fromAgr agr).num ! Nom ;
voice = Act ;
topic = va.topic
v = va ;
compl = \\agr => ap.s ! Indef ! (fromAgr agr).gend ! (fromAgr agr).num ! Nom ;
voice = Act ;
leftVal = va.leftVal ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos
} ;
-- V2 -> VPSlash
-- e.g. 'love (it)'
SlashV2a v2 = {
v = v2 ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\_ => [] ;
voice = Act ;
topic = v2.topic ;
focus = v2.focus
v = v2 ;
compl = \\_ => [] ; -- will be overriden
voice = Act ;
leftVal = v2.leftVal ;
rightAgr = AgrP3 Sg Masc ; -- will be overriden
rightPol = Pos ; -- will be overriden
rightVal = v2.rightVal
} ;
-- V3 -> NP -> VPSlash
-- e.g. 'give it (to her)'
Slash2V3 v3 np = insertObjC
(\\_ => v3.focus2.s ++ np.s ! (v3.focus2.c ! (fromAgr np.agr).num))
Slash2V3 v3 np = insertObjSlash
(\\_ => v3.rightVal2.s ++ np.s ! (v3.rightVal2.c ! (fromAgr np.agr).num))
{
v = v3 ;
agr = { subj = np.agr ; focus = np.pol } ;
compl = \\_ => [] ;
voice = Act ;
topic = v3.topic ;
focus = v3.focus1
v = v3 ;
compl = \\_ => [] ; -- will be overriden
voice = Act ;
leftVal = v3.leftVal ;
rightAgr = np.agr ;
rightPol = np.pol ;
rightVal = v3.rightVal1
} ;
-- FIXME: "vīrietis runā par ābolus ar sievieti" ("a man talks to a woman about apples")
-- FIXME: the order of objects (?)
-- TODO: test val (P1 un P2) un objNeg
-- FIXME: Slash2V3 = Slash3V3 (?)
-- V3 -> NP -> VPSlash
-- e.g. 'give (it) to her'
Slash3V3 v3 np = insertObjC
(\\_ => v3.focus2.s ++ np.s ! (v3.focus2.c ! (fromAgr np.agr).num))
Slash3V3 v3 np = insertObjSlash
(\\_ => v3.rightVal2.s ++ np.s ! (v3.rightVal2.c ! (fromAgr np.agr).num))
{
v = v3 ;
agr = { subj = np.agr ; focus = np.pol } ;
compl = \\_ => [] ;
voice = Act ;
topic = v3.topic ;
focus = v3.focus1
v = v3 ;
compl = \\_ => [] ; -- will be overriden
voice = Act ;
leftVal = v3.leftVal ;
rightAgr = np.agr ;
rightPol = np.pol ;
rightVal = v3.rightVal1
} ;
-- TODO: val other than P3 Sg Masc
-- TODO: test objNeg
-- V2V -> VP -> VPSlash
-- e.g. 'beg (her) to go'
SlashV2V v2v vp = {
v = v2v ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\agr => buildVP vp Pos VInf agr ;
voice = Act ;
topic = v2v.topic ;
focus = v2v.focus
v = v2v ;
compl = \\agr => buildVP vp Pos VInf agr ;
voice = Act ;
leftVal = v2v.leftVal ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos ;
rightVal = v2v.rightVal
} ;
-- V2S -> S -> VPSlash
-- e.g. 'answer (to him) that it is good'
SlashV2S v2s s = {
v = v2s ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\_ => "," ++ v2s.conj.s ++ s.s ;
voice = Act ;
topic = v2s.topic ;
focus = v2s.focus
v = v2s ;
compl = \\_ => "," ++ v2s.conj.s ++ s.s ;
voice = Act ;
leftVal = v2s.leftVal ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos ;
rightVal = v2s.rightVal
} ;
-- V2Q -> QS -> VPSlash
-- e.g. 'ask (him) who came'
SlashV2Q v2q qs = {
v = v2q ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\_ => "," ++ qs.s ;
voice = Act ;
topic = v2q.topic ;
focus = v2q.focus
v = v2q ;
compl = \\_ => "," ++ qs.s ;
voice = Act ;
leftVal = v2q.leftVal ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos ;
rightVal = v2q.rightVal
} ;
-- V2A -> AP -> VPSlash
-- e.g. 'paint (it) red'
SlashV2A v2a ap = {
v = v2a ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\agr => ap.s ! Indef ! (fromAgr agr).gend ! (fromAgr agr).num ! Nom ;
voice = Act ;
topic = v2a.topic ;
focus = v2a.focus
v = v2a ;
compl = \\agr => ap.s ! Indef ! (fromAgr agr).gend ! (fromAgr agr).num ! Nom ;
voice = Act ;
leftVal = v2a.leftVal ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos ;
rightVal = v2a.rightVal
} ;
-- VPSlash -> NP -> VP
-- e.g. 'love it'
ComplSlash vpslash np =
let agr : Agreement = np.agr in {
v = vpslash.v ;
agr = { subj = agr ; focus = np.pol } ;
compl = \\agr => case vpslash.voice of {
Act => vpslash.focus.s ++ np.s ! (vpslash.focus.c ! (fromAgr agr).num) ;
Pass => case vpslash.focus.c ! (fromAgr agr).num of {
Nom => np.s ! (vpslash.focus.c ! Sg) ;
_ => vpslash.focus.s ++ np.s ! (vpslash.focus.c ! (fromAgr agr).num)
v = vpslash.v ;
{-
compl = \\agr => case vpslash.voice of {
Act => vpslash.rightVal.s ++ np.s ! (vpslash.rightVal.c ! (fromAgr agr).num) ;
Pass => case vpslash.rightVal.c ! (fromAgr agr).num of {
Nom => np.s ! (vpslash.rightVal.c ! Sg) ;
_ => vpslash.rightVal.s ++ np.s ! (vpslash.rightVal.c ! (fromAgr agr).num)
}
} ++ vpslash.compl ! agr ;
voice = vpslash.voice ;
topic = vpslash.topic ;
focus = vpslash.focus
-}
compl = \\agr => vpslash.rightVal.s ++
np.s ! (vpslash.rightVal.c ! (fromAgr agr).num) ++
vpslash.compl ! agr ;
voice = vpslash.voice ;
leftVal = vpslash.leftVal ;
rightAgr = np.agr ;
rightPol = np.pol ;
rightVal = vpslash.rightVal ;
} ;
-- VV -> VPSlash -> VPSlash
-- e.g. 'want to buy'
SlashVV vv vpslash = {
v = vv ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\agr => buildVP vpslash Pos VInf agr ;
voice = Act ;
topic = vv.topic ;
focus = defaultPrep
v = vv ;
compl = \\agr => buildVP vpslash Pos VInf agr ;
voice = Act ;
leftVal = vv.leftVal ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos ;
rightVal = nom_Prep
} ;
-- V2V -> NP -> VPSlash -> VPSlash
-- e.g. '-- beg me to buy'
SlashV2VNP v2v np vpslash = insertObjC
(\\_ => v2v.focus.s ++ np.s ! (v2v.focus.c ! (fromAgr np.agr).num))
SlashV2VNP v2v np vpslash = insertObjSlash
(\\_ => v2v.rightVal.s ++ np.s ! (v2v.rightVal.c ! (fromAgr np.agr).num))
{
v = v2v ;
agr = { subj = np.agr ; focus = np.pol } ;
compl = \\agr => buildVP vpslash Pos VInf agr ;
voice = Act ;
topic = v2v.topic ;
focus = v2v.focus
v = v2v ;
compl = \\agr => buildVP vpslash Pos VInf agr ;
voice = Act ;
leftVal = v2v.leftVal ;
rightAgr = np.agr ;
rightPol = np.pol ;
rightVal = v2v.rightVal
} ;
-- Other ways of forming verb phrases
@@ -205,28 +223,30 @@ lin
-- VPSlash -> VP
-- e.g. 'love himself'
ReflVP vpslash = insertObjPre
(\\agr => vpslash.focus.s ++ reflPron ! (vpslash.focus.c ! (fromAgr agr).num))
(\\agr => vpslash.rightVal.s ++ reflPron ! (vpslash.rightVal.c ! (fromAgr agr).num))
vpslash ;
-- Comp -> VP
-- e.g. 'be warm'
UseComp comp = {
v = mkV "būt" ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\agr => comp.s ! agr ;
voice = Act ;
topic = Nom
v = mkV "būt" ;
compl = \\agr => comp.s ! agr ;
voice = Act ;
leftVal = Nom ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos
} ;
-- V2 -> VP
-- e.g. 'be loved'
PassV2 v2 = {
v = v2 ;
agr = { subj = defaultAgr ; focus = Pos } ;
compl = \\_ => [] ;
voice = Pass ;
topic = v2.focus.c ! Sg ;
focus = mkPrep v2.topic
v = v2 ;
compl = \\_ => [] ;
voice = Pass ;
leftVal = v2.rightVal.c ! Sg ;
rightAgr = AgrP3 Sg Masc ;
rightPol = Pos
--rightVal = mkPrep v2.leftVal
} ;
-- TODO: val - should not be overriden in ComplSlash etc.?
-- TODO: val - P3 Sg Masc restriction - never used?
@@ -248,8 +268,8 @@ lin
-- VP -> Prep -> VPSlash
-- e.g. 'live in (it)'
VPSlashPrep vp prep = vp ** { focus = prep } ;
-- TODO: šajā brīdī ir jāignorē prep (by8agent_Prep); tas jāaizstāj ar v2.topic (?)
VPSlashPrep vp prep = vp ** { rightVal = prep } ;
-- TODO: šajā brīdī ir jāignorē prep (by8agent_Prep); tas jāaizstāj ar v2.left (?)
-- Tad varēs dzēst ārā komentāru pie StructuralLav.by8agent_Prep (?)
-- Complements to copula
@@ -275,16 +295,12 @@ lin
oper
defaultAgr : Agreement = AgrP3 Sg Masc ; -- variants {}
defaultPrep : Preposition = nom_Prep ;
-- FIXME: the type of the participle form - depending on what?! (currently fixed)
buildVerb : Verb -> VMood -> Polarity -> Agreement -> Polarity -> Polarity -> Str =
\v,mood,pol,agr,polTopic,polFocus ->
\v,mood,pol,agr,leftPol,rightPol ->
let
polFinal : Polarity = case <polTopic, polFocus> of {
-- double negation, if the topic/focus NP has a negated determiner
<Neg, _> => Neg ;
finalPol : Polarity = case <leftPol, rightPol> of {
<Neg, _> => Neg ; -- double negation, if the left/right NP has a negated determiner
<_, Neg> => Neg ;
_ => pol
} ;
@@ -292,23 +308,23 @@ oper
; --# notpresent
part = v.s ! Pos ! (VPart Pass agr.gend agr.num Nom) --# notpresent
in case mood of {
Ind Simul tense => v.s ! polFinal ! (VInd agr.pers agr.num tense)
Ind Simul tense => v.s ! finalPol ! (VInd agr.pers agr.num tense)
; --# notpresent
Ind Anter tense => (mkV "būt").s ! polFinal ! (VInd agr.pers agr.num tense) ++ part ; --# notpresent
Ind Anter tense => (mkV "būt").s ! finalPol ! (VInd agr.pers agr.num tense) ++ part ; --# notpresent
-- FIXME(?): Rel _ Past => ...
Rel _ Past => NON_EXISTENT ; --# notpresent
Rel Simul tense => v.s ! polFinal ! (VRel tense) ; --# notpresent
Rel Anter tense => (mkV "būt").s ! polFinal ! (VRel tense) ++ part ; --# notpresent
Rel Simul tense => v.s ! finalPol ! (VRel tense) ; --# notpresent
Rel Anter tense => (mkV "būt").s ! finalPol ! (VRel tense) ++ part ; --# notpresent
Deb Simul tense => (mkV "būt").s ! polFinal ! (VInd P3 Sg tense) ++ --# notpresent
Deb Simul tense => (mkV "būt").s ! finalPol ! (VInd P3 Sg tense) ++ --# notpresent
v.s ! Pos ! VDeb ; --# notpresent
Deb Anter tense => (mkV "būt").s ! polFinal ! (VInd P3 Sg tense) ++ --# notpresent
Deb Anter tense => (mkV "būt").s ! finalPol ! (VInd P3 Sg tense) ++ --# notpresent
(mkV "būt").s ! Pos ! (VPart Pass Masc Sg Nom) ++ --# notpresent
v.s ! Pos ! VDeb ; --# notpresent
Condit Simul => v.s ! polFinal ! (VInd agr.pers agr.num ParamX.Cond) ; --# notpresent
Condit Anter => (mkV "būt").s ! polFinal ! (VInd agr.pers agr.num ParamX.Cond) ++ part --# notpresent
Condit Simul => v.s ! finalPol ! (VInd agr.pers agr.num ParamX.Cond) ; --# notpresent
Condit Anter => (mkV "būt").s ! finalPol ! (VInd agr.pers agr.num ParamX.Cond) ++ part --# notpresent
} ;
}