1
0
forked from GitHub/gf-rgl

Latvian: CN and NP types are extended with a Bool field for tracking whether a relative clause has been used

This is used for inserting the closing comma if necessary, and later will be used also for adjusting the word order.
This commit is contained in:
normundsg
2013-12-12 20:42:55 +00:00
parent 6733ffa228
commit b9255bbfe9
7 changed files with 95 additions and 54 deletions

View File

@@ -55,9 +55,9 @@ lincat
-- Nouns and noun phrases -- Nouns and noun phrases
CN = { s : Definiteness => Number => Case => Str ; gend : Gender } ; CN = { s : Definiteness => Number => Case => Str ; gend : Gender ; isRel : Bool } ;
NP = { s : Case => Str ; agr : Agreement ; pol : Polarity } ; NP = { s : Case => Str ; agr : Agreement ; pol : Polarity ; isRel : Bool } ;
Pron = Pronoun ; Pron = Pronoun ;

View File

@@ -18,7 +18,8 @@ lin
ConjNP conj ss = conjunctDistrTable Case conj ss ** { ConjNP conj ss = conjunctDistrTable Case conj ss ** {
agr = toAgr (fromAgr ss.agr).pers (conjNumber (fromAgr ss.agr).num conj.num) (fromAgr ss.agr).gend; agr = toAgr (fromAgr ss.agr).pers (conjNumber (fromAgr ss.agr).num conj.num) (fromAgr ss.agr).gend;
pol = Pos pol = Pos ;
isRel = False
} ; } ;
ConjAP conj ss = conjunctDistrTable4 Definiteness Gender Number Case conj ss ; ConjAP conj ss = conjunctDistrTable4 Definiteness Gender Number Case conj ss ;

View File

