mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
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:
@@ -55,9 +55,9 @@ lincat
|
||||
|
||||
-- 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 ;
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ lin
|
||||
|
||||
ConjNP conj ss = conjunctDistrTable Case conj ss ** {
|
||||
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 ;
|
||||
|
||||
@@ -11,10 +11,12 @@ in {
|
||||
flags coding = utf8 ;
|
||||
|
||||
lin
|
||||
|
||||
-- NP -> CN -> CN
|
||||
GenCN np cn = {
|
||||
s = \\d,n,c => np.s ! Gen ++ cn.s ! d ! n ! c ;
|
||||
gend = cn.gend
|
||||
s = \\d,n,c => np.s ! Gen ++ closeRelCl np.isRel ++ cn.s ! d ! n ! c ;
|
||||
gend = cn.gend ;
|
||||
isRel = cn.isRel
|
||||
} ;
|
||||
|
||||
aiz_Prep = mkPrep "aiz" Gen Dat ;
|
||||
|
||||
@@ -14,61 +14,86 @@ lin
|
||||
-- Det -> CN -> NP
|
||||
-- e.g. 'the man'
|
||||
DetCN det cn = {
|
||||
s = \\c => det.s ! cn.gend ! c ++ cn.s ! det.defin ! det.num ! c ;
|
||||
agr = AgrP3 det.num cn.gend ;
|
||||
pol = det.pol
|
||||
s = \\c => det.s ! cn.gend ! c ++ cn.s ! det.defin ! det.num ! c ;
|
||||
agr = AgrP3 det.num cn.gend ;
|
||||
pol = det.pol ;
|
||||
isRel = cn.isRel
|
||||
} ;
|
||||
|
||||
-- PN -> NP
|
||||
-- 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
|
||||
-- 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
|
||||
-- e.g. 'only the man'
|
||||
PredetNP predet np = {
|
||||
s = \\c => predet.s ! (fromAgr np.agr).gend ++ np.s ! c ;
|
||||
agr = np.agr ;
|
||||
pol = np.pol
|
||||
s = \\c => predet.s ! (fromAgr np.agr).gend ++ np.s ! c ;
|
||||
agr = np.agr ;
|
||||
pol = np.pol ;
|
||||
isRel = np.isRel
|
||||
} ;
|
||||
|
||||
-- NP -> V2 -> NP
|
||||
-- e.g. 'the man seen'
|
||||
PPartNP np v2 = {
|
||||
s = \\c => v2.s ! Pos ! (VPart Pass (fromAgr np.agr).gend (fromAgr np.agr).num c) ++ np.s ! c ;
|
||||
agr = np.agr ;
|
||||
pol = np.pol
|
||||
s = \\c => v2.s ! Pos ! (VPart Pass (fromAgr np.agr).gend (fromAgr np.agr).num c) ++ np.s ! c ;
|
||||
agr = np.agr ;
|
||||
pol = np.pol ;
|
||||
isRel = np.isRel
|
||||
} ;
|
||||
|
||||
-- NP -> Adv -> NP
|
||||
-- e.g. 'Paris today'
|
||||
AdvNP np adv = {
|
||||
s = \\c => np.s ! c ++ adv.s ;
|
||||
agr = np.agr ;
|
||||
pol = np.pol
|
||||
s = \\c => np.s ! c ++ adv.s ;
|
||||
agr = np.agr ;
|
||||
pol = np.pol ;
|
||||
isRel = False
|
||||
} ;
|
||||
|
||||
-- NP -> RS -> NP
|
||||
-- e.g. 'Paris, which is here'
|
||||
RelNP np rs = {
|
||||
s = \\c => np.s ! c ++ "," ++ rs.s ! np.agr ;
|
||||
agr = np.agr ;
|
||||
pol = np.pol
|
||||
s = \\c => np.s ! c ++ "," ++ rs.s ! np.agr ;
|
||||
agr = np.agr ;
|
||||
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
|
||||
-- e.g. 'these five'
|
||||
DetNP det = {
|
||||
s = \\c => det.s ! Masc ! c ;
|
||||
agr = AgrP3 det.num Masc ;
|
||||
pol = det.pol
|
||||
s = \\c => det.s ! Masc ! c ;
|
||||
agr = AgrP3 det.num Masc ;
|
||||
pol = det.pol ;
|
||||
isRel = False
|
||||
} | {
|
||||
s = \\c => det.s ! Fem ! c ;
|
||||
agr = AgrP3 det.num Fem ;
|
||||
pol = det.pol
|
||||
s = \\c => det.s ! Fem ! c ;
|
||||
agr = AgrP3 det.num Fem ;
|
||||
pol = det.pol ;
|
||||
isRel = False
|
||||
} ;
|
||||
|
||||
-- Determiners
|
||||
@@ -87,7 +112,7 @@ lin
|
||||
DetQuantOrd quant num ord = {
|
||||
s = \\gend,c => quant.s ! gend ! num.num ! c ++ num.s ! gend ! c ++ ord.s ! gend ! c ;
|
||||
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
|
||||
} ;
|
||||
|
||||
@@ -133,13 +158,6 @@ lin
|
||||
-- Quant
|
||||
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
|
||||
PossPron pron = { s = pron.poss ; defin = Def ; pol = Pos } ;
|
||||
|
||||
@@ -147,19 +165,24 @@ lin
|
||||
|
||||
-- N -> CN
|
||||
-- e.g. 'house'
|
||||
UseN n = { s = \\_ => n.s ; gend = n.gend } ;
|
||||
UseN n = { s = \\_ => n.s ; gend = n.gend ; isRel = False } ;
|
||||
|
||||
-- N2 -> NP -> CN
|
||||
-- e.g. 'mother of the king'
|
||||
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) ;
|
||||
gend = n2.gend
|
||||
s = \\_,num,c => preOrPost n2.isPre
|
||||
(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
|
||||
-- e.g. 'distance from this city (to Paris)'
|
||||
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 ;
|
||||
prep = n3.prep2 ;
|
||||
isPre = n3.isPre2
|
||||
@@ -167,7 +190,7 @@ lin
|
||||
|
||||
-- N2 -> CN
|
||||
-- e.g. 'mother'
|
||||
UseN2 n2 = { s = \\_ => n2.s ; gend = n2.gend } ;
|
||||
UseN2 n2 = { s = \\_ => n2.s ; gend = n2.gend ; isRel = False } ;
|
||||
|
||||
-- N3 -> N2
|
||||
-- e.g. 'distance (from this city)'
|
||||
@@ -180,29 +203,33 @@ lin
|
||||
-- AP -> CN -> CN
|
||||
-- e.g. 'big house'
|
||||
AdjCN ap cn = {
|
||||
s = \\defin,num,c => ap.s ! defin ! cn.gend ! num ! c ++ cn.s ! defin ! num ! c ;
|
||||
gend = cn.gend
|
||||
s = \\defin,num,c => ap.s ! defin ! cn.gend ! num ! c ++ cn.s ! defin ! num ! c ;
|
||||
gend = cn.gend ;
|
||||
isRel = cn.isRel
|
||||
} ;
|
||||
|
||||
-- CN -> RS -> CN
|
||||
-- e.g. 'house that John bought'
|
||||
RelCN cn rs = {
|
||||
s = \\defin,num,c => cn.s ! defin ! num ! c ++ "," ++ rs.s ! AgrP3 num cn.gend ;
|
||||
gend = cn.gend
|
||||
s = \\defin,num,c => cn.s ! defin ! num ! c ++ "," ++ rs.s ! AgrP3 num cn.gend ;
|
||||
gend = cn.gend ;
|
||||
isRel = True
|
||||
} ;
|
||||
|
||||
-- CN -> Adv -> CN
|
||||
-- e.g. 'house on the hill'
|
||||
AdvCN cn adv = {
|
||||
s = \\defin,num,c => cn.s ! defin ! num ! c ++ adv.s ;
|
||||
gend = cn.gend
|
||||
s = \\defin,num,c => cn.s ! defin ! num ! c ++ adv.s ;
|
||||
gend = cn.gend ;
|
||||
isRel = False -- TODO: Adv arī būs jāievieš isRel lauks
|
||||
} ;
|
||||
|
||||
-- CN -> SC -> CN
|
||||
-- e.g. 'question where she sleeps'
|
||||
SentCN cn sc = {
|
||||
s = \\defin,num,c => cn.s ! defin ! num ! c ++ "," ++ sc.s ;
|
||||
gend = cn.gend
|
||||
s = \\defin,num,c => cn.s ! defin ! num ! c ++ "," ++ sc.s ;
|
||||
gend = cn.gend ;
|
||||
isRel = True
|
||||
} ;
|
||||
|
||||
-- Apposition
|
||||
@@ -211,8 +238,9 @@ lin
|
||||
-- e.g. 'city Paris', 'numbers x and y'
|
||||
ApposCN cn np =
|
||||
let num : Number = (fromAgr np.agr).num in {
|
||||
s = \\defin,num,c => cn.s ! defin ! num ! c ++ np.s ! c ;
|
||||
gend = cn.gend
|
||||
s = \\defin,num,c => cn.s ! defin ! num ! c ++ np.s ! c ;
|
||||
gend = cn.gend ;
|
||||
isRel = np.isRel
|
||||
} ;
|
||||
|
||||
-- TODO: Possessive and partitive constructs
|
||||
|
||||
@@ -143,6 +143,12 @@ oper
|
||||
Masc => Masc
|
||||
} ;
|
||||
|
||||
closeRelCl : Bool -> Str = \isRel ->
|
||||
case isRel of {
|
||||
True => "," ;
|
||||
False => []
|
||||
} ;
|
||||
|
||||
vowel : pattern Str = #("a"|"ā"|"e"|"ē"|"i"|"ī"|"o"|"u"|"ū") ;
|
||||
|
||||
simpleCons : pattern Str = #("c"|"d"|"l"|"n"|"s"|"t"|"z") ;
|
||||
|
||||
@@ -78,6 +78,7 @@ oper
|
||||
Deb _ _ => np.s ! Dat ; --# notpresent
|
||||
_ => np.s ! vp.leftVal
|
||||
} ++
|
||||
closeRelCl np.isRel ++
|
||||
buildVerb vp.v mood pol agr np.pol vp.rightPol ++ -- verb
|
||||
vp.compl ! np.agr -- object(s), complements, adverbial modifiers
|
||||
} ;
|
||||
|
||||
@@ -18,19 +18,22 @@ lin
|
||||
CNIntNP cn i = {
|
||||
s = \\_ => cn.s ! Indef ! Sg ! Nom ++ i.s ;
|
||||
agr = AgrP3 Sg cn.gend ;
|
||||
pol = Pos
|
||||
pol = Pos ;
|
||||
isRel = False
|
||||
} ;
|
||||
|
||||
CNSymbNP det cn xs = {
|
||||
s = \\_ => det.s ! cn.gend ! Nom ++ cn.s ! det.defin ! det.num ! Nom ++ xs.s ;
|
||||
agr = AgrP3 det.num cn.gend ;
|
||||
pol = Pos
|
||||
pol = Pos ;
|
||||
isRel = False
|
||||
} ;
|
||||
|
||||
CNNumNP cn i = {
|
||||
s = \\_ => cn.s ! Indef ! Sg ! Nom ++ i.s ! Masc ! Nom ;
|
||||
agr = AgrP3 Sg cn.gend ;
|
||||
pol = Pos
|
||||
pol = Pos ;
|
||||
isRel = False
|
||||
} ;
|
||||
|
||||
SymbS sy = sy ;
|
||||
|
||||
Reference in New Issue
Block a user