(Ara) bind CN's np field if it comes from a pronoun

This commit is contained in:
Inari Listenmaa
2018-12-30 11:16:53 +02:00
parent 459e51f9b9
commit 1566b6bd03
2 changed files with 44 additions and 34 deletions

View File

@@ -7,16 +7,16 @@ lin
DetCN det cn = let {
cas : Case -> Case = if_then_else Case det.is1sg Bare ;
number = case cn.isDual of {
True =>
True =>
case sizeToNumber det.n of {
Sg => Sg ;
_ => Dl } ;
False => sizeToNumber det.n } ;
determiner : Case -> Str = \c ->
det.s ! cn.h ! detGender cn.g det.n ! c ;
noun : Case -> Str = \c ->
cn.s ! number
! nounState det.d number
noun : Case -> Str = \c ->
cn.s ! number
! nounState det.d number
! nounCase c det.n det.d ;
adj : Case -> Str = \c ->
cn.s2 ! number
@@ -29,12 +29,14 @@ lin
False => determiner c'
++ noun c'
++ adj c'
++ cn.np ! c' ;
++ bindIf cn.np.binds -- ?
++ cn.np.s ! c' ;
True => noun (cas c) -- deal with possessive suffix
++ determiner c'
++ adj c'
++ cn.np ! c'
};
++ bindIf cn.np.binds -- ?
++ cn.np.s ! c'
};
a = { pgn = agrP3 cn.h cn.g number;
isPron = False } ;
empty = []
@@ -78,7 +80,7 @@ lin
quant.s ! Pl ! h ! g ! c
++ num.s ! g ! d ! c
--FIXME check this:
++ ord.s ! g
++ ord.s ! g
! case d of {Poss => Def ; _ => d}
! c ;
n = num.n;
@@ -97,7 +99,7 @@ lin
None => False;
_ => num.isNum
} ;
isEmpty =
isEmpty =
case quant.isEmpty of {
True => notB num.isNum ;
_ => False }
@@ -170,7 +172,7 @@ lin
} ;
MassNP cn =
{s = \\c => cn2str cn Sg Indef c ;
{s = \\c => cn2str cn Sg Indef c ;
a = {pgn = Per3 cn.g Sg ; isPron = False} ;
empty = []} ;
@@ -179,12 +181,15 @@ lin
Use2N3 n3 = n3 ;
Use3N3 n3 = n3 ** {c2 = n3.c3} ;
ComplN2 n2 np = UseN n2 ** {np = \\c => n2.c2.s ++ bindIf n2.c2.binds ++ np.s ! n2.c2.c} ;
ComplN2 n2 np = UseN n2 ** {
np = {s = \\c => n2.c2.s ++ bindIf n2.c2.binds ++ np.s ! n2.c2.c ;
binds = False}
} ;
ComplN3 n3 np = ComplN2 n3 np ** {c2 = n3.c3} ;
AdjCN ap cn = cn ** {
s2 = \\n,d,c => cn.s2 ! n ! d ! c ++ ap.s ! cn.h ! cn.g ! n ! (definite ! d) ! c
s2 = \\n,d,c => cn.s2 ! n ! d ! c ++ ap.s ! cn.h ! cn.g ! n ! (definite ! d) ! c
};
RelCN cn rs = cn ** {
@@ -195,13 +200,17 @@ lin
AdvCN,
SentCN = \cn,ss -> cn ** {s2 = \\n,d,c => cn.s2 ! n ! d ! c ++ ss.s} ;
ApposCN cn np = cn ** { np = \\c => cn.np ! c ++ np.s ! c } ;
ApposCN cn np = cn ** {
np = {s = \\c => cn.np.s ! c ++ np.s ! c ;
binds = False} -- even if it's pron, it shouldn't be a suffix
} ;
-- : CN -> NP -> CN ; -- house of Paris, house of mine
PossNP cn np = cn ** {
s = \\n,_d,c => cn.s ! n ! Const ! c ;
s2 = \\n,_d,c => cn.s2 ! n ! Const ! Gen ;
np = \\c => cn.np ! c ++ np.s ! Gen
np = {s = \\c => cn.np.s ! c ++ np.s ! Gen ;
binds = np.a.isPron} ; -- will be weird if the CN's np field already has something. but that'd be weird in any case, binds or not. /IL
};
-- : CN -> NP -> CN ; -- glass of wine

View File

@@ -57,7 +57,7 @@ resource ResAra = PatternsAra ** open Prelude, Predef, OrthoAra, ParamX in {
mkPat : Str -> Pattern = \pat ->
case pat of {
w + "ف" + x + "ع" + y + "ل" + z
w + "ف" + x + "ع" + y + "ل" + z
=> { h = w ; m1 = x; m2 = y; t = z} ;
w + "ف" + x + ("ع"|"ل") + y
=> { h = w ; m1 = x; m2 = ""; t = y}
@@ -145,7 +145,7 @@ resource ResAra = PatternsAra ** open Prelude, Predef, OrthoAra, ParamX in {
liPrep : Preposition = mkPrefix (
pre { #pronSuffAndOther => "لِ" ;
#pronSuff => "لَ" ;
_ => "لِ"
_ => "لِ"
}) Dat ;
biPrep : Preposition = mkPrefix "بِ" ;
@@ -173,15 +173,16 @@ resource ResAra = PatternsAra ** open Prelude, Predef, OrthoAra, ParamX in {
uttAP : AP -> (Gender => Str) ;
uttAP ap = \\g => ap.s ! NoHum ! g ! Sg ! Indef ! Bare ; ----IL
CN : Type = Noun ** {np : Case => Str};
CN : Type = Noun ** {np : {s : Case => Str ; binds : Bool}};
-- All fields of NP
cn2str : CN -> Number -> State -> Case -> Str = \cn,n,s,c ->
cn.s ! n ! s ! c ++
cn.s2 ! n ! s ! c ++
cn.np ! c ;
bindIf cn.np.binds ++
cn.np.s ! c ;
useN : Noun -> CN = \n -> n ** {np = \\_ => []} ;
useN : Noun -> CN = \n -> n ** {np = {s = \\_ => []; binds = False}} ;
uttCN : CN -> (Gender => Str) ;
uttCN cn = \\_ => cn2str cn Sg Indef Bare ;
@@ -1066,7 +1067,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
Poss => lemma + "ت" + dec1sg ! s ! c ;
_ => word + dec1sgNoDoubleAlif ! s ! c
} ;
_ => fixShd word (dec1sg ! s ! c)
_ => fixShd word (dec1sg ! s ! c)
}) ;
sing : Str -> State => Case => Str = \word ->
@@ -1074,15 +1075,15 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
-- This only applies for singular indefinite
x + y@? + #hamza => defArt s c (
case <s,c> of { -- if hamza was last, it's now in the body
<Indef,Acc> =>
<Indef,Acc> =>
case y of {
#vstar => word + dec1sgNoDoubleAlif ! Indef ! Acc ;
_ => let an : Str = dec1sg ! Indef ! Acc ;
hmz : Str = bHmz x an ;
in x + y + hmz + an } ;
_ => word + dec1sg ! s ! c }) ;
_ => word + dec1sg ! s ! c }) ;
-- The rest is identical with singulars and broken plurals
_ => brkPl word ! s ! c
_ => brkPl word ! s ! c
} ;
@@ -1228,7 +1229,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
};
-- TODO: this isn't actually because of gender, it "just happens".
-- Refactor the whole sdfN and make variant with a parameter
-- Refactor the whole sdfN and make variant with a parameter
-- whether to insert a و or ه or something else /IL
mkAtMasc : Str -> Str = \x ->
case x of {
@@ -1431,7 +1432,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
agrNP : Agr -> NP = \agr -> emptyNP ** {a = agr} ;
-- e.g. al-jamii3, 2a7ad
regNP : Str -> Number -> State -> NP = \word,n,s ->
regNP : Str -> Number -> State -> NP = \word,n,s ->
agrNP {pgn = Per3 Masc n ; isPron = False} ** {
s = \\c => fixShd word (dec1sg ! s ! c) ;
} ;
@@ -1610,11 +1611,11 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
};
-- very unsure about this /IL
sc : Preposition = case o of {
sc : Preposition = case o of {
Subord => {s=[]; c=Acc; binds=False} ;
_ => case np.a.isPron of {
True => noPrep ; -- to prevent weird stuff with VVs, might be overly specific
_ => vp.sc }
_ => vp.sc }
} ;
subj = np.empty ++ sc.s ++ bindIf sc.binds
++ case vp.isPred of {
@@ -1625,7 +1626,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
vp.obj.a.isPron np.a.isPron
(vStr vp pgn t p o)
vp.obj.s
(pred vp pgn t p)
(pred vp pgn t p)
vp.s2
subj
} ;
@@ -1635,7 +1636,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
\o,objIsPron,subjIsPron,verb,obj,pred,adv,subj ->
let cl = wordOrderNoSubj o objIsPron verb obj pred adv in
case o of {
Subord =>
Subord =>
let bind = if_then_Str subjIsPron BIND [] -- in subord. clause, subj. pronoun binds to the main verb
in cl.before ++ bind ++ subj ++ cl.after ;
_ => cl.before ++ subj ++ cl.after
@@ -1647,19 +1648,19 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
VOS => {before = verb ++ obj ++ pred ++ adv; after = []} ;
Verbal => case objIsPron of {
True => {before = verb ++ obj ; after = adv ++ pred} ; -- obj. clitic attaches directly to the verb
False => {before = verb ; after = obj ++ adv ++ pred}
False => {before = verb ; after = obj ++ adv ++ pred}
} ;
(Nominal|Subord) => {before = [] ; after = verb ++ obj ++ adv ++ pred}
} ;
pred : VP -> PerGenNum -> ParamX.Tense -> Polarity -> Str = \vp,pgn,tn,pl ->
pred : VP -> PerGenNum -> ParamX.Tense -> Polarity -> Str = \vp,pgn,tn,pl ->
let gn = pgn2gn pgn
in case <vp.isPred,tn,pl> of {
<True, Pres, Pos> => vp.pred.s ! gn ! Nom; --xabar marfooc
_ => vp.pred.s ! gn ! Acc --xabar kaana wa laysa manSoob
} ;
vStr : VP -> PerGenNum -> ParamX.Tense -> Polarity -> Order -> Str = \vp,pgn,tn,pl,o ->
vStr : VP -> PerGenNum -> ParamX.Tense -> Polarity -> Order -> Str = \vp,pgn,tn,pl,o ->
let kataba = vp.s ! pgn ! VPPerf ;
yaktubu = vp.s ! pgn ! VPImpf Ind ;
yaktuba = vp.s ! pgn ! VPImpf Cnj ;
@@ -1710,11 +1711,11 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
subj2np : Subj -> NP = \su -> su ** {a = {pgn = emptyNP.a.pgn ; isPron = su.isPron} ; empty=[]} ;
emptyObj : Obj = {a = {gn = {g=Masc ; n=Sg} ; isPron = False}; s = []} ;
insertObj : NP -> VPSlash -> VP = \np,vp -> vp ** {
insertObj : NP -> VPSlash -> VP = \np,vp -> vp ** {
obj = {s = vp.obj.s -- old object, if there was one
++ bindIfPron np vp -- new object, bind if pronoun and not pred
++ vp.agrObj ! np.a.pgn ; -- only used for SlashV2V
a = agrLite np.a}
a = agrLite np.a}
} ;
bindIf : Bool -> Str = \b -> if_then_Str b BIND [] ;