@@ -11,10 +11,12 @@ in {
flags coding = utf8 ; flags coding = utf8 ;
lin lin
-- NP -> CN -> CN -- NP -> CN -> CN
GenCN np cn = { GenCN np cn = {
s = \\d,n,c => np.s ! Gen ++ cn.s ! d ! n ! c ; s = \\d,n,c => np.s ! Gen ++ closeRelCl np.isRel ++ cn.s ! d ! n ! c ;
gend = cn.gend gend = cn.gend ;
isRel = cn.isRel
} ; } ;
aiz_Prep = mkPrep "aiz" Gen Dat ; aiz_Prep = mkPrep "aiz" Gen Dat ;

View File

@@ -16,23 +16,35 @@ lin
DetCN det cn = { DetCN det cn = {
s = \\c => det.s ! cn.gend ! c ++ cn.s ! det.defin ! det.num ! c ; s = \\c => det.s ! cn.gend ! c ++ cn.s ! det.defin ! det.num ! c ;
agr = AgrP3 det.num cn.gend ; agr = AgrP3 det.num cn.gend ;
pol = det.pol pol = det.pol ;
isRel = cn.isRel
} ; } ;
-- PN -> NP -- PN -> NP
-- e.g. 'John' -- e.g. 'John'
UsePN pn = { s = pn.s ; agr = AgrP3 pn.num pn.gend ; pol = Pos } ; UsePN pn = {
s = pn.s ;
agr = AgrP3 pn.num pn.gend ;
pol = Pos ;
isRel = False
} ;
-- Pron -> NP -- Pron -> NP
-- e.g. 'he' -- e.g. 'he'
UsePron pron = { s = pron.s ; agr = pron.agr ; pol = pron.pol } ; UsePron pron = {
s = pron.s ;
agr = pron.agr ;
pol = pron.pol ;
isRel = False
} ;
-- Predet -> NP -> NP -- Predet -> NP -> NP
-- e.g. 'only the man' -- e.g. 'only the man'
PredetNP predet np = { PredetNP predet np = {
s = \\c => predet.s ! (fromAgr np.agr).gend ++ np.s ! c ; s = \\c => predet.s ! (fromAgr np.agr).gend ++ np.s ! c ;
agr = np.agr ; agr = np.agr ;
pol = np.pol pol = np.pol ;
isRel = np.isRel
} ; } ;
-- NP -> V2 -> NP -- NP -> V2 -> NP
@@ -40,7 +52,8 @@ lin
PPartNP np v2 = { PPartNP np v2 = {
s = \\c => v2.s ! Pos ! (VPart Pass (fromAgr np.agr).gend (fromAgr np.agr).num c) ++ np.s ! c ; s = \\c => v2.s ! Pos ! (VPart Pass (fromAgr np.agr).gend (fromAgr np.agr).num c) ++ np.s ! c ;
agr = np.agr ; agr = np.agr ;
pol = np.pol pol = np.pol ;
isRel = np.isRel
} ; } ;
-- NP -> Adv -> NP -- NP -> Adv -> NP
@@ -48,7 +61,8 @@ lin
AdvNP np adv = { AdvNP np adv = {
s = \\c => np.s ! c ++ adv.s ; s = \\c => np.s ! c ++ adv.s ;
agr = np.agr ; agr = np.agr ;
pol = np.pol pol = np.pol ;
isRel = False
} ; } ;
-- NP -> RS -> NP -- NP -> RS -> NP
@@ -56,7 +70,16 @@ lin
RelNP np rs = { RelNP np rs = {
s = \\c => np.s ! c ++ "," ++ rs.s ! np.agr ; s = \\c => np.s ! c ++ "," ++ rs.s ! np.agr ;
agr = np.agr ; agr = np.agr ;
pol = np.pol pol = np.pol ;
isRel = True
} ;
-- CN -> NP
MassNP cn = {
s = cn.s ! Indef ! Sg ; -- FIXME: bet 'šis alus'? un 'zaļš alus' vs. 'zaļais alus'?
agr = AgrP3 Sg cn.gend ;
pol = Pos ;
isRel = cn.isRel
} ; } ;
-- Det -> NP -- Det -> NP
@@ -64,11 +87,13 @@ lin
DetNP det = { DetNP det = {
s = \\c => det.s ! Masc ! c ; s = \\c => det.s ! Masc ! c ;
agr = AgrP3 det.num Masc ; agr = AgrP3 det.num Masc ;
pol = det.pol pol = det.pol ;
isRel = False
} | { } | {
s = \\c => det.s ! Fem ! c ; s = \\c => det.s ! Fem ! c ;
agr = AgrP3 det.num Fem ; agr = AgrP3 det.num Fem ;
pol = det.pol pol = det.pol ;
isRel = False
} ; } ;
-- Determiners -- Determiners
@@ -87,7 +112,7 @@ lin
DetQuantOrd quant num ord = { DetQuantOrd quant num ord = {
s = \\gend,c => quant.s ! gend ! num.num ! c ++ num.s ! gend ! c ++ ord.s ! gend ! c ; s = \\gend,c => quant.s ! gend ! num.num ! c ++ num.s ! gend ! c ++ ord.s ! gend ! c ;
num = num.num ; num = num.num ;
defin = quant.defin ; --FIXME: ja ir kārtas skaitļa vārds, tad tikai noteiktās formas defin = quant.defin ; -- FIXME: ja ir kārtas skaitļa vārds, tad tikai noteiktās formas
pol = quant.pol pol = quant.pol
} ; } ;
@@ -133,13 +158,6 @@ lin
-- Quant -- Quant
DefArt = { s = \\_,_,_ => [] ; defin = Def ; pol = Pos } ; DefArt = { s = \\_,_,_ => [] ; defin = Def ; pol = Pos } ;
-- CN -> NP
MassNP cn = {
s = cn.s ! Indef ! Sg ; -- FIXME: bet 'šis alus'? un 'zaļš alus' vs. 'zaļais alus'?
agr = AgrP3 Sg cn.gend ;
pol = Pos
} ;
-- Pron -> Quant -- Pron -> Quant
PossPron pron = { s = pron.poss ; defin = Def ; pol = Pos } ; PossPron pron = { s = pron.poss ; defin = Def ; pol = Pos } ;
@@ -147,19 +165,24 @@ lin
-- N -> CN -- N -> CN
-- e.g. 'house' -- e.g. 'house'
UseN n = { s = \\_ => n.s ; gend = n.gend } ; UseN n = { s = \\_ => n.s ; gend = n.gend ; isRel = False } ;
-- N2 -> NP -> CN -- N2 -> NP -> CN
-- e.g. 'mother of the king' -- e.g. 'mother of the king'
ComplN2 n2 np = { ComplN2 n2 np = {
s = \\_,num,c => preOrPost n2.isPre (n2.prep.s ++ np.s ! (n2.prep.c ! (fromAgr np.agr).num)) (n2.s ! num ! c) ; s = \\_,num,c => preOrPost n2.isPre
gend = n2.gend (n2.prep.s ++ np.s ! (n2.prep.c ! (fromAgr np.agr).num) ++ closeRelCl np.isRel)
(n2.s ! num ! c) ;
gend = n2.gend ;
isRel = False
} ; } ;
-- N3 -> NP -> N2 -- N3 -> NP -> N2
-- e.g. 'distance from this city (to Paris)' -- e.g. 'distance from this city (to Paris)'
ComplN3 n3 np = { ComplN3 n3 np = {
s = \\num,c => preOrPost n3.isPre1 (n3.prep1.s ++ np.s ! (n3.prep1.c ! (fromAgr np.agr).num)) (n3.s ! num ! c) ; s = \\num,c => preOrPost n3.isPre1
(n3.prep1.s ++ np.s ! (n3.prep1.c ! (fromAgr np.agr).num) ++ closeRelCl np.isRel)
(n3.s ! num ! c) ;
gend = n3.gend ; gend = n3.gend ;
prep = n3.prep2 ; prep = n3.prep2 ;
isPre = n3.isPre2 isPre = n3.isPre2
@@ -167,7 +190,7 @@ lin
-- N2 -> CN -- N2 -> CN
-- e.g. 'mother' -- e.g. 'mother'
UseN2 n2 = { s = \\_ => n2.s ; gend = n2.gend } ; UseN2 n2 = { s = \\_ => n2.s ; gend = n2.gend ; isRel = False } ;
-- N3 -> N2 -- N3 -> N2
-- e.g. 'distance (from this city)' -- e.g. 'distance (from this city)'
@@ -181,28 +204,32 @@ lin
-- e.g. 'big house' -- e.g. 'big house'
AdjCN ap cn = { AdjCN ap cn = {
s = \\defin,num,c => ap.s ! defin ! cn.gend ! num ! c ++ cn.s ! defin ! num ! c ; s = \\defin,num,c => ap.s ! defin ! cn.gend ! num ! c ++ cn.s ! defin ! num ! c ;
gend = cn.gend gend = cn.gend ;
isRel = cn.isRel
} ; } ;
-- CN -> RS -> CN -- CN -> RS -> CN
-- e.g. 'house that John bought' -- e.g. 'house that John bought'
RelCN cn rs = { RelCN cn rs = {
s = \\defin,num,c => cn.s ! defin ! num ! c ++ "," ++ rs.s ! AgrP3 num cn.gend ; s = \\defin,num,c => cn.s ! defin ! num ! c ++ "," ++ rs.s ! AgrP3 num cn.gend ;
gend = cn.gend gend = cn.gend ;
isRel = True
} ; } ;
-- CN -> Adv -> CN -- CN -> Adv -> CN
-- e.g. 'house on the hill' -- e.g. 'house on the hill'
AdvCN cn adv = { AdvCN cn adv = {
s = \\defin,num,c => cn.s ! defin ! num ! c ++ adv.s ; s = \\defin,num,c => cn.s ! defin ! num ! c ++ adv.s ;
gend = cn.gend gend = cn.gend ;
isRel = False -- TODO: Adv arī būs jāievieš isRel lauks
} ; } ;
-- CN -> SC -> CN -- CN -> SC -> CN
-- e.g. 'question where she sleeps' -- e.g. 'question where she sleeps'
SentCN cn sc = { SentCN cn sc = {
s = \\defin,num,c => cn.s ! defin ! num ! c ++ "," ++ sc.s ; s = \\defin,num,c => cn.s ! defin ! num ! c ++ "," ++ sc.s ;
gend = cn.gend gend = cn.gend ;
isRel = True
} ; } ;
-- Apposition -- Apposition
@@ -212,7 +239,8 @@ lin
ApposCN cn np = ApposCN cn np =
let num : Number = (fromAgr np.agr).num in { let num : Number = (fromAgr np.agr).num in {
s = \\defin,num,c => cn.s ! defin ! num ! c ++ np.s ! c ; s = \\defin,num,c => cn.s ! defin ! num ! c ++ np.s ! c ;
gend = cn.gend gend = cn.gend ;
isRel = np.isRel
} ; } ;
-- TODO: Possessive and partitive constructs -- TODO: Possessive and partitive constructs

View File

@@ -143,6 +143,12 @@ oper
Masc => Masc Masc => Masc
} ; } ;
closeRelCl : Bool -> Str = \isRel ->
case isRel of {
True => "," ;
False => []
} ;
vowel : pattern Str = #("a"|"ā"|"e"|"ē"|"i"|"ī"|"o"|"u"|"ū") ; vowel : pattern Str = #("a"|"ā"|"e"|"ē"|"i"|"ī"|"o"|"u"|"ū") ;
simpleCons : pattern Str = #("c"|"d"|"l"|"n"|"s"|"t"|"z") ; simpleCons : pattern Str = #("c"|"d"|"l"|"n"|"s"|"t"|"z") ;

View File

@@ -78,6 +78,7 @@ oper
Deb _ _ => np.s ! Dat ; --# notpresent Deb _ _ => np.s ! Dat ; --# notpresent
_ => np.s ! vp.leftVal _ => np.s ! vp.leftVal
} ++ } ++
closeRelCl np.isRel ++
buildVerb vp.v mood pol agr np.pol vp.rightPol ++ -- verb buildVerb vp.v mood pol agr np.pol vp.rightPol ++ -- verb
vp.compl ! np.agr -- object(s), complements, adverbial modifiers vp.compl ! np.agr -- object(s), complements, adverbial modifiers
} ; } ;

View File

@@ -18,19 +18,22 @@ lin
CNIntNP cn i = { CNIntNP cn i = {
s = \\_ => cn.s ! Indef ! Sg ! Nom ++ i.s ; s = \\_ => cn.s ! Indef ! Sg ! Nom ++ i.s ;
agr = AgrP3 Sg cn.gend ; agr = AgrP3 Sg cn.gend ;
pol = Pos pol = Pos ;
isRel = False
} ; } ;
CNSymbNP det cn xs = { CNSymbNP det cn xs = {
s = \\_ => det.s ! cn.gend ! Nom ++ cn.s ! det.defin ! det.num ! Nom ++ xs.s ; s = \\_ => det.s ! cn.gend ! Nom ++ cn.s ! det.defin ! det.num ! Nom ++ xs.s ;
agr = AgrP3 det.num cn.gend ; agr = AgrP3 det.num cn.gend ;
pol = Pos pol = Pos ;
isRel = False
} ; } ;
CNNumNP cn i = { CNNumNP cn i = {
s = \\_ => cn.s ! Indef ! Sg ! Nom ++ i.s ! Masc ! Nom ; s = \\_ => cn.s ! Indef ! Sg ! Nom ++ i.s ! Masc ! Nom ;
agr = AgrP3 Sg cn.gend ; agr = AgrP3 Sg cn.gend ;
pol = Pos pol = Pos ;
isRel = False
} ; } ;
SymbS sy = sy ; SymbS sy = sy ;