1
0
forked from GitHub/gf-rgl

(Som) Restructure nominal morphology + numerals

This commit is contained in:
Inari Listenmaa
2019-06-27 16:19:13 +02:00
parent 388741ef8d
commit 682a0adac0
8 changed files with 292 additions and 229 deletions

View File

@@ -80,8 +80,8 @@ concrete CatSom of Cat = CommonX - [Adv] ** open ResSom, Prelude in {
-- Constructed in NumeralSom. -- Constructed in NumeralSom.
Card = {s : State => Str ; n : Number} ; Card = BaseNum ;
Numeral = {s : CardOrd => State => Str ; n : Number} ; Numeral = ResSom.Numeral ;
Digits = {s : CardOrd => Str ; n : Number} ; Digits = {s : CardOrd => Str ; n : Number} ;

View File

@@ -41,8 +41,8 @@ lin bird_N = mkN "shimbir" fem ;
-- lin bone_N = mkN "" ; -- lin bone_N = mkN "" ;
-- lin boot_N = mkN "" ; -- lin boot_N = mkN "" ;
-- lin boss_N = mkN "" ; -- lin boss_N = mkN "" ;
lin book_N = mkN "buug" ; -- TODO: irregular plural lin book_N = (mk2N "buug" "buugaag") ** {pl = F TA} ;
lin boy_N = mkN "wiil" ; lin boy_N = mk2N "wiil" "wiilal" ;
lin bread_N = mkN "rooti" ; --masc/fem lin bread_N = mkN "rooti" ; --masc/fem
-- lin break_V2 = mkV2 "" ; -- lin break_V2 = mkV2 "" ;
-- lin breast_N = mkN "" ; -- lin breast_N = mkN "" ;

View File

@@ -93,13 +93,9 @@ oper ImpP3 : NP -> VP -> Utt = notYet "ImpP3" ;
oper ImpPl1 : VP -> Utt = notYet "ImpPl1" ; oper ImpPl1 : VP -> Utt = notYet "ImpPl1" ;
oper ImpVP : VP -> Imp = notYet "ImpVP" ; oper ImpVP : VP -> Imp = notYet "ImpVP" ;
oper ImpersCl : VP -> Cl = notYet "ImpersCl" ; oper ImpersCl : VP -> Cl = notYet "ImpersCl" ;
oper IndefArt : Quant = notYet "IndefArt" ;
oper IndefArt : Quant = notYet "IndefArt" ;
oper NumCard : Card -> Num = notYet "NumCard" ; oper NumCard : Card -> Num = notYet "NumCard" ;
oper NumDigits : Digits -> Card = notYet "NumDigits" ; oper NumDigits : Digits -> Card = notYet "NumDigits" ;
oper NumNumeral : Numeral -> Card = notYet "NumNumeral" ; oper NumNumeral : Numeral -> Card = notYet "NumNumeral" ;
oper NumPl : Num = notYet "NumPl" ;
oper NumSg : Num = notYet "NumSg" ;
oper OrdDigits : Digits -> Ord = notYet "OrdDigits" ; oper OrdDigits : Digits -> Ord = notYet "OrdDigits" ;
oper OrdNumeral : Numeral -> Ord = notYet "OrdNumeral" ; oper OrdNumeral : Numeral -> Ord = notYet "OrdNumeral" ;
oper OrdNumeralSuperl : Numeral -> A -> Ord = notYet "OrdNumeralSuperl" ; oper OrdNumeralSuperl : Numeral -> A -> Ord = notYet "OrdNumeralSuperl" ;

View File

@@ -9,35 +9,36 @@ concrete NounSom of Noun = CatSom ** open ResSom, Prelude in {
-- : Det -> CN -> NP -- : Det -> CN -> NP
DetCN det cn = useN cn ** { DetCN det cn = useN cn ** {
s = sTable ; s = sTable ;
a = getAgr det.d cn.g } where { a = getAgr det.n (gender cn) } where {
sTable : Case => Str = \\c => sTable : Case => Str = \\c =>
let nfc : {nf : NForm ; c : Case} = let nfc : {nf : NForm ; c : Case} =
case <c,cn.hasMod,det.d> of { case <det.isNum,c,cn.hasMod,det.st,det.n> of {
-- special form for fem. nouns -- Numbers
<Nom,False,Indef Sg> => {nf=NomSg ; c=c} ; <True,_,_,_,_> => {nf=Numerative ; c=c} ;
-- special case for DefArt+Nom: override vowel -- special form for fem. nouns
<Nom,False,Def x NA> => {nf=Def x vU ; c=c} ; <_,Nom,False,Indefinite,Sg> => {nf=NomSg ; c=c} ;
-- Definite
<_,Nom,False,Definite,n> => {nf=Def n ; c=c} ;
-- If cn has modifier, Nom ending attaches to the modifier -- If cn has modifier, Nom ending attaches to the modifier
<Nom,True,_> => {nf=det.d ; c=Abs} ; <_,Nom,True,_,_> => {nf=Def det.n ; c=Abs} ;
_ => {nf=det.d ; c=c} _ => {nf=Def det.n ; c=c} -- TODO check
} ; } ;
detStr : Str = art = case det.n of {Sg => cn.sg ; Pl => cn.pl} ;
case <cn.isPoss,det.d,det.isPoss,cn.shortPoss> of { num = case det.isNum of {True => Sg ; _ => det.n} ;
<True, _,_,_> => det.sp ! cn.g ! nfc.c ; -- CN has undergone ComplN2 and is already quantified dt : {pref,s : Str} =
<_,Numerative,_,_> => [] ; -- s is in pref case <nfc.nf,cn.isPoss,andB det.isPoss cn.shortPoss> of {
<_,_, True,True> => det.shortPoss ; <Numerative,_,_> => {s = [] ; pref = det.s ! art ! nfc.c} ; -- determiner comes before CN
_ => det.s ! cn.g ! nfc.c <_, True,_> => {pref = [] ; s = det.sp ! gender cn ! nfc.c} ; -- CN has undergone ComplN2 and is already quantified
<_,_, True> => {pref = [] ; s = BIND ++ det.shortPoss ! art} ;
_ => {pref = [] ; s = det.s ! art ! nfc.c}
} ; } ;
pref : Str = case det.d of { in dt.pref -- if det is numeral
Numerative => det.s ! cn.g ! nfc.c ;
_ => []
} ;
in pref -- if det is numeral.
++ cn.s ! nfc.nf ++ cn.s ! nfc.nf
++ detStr -- non-numeral det ++ dt.s -- non-numeral det
++ cn.mod ! getNum (getAgr det.d Masc) ! c ++ cn.mod ! num ! c
} ; } ;
-- : PN -> NP ; -- : PN -> NP ;
@@ -74,7 +75,7 @@ DetCN det cn = useN cn ** {
-- : Det -> NP ; -- : Det -> NP ;
DetNP det = { DetNP det = {
s = det.sp ! Masc ; ---- Any way to decide for gender here? s = det.sp ! Masc ; ---- Any way to decide for gender here?
a = getAgr det.d Masc ; a = getAgr det.n Masc ;
isPron = False ; isPron = False ;
} ; } ;
@@ -91,25 +92,24 @@ DetCN det cn = useN cn ** {
-- quantifier and an optional numeral can be discerned. -- quantifier and an optional numeral can be discerned.
-- : Quant -> Num -> Det ; -- : Quant -> Num -> Det ;
DetQuant quant num = quant ** { DetQuant quant num = let indep = Hal in quant ** {
s = \\g,c => case <num.n,g> of { s = \\da,c =>
<Sg,Masc> => num.s ! quant.st ++ quant.s ! SgMasc ! c ; case num.isNum of {
<Sg,Fem> => num.s ! quant.st ++ quant.s ! SgFem ! c ; True => num.s ! indep ++ quant.s ! num.da ! c ++ num.thousand ;
-- gender-flipped allomorphs in plural; TODO needs more fine-grained rules False => num.s ! indep ++ quant.s ! da ! c ++ num.thousand } ;
<Pl,Fem> => num.s ! quant.st ++ quant.s ! SgMasc ! c ;
<Pl,Masc> => num.s ! quant.st ++ quant.s ! SgFem ! c } ;
sp = \\g,c => case <num.n,g> of { sp = \\g,c => case <num.n,g> of { -- TODO check what happens when num.isNum
<Sg,Masc> => num.s ! quant.st ++ quant.sp ! SgMasc ! c ; <Sg,Masc> => num.s ! indep ++ quant.sp ! SgMasc ! c ++ num.thousand ;
<Sg,Fem> => num.s ! quant.st ++ quant.sp ! SgFem ! c ; <Sg,Fem> => num.s ! indep ++ quant.sp ! SgFem ! c ++ num.thousand ;
-- Independent form uses plural morpheme, not gender-flipped allomorph -- Independent form uses plural morpheme, not gender-flipped allomorph
<Pl,_> => num.s ! quant.st ++ quant.sp ! PlInv ! c } ; <Pl,_> => num.s ! indep ++ quant.sp ! PlInv ! c ++ num.thousand } ;
isNum = num.isNum ;
d = case <num.isNum,quant.st> of { n = num.n
<True,_> => Numerative ;
<False,Definite> => Def num.n quant.v ;
<False,Indefinite> => Indef num.n } ;
} ; } ;
-- d = case <num.isNum,quant.st> of {
-- <True,_> => Numerative ;
-- <False,Definite> => Def num.n quant.v ;
-- <False,Indefinite> => Indef num.n } ;
-- : Quant -> Num -> Ord -> Det ; -- these five best -- : Quant -> Num -> Ord -> Det ; -- these five best
DetQuantOrd quant num ord = DetQuantOrd quant num ord =
@@ -125,8 +125,8 @@ DetCN det cn = useN cn ** {
-- the "kernel" of a determiner. It is, however, the $Num$ that determines -- the "kernel" of a determiner. It is, however, the $Num$ that determines
-- the inherent number. -- the inherent number.
NumSg = {s = \\_ => [] ; n = Sg ; isNum = False} ; NumSg = baseNum ;
NumPl = {s = \\_ => [] ; n = Pl ; isNum = False} ; NumPl = baseNum ** {n = Pl} ;
-- : Card -> Num ; -- : Card -> Num ;
NumCard card = card ** {isNum = True} ; NumCard card = card ** {isNum = True} ;
@@ -135,7 +135,7 @@ DetCN det cn = useN cn ** {
-- NumDigits dig = { s = dig.s ! NCard ; n = dig.n } ; -- NumDigits dig = { s = dig.s ! NCard ; n = dig.n } ;
-- : Numeral -> Card ; -- : Numeral -> Card ;
NumNumeral num = num ** {s = num.s ! NCard}; NumNumeral num = num ; -- ** {s = num.s ! NCard};
{- {-
-- : AdN -> Card -> Card ; -- : AdN -> Card -> Card ;
@@ -145,7 +145,7 @@ DetCN det cn = useN cn ** {
OrdDigits digs = digs ** { s = digs.s ! NOrd } ; OrdDigits digs = digs ** { s = digs.s ! NOrd } ;
-} -}
-- : Numeral -> Ord ; -- : Numeral -> Ord ;
OrdNumeral num = num ** {s = num.s ! NOrd ! Indefinite} ; OrdNumeral num = num ** {s = num.ord} ;
{- {-
-- : A -> Ord ; -- : A -> Ord ;
@@ -166,18 +166,15 @@ DetCN det cn = useN cn ** {
-- : Pron -> Quant -- : Pron -> Quant
PossPron pron = PossPron pron =
let p = pron.poss ; let p = pron.poss ;
gntbl = gnTable (BIND ++ p.sp ! SgMasc)
(BIND ++ p.sp ! SgFem)
(BIND ++ p.sp ! PlInv)
in DefArt ** { in DefArt ** {
shortPoss = BIND ++ p.s ; shortPoss = p.short ;
isPoss = True ; isPoss = True ;
s = \\gn,c => let casevow = case c of {Nom => "u" ; Abs => "a"} s = \\da,c => let casevow = case c of {Nom => "u" ; Abs => "a"}
in gntbl ! gn ++ BIND ++ casevow ; in BIND ++ p.s ! da ++ BIND ++ casevow ;
sp = \\gn,c => let prefix = case gn of {SgFem => "t" ; _ => "k"} ; sp = \\gn,c => let prefix = case gn of {SgFem => "t" ; _ => "k"} ;
casevow = case c of {Nom => "u" ; Abs => "a"} casevow = case c of {Nom => "u" ; Abs => "a"}
in prefix ++ gntbl ! gn ++ BIND ++ casevow ; in prefix ++ BIND ++ p.sp ! gn ++ BIND ++ casevow ;
v = p.v
} ; } ;
--2 Common nouns --2 Common nouns
@@ -188,19 +185,19 @@ DetCN det cn = useN cn ** {
-- : N2 -> NP -> CN ; -- Sahra hooyadeed -- : N2 -> NP -> CN ; -- Sahra hooyadeed
ComplN2 n2 np = let cn = useN n2 in cn ** {s = \\nf => ComplN2 n2 np = let cn = useN n2 in cn ** {s = \\nf =>
let qnt = PossPron (pronTable ! np.a) ; let num = case nf of {
Def n => n ;
det = case cn.shortPoss of {
True => qnt.shortPoss ;
_ => qnt.s ! nf2gennum nf cn.g ! Abs } ;
num = case nf of {
Indef n => n ; Indef n => n ;
Def n v => n ;
_ => Sg } ; _ => Sg } ;
art = case num of {Sg => cn.sg ; Pl => cn.pl} ;
qnt = PossPron (pronTable ! np.a) ;
det = case cn.shortPoss of {
True => qnt.shortPoss ! art ;
_ => qnt.s ! n2.sg ! Abs } ;
noun = case np.isPron of { noun = case np.isPron of {
True => (pronTable ! np.a).sp ; -- long subject pronoun True => (pronTable ! np.a).sp ; -- long subject pronoun
False => np.s ! Abs } False => np.s ! Abs }
in noun ++ cn.s ! Def num qnt.v ++ det ; in noun ++ cn.s ! Def num ++ BIND ++ det ;
isPoss = True} ; isPoss = True} ;
{- {-

View File

@@ -3,15 +3,13 @@ concrete NumeralSom of Numeral = CatSom [Numeral,Digits] **
oper oper
LinDigit : Type = { LinDigit : Type = {
s : DForm => CardOrd => State => Str -- TODO: for 1, hal and mid. variation kow-koob implemented with pre. unit : {s : DForm => Str ; ord : Str ; da : DefArticle} ;
ten : {s, ord : Str ; da : DefArticle}
} ; } ;
mkNum3 : (ucard,tcard,uord : Str) -> Gender -> LinDigit = \uc,tc,uo,g -> {s = mkNum3 : (ucard,tcard,uord : Str) -> DefArticle -> LinDigit = \uc,tc,uo,ud -> {
\\df,co,s => case <co,df,s> of { unit = {s = \\df => uc ; ord = uo ; da = ud} ;
<NOrd,Unit,_> => uo ; ten = {s = tc ; ord = tc + "aad" ; da = M KA}
<NOrd,Ten, _> => tc + "aad" ;
<NCard,Unit,s> => nf2state (mkNg uc g) ! s ;
<NCard,Ten, s> => nf2state (mkN1 tc) ! s }
} ; } ;
mkNum2 : (ucard,tcard : Str) -> LinDigit = \uc,tc -> mkNum2 : (ucard,tcard : Str) -> LinDigit = \uc,tc ->
@@ -19,20 +17,25 @@ oper
x + "a" => x + "aad" ; -- ?? x + "a" => x + "aad" ; -- ??
x + #v + c@#c => x + c + "aad" ; x + #v + c@#c => x + c + "aad" ;
_ => uc + "aad" } ; _ => uc + "aad" } ;
in mkNum3 uc tc uo Fem ; in mkNum3 uc tc uo (F DA) ;
mkNum2Masc : (ucard,tcard : Str) -> LinDigit = \uc,tc -> mkNum2Masc : (ucard,tcard : Str) -> LinDigit = \uc,tc ->
let uo : Str = case uc of { let uo : Str = case uc of {
x + "a" => x + "aad" ; -- ?? x + "a" => x + "aad" ; -- ??
x + #v + c@#c => x + c + "aad" ; x + #v + c@#c => x + c + "aad" ;
_ => uc + "aad" } ; _ => uc + "aad" } ;
in mkNum3 uc tc uo Masc ; in mkNum3 uc tc uo (M KA) ;
lincat lincat
Digit = LinDigit ; Digit = LinDigit ;
Sub10, Sub100, Sub1000, Sub1000000 = Sub10, Sub100, Sub1000, Sub1000000 = {
{s : CardOrd => State => Str ; n : Number} ; s : DForm => Str ;
thousand : Str ; -- TODO figure out if this really works so
ord : Str ;
da : DefArticle ;
n : Number
} ;
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
@@ -40,9 +43,10 @@ lincat
-- num : Sub1000000 -> Numeral ; -- num : Sub1000000 -> Numeral ;
lin num x = x ; lin num x = x ;
oper kow : Str = "kow" ; --pre {"iyo" => "koob" ; _ => "kow"} ; oper kow : DForm => Str = table {Kow => "kow" ; Hal => "hal" ; Mid => "mid"} ;
oper n1 : LinDigit = let one : LinDigit = mkNum2 "kow" "toban" in one ** {
oper n1 = mkNum3 kow "toban" "kowaad" Fem ; unit = one.unit ** {s = kow}
} ;
lin n2 = mkNum2 "laba" "labaatan" ; lin n2 = mkNum2 "laba" "labaatan" ;
lin n3 = mkNum2 "saddex" "soddon" ; lin n3 = mkNum2 "saddex" "soddon" ;
lin n4 = mkNum2 "afar" "afartan"; lin n4 = mkNum2 "afar" "afartan";
@@ -50,42 +54,67 @@ lin n5 = mkNum2 "shan" "konton";
lin n6 = mkNum2 "lix" "lixdan" ; lin n6 = mkNum2 "lix" "lixdan" ;
lin n7 = mkNum2 "toddoba" "toddobaatan" ; lin n7 = mkNum2 "toddoba" "toddobaatan" ;
lin n8 = mkNum2Masc "siddeed" "siddeetan" ; lin n8 = mkNum2Masc "siddeed" "siddeetan" ;
lin n9 = mkNum2Masc "sagaal" "sagaaashan" ; lin n9 = mkNum2Masc "sagaal" "sagaashan" ;
lin pot01 = {s = n1.s ! Unit ; n = Sg} ; lin pot01 = n1.unit ** {n = Sg ; thousand = []} ;
lin pot0 d = {s = d.s ! Unit ; n = Pl} ; lin pot0 d = d.unit ** {n = Pl ; thousand = []} ;
lin pot110 = {s = n1.s ! Ten ; n = Pl} ; lin pot110 = n1.ten ** {
lin pot111 = {s = \\co,s => "koob iyo" ++ n1.s ! Ten ! co ! s ; n = Pl} ; s = \\df => n1.ten.s ;
lin pot1to19 d = {s = \\co,s => d.s ! Unit ! co ! s ++ n1.s ! Ten ! co ! s ; n=Pl} ; thousand = [] ;
n = Pl
} ;
lin pot111 = {
s = \\_ => "koob iyo" ++ n1.ten.s ;
ord = "koob iyo" ++ n1.ten.ord ;
thousand = [] ;
da = M KA ; -- TODO check
n = Pl
} ;
lin pot1to19 d = {
s = \\_ => d.unit.s ! Kow ++ "iyo" ++ n1.ten.s ;
thousand = [] ;
ord = d.unit.s ! Kow ++ "iyo" ++ n1.ten.ord ;
da = M KA ; -- TODO check
n = Pl
} ;
lin pot0as1 n = n ; lin pot0as1 n = n ;
lin pot1 d = {s = d.s ! Ten ; n=Pl}; lin pot1 d = d.ten ** {
-- {s = d.s ! Unit ; s = \\df => d.ten.s ;
-- n = Pl} ; thousand = [] ;
lin pot1plus d e = { n = Pl
s = \\co,s => e.s ! co ! Indefinite ++ "iyo" ++ d.s ! Ten ! co ! s ; } ;
n = Pl} ; lin pot1plus d e = d.ten ** {
s = \\b => d.unit.s ! Kow ++ "iyo" ++ e.s ! b ;
ord = d.unit.s ! Kow ++ "iyo" ++ e.ord ; -- TODO check
thousand = [] ;
n = Pl ;
} ;
lin pot1as2 n = n ; lin pot1as2 n = n ;
lin pot2 d = d ** {s = \\co,s => d.s ! co ! s ++ "boqol"} ; -- TODO lin pot2 d = d ** {
lin pot2plus d e = { thousand = "boqol" ; -- TODO check
s = \\co,s => d.s ! co ! Indefinite ++ "boqol iyo" ++ e.s ! co ! s ; ord = d.s ! Kow ++ "boqlaad"
} ; -- TODO what's the def. art. allomorph?
lin pot2plus d e = d ** {
s = \\b => d.s ! b ++ "boqol iyo" ++ e.s ! b ;
ord = d.ord ++ "boqol iyo" ++ e.ord ;
n = Pl} ; n = Pl} ;
lin pot2as3 n = n ; lin pot2as3 n = n ;
lin pot3 n = n ; lin pot3 n = n ** {
thousand = "kun" ;
lin pot3plus n m = { ord = n.s ! Kow ++ "kunaad" ;
s = \\co,s => n.s ! co ! s ++ "iyo" ++ m.s ! co ! s ; --da = M KA ; -- TODO check
n = n.n } ; n = Pl } ;
lin pot3plus n m = n ** {
s = \\b => n.s ! b ++ "kun iyo" ++ m.s ! b ;
ord = n.ord ++ "kun iyo" ++ m.ord ;
n = Pl} ;
--TODO: --TODO:
-- my three cats -- two thousand small cats
-- * saddexd &+ ayg &+ a bisadood -- => laba kun oo bisadood oo yar (kun and bisadood are both attributes)
-- => saddexd &+ ayd &+ a bisadood
-- my *two* thousand small cats
-- => laba kun oo bisadood oo yar (kun is an attribute, bisadood is an attribute)
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
lincat Dig = TDigit ; lincat Dig = TDigit ;
@@ -100,7 +129,6 @@ oper
n = num } ; n = num } ;
lin D_0 = mkDig "0" ; lin D_0 = mkDig "0" ;
lin D_1 = mk2Dig "1" Sg ; lin D_1 = mk2Dig "1" Sg ;
lin D_2 = mkDig "2" ; lin D_2 = mkDig "2" ;

View File

@@ -24,9 +24,54 @@ oper
-- Morphophonology -- Morphophonology
param param
Morpheme = mO | mKa | mTa ; -- Allomorphs for the definite article
-- | mKii | mTii ; -- TODO check if needed DefTA = TA | DA | SHA | DHA ;
DefKA = KA | GA | A_ | HA ;
DefArticle = M DefKA | F DefTA ;
oper
defAllomorph : Str -> DefArticle = \wiilka ->
case wiilka of {
_ + "ta" => F DA ; _ + "sha" => F SHA ;
_ + "da" => F DA ; _ + "dha" => F DHA ;
_ + "ka" => M KA ; _ + "aha" => M HA ;
_ + "ga" => M GA ; _ => M A_ } ;
-- Use always via quantTable!
defStems : DefArticle => Str = table {
M KA => "k" ;
M GA => "g" ;
M A_ => [] ; -- If we want magac~magiciisa, we need to split this into CA and A_.
M HA => "ah" ; -- NB. stem vowel replaced
F TA => "t" ;
F DA => "d" ;
F SHA => "sh" ; -- NB. stem l replaced
F DHA => "dh"
} ;
quantTable = overload {
quantTable : Str -> DefArticle=>Str = \iis -> let i = head iis in table {
M HA => i + "h" + iis ;
x => defStems ! x + iis
} ;
quantTable : (ayg,ayd : Str) -> DefArticle=>Str = \ayg,ayd ->
let a = head ayg in table {
M HA => a + "h" + ayg ;
M x => defStems ! M x + ayg ;
F y => defStems ! F y + ayd
}
} ;
head : Str -> Str = \s -> case s of {
x@? + _ => x ;
_ => "" -- Predef.error "head: empty string."
} ;
--------------------------------------------
-- Old version, may be deprecated eventually
param
Morpheme = mO | mKa | mTa ;
oper oper
allomorph : Morpheme -> Str -> Str = \x,stem -> allomorph : Morpheme -> Str -> Str = \x,stem ->
case x of { case x of {
@@ -34,28 +79,18 @@ oper
d@("b"|"d"|"r"|"l"|"m"|"n") => d + "o" ; d@("b"|"d"|"r"|"l"|"m"|"n") => d + "o" ;
"c"|"g"|"i"|"j"|"x"|"s" => "yo" ; "c"|"g"|"i"|"j"|"x"|"s" => "yo" ;
_ => "o" } ; _ => "o" } ;
mTa => case stem of { -- Saeed p. 29 mTa => case stem of { -- Saeed p. 29
_ + ("dh") => "dha" ; ---- ??? _ + ("dh") => "dha" ;
_ + (#v|"'"|"c"|"d"|"h"|"kh"|"q"|"w"|"x"|"y") => "da" ; _ + (#v|"'"|"c"|"d"|"h"|"kh"|"q"|"w"|"x"|"y") => "da" ;
_ + "l" => "sha" ; _ + "l" => "sha" ;
_ {- b,f,g,n,r,s -} => "ta" } ; _ {- b,f,g,n,r,s -} => "ta" } ;
mKa => case stem of { -- Saeed p. 28-29 mKa => case stem of { -- Saeed p. 28-29
_ + ("r"|"g"|"w"|"y"|"i"|"u"|"aa"|"oo"|"uu") => "ga" ; _ + ("r"|"g"|"w"|"y"|"i"|"u"|"aa"|"oo"|"uu") => "ga" ;
_ + ("q"|"'"|"kh"|"x"|"c"|"h") => "a" ; _ + ("q"|"'"|"kh"|"x"|"c"|"h") => "a" ;
_ + ("e"|"o") => "ha" ; _ + ("e"|"o") => "ha" ;
_ {- b,d,dh,f,j,l,n,r,sh-} => "ka" } _ {- b,d,dh,f,j,l,n,r,sh-} => "ka" }
{-- TODO check if needed/implement elsewhere:
mKii => case stem of {
_+ #vv + #c => init (allomorph mKa stem) ++ "ii" ; -- Should not change stem vowel
_ + ("'"|"x"|"c") => "ii" ; -- Should change stem vowel
_ => init (allomorph mKa stem) ++ "ii" } ;
mTii => init (allomorph mTa stem) ++ "ii" -}
} ; } ;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Nouns -- Nouns
@@ -82,48 +117,32 @@ param
State = Definite | Indefinite ; State = Definite | Indefinite ;
NForm = NForm = Def Number | Indef Number | NomSg | Numerative ;
Indef Number
| Def Number Vowel -- Stems for definite and determinative suffixes
-- Special forms only for fem. nouns ending in consonant.
| Numerative -- When modified by a number: either pl gen or sg abs
| NomSg ;
oper oper
getAgr : NForm -> Gender -> Agreement = \n,g -> getAgr : Number -> Gender -> Agreement = \n,g ->
case n of { Indef Pl|Def Pl _ => Pl3 ; case n of { Pl => Pl3 ;
_ => Sg3 g } ; _ => Sg3 g } ;
getNum : Agreement -> Number = \a -> getNum : Agreement -> Number = \a ->
case a of { Sg1|Sg2|Sg3 _ => Sg ; _ => Pl } ; case a of { Sg1|Sg2|Sg3 _ => Sg ; _ => Pl } ;
agr2agrplus : (isPron : Bool) -> Agreement -> AgreementPlus = \isPron,a -> agr2agrplus : (isPron : Bool) -> Agreement -> AgreementPlus = \isPron,a ->
case isPron of {True => IsPron a ; False => NotPronP3} ; case isPron of {True => IsPron a ; False => NotPronP3} ;
nf2state : {s:NForm=>Str} -> State=>Str = \ss -> table { -- gn2gennum : Gender -> Number -> GenNum = \g,n ->
Definite => ss.s ! Def Sg vA ; -- case <g,n> of {
Indefinite => ss.s ! Indef Sg -- <Masc,Sg> => SgMasc ;
} ; -- <Fem,Sg> => SgFem ;
-- _ => PlInv } ;
gn2gennum : Gender -> Number -> GenNum = \g,n ->
case <g,n> of {
<Masc,Sg> => SgMasc ;
<Fem,Sg> => SgFem ;
_ => PlInv } ;
nf2gennum : NForm -> Gender -> GenNum = \nf,g ->
gn2gennum g (getNum (getAgr nf g)) ;
gender : {sg : DefArticle} -> Gender = \n ->
case n.sg of {M _ => Masc ; F _ => Fem} ;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Numerals -- Numerals
param param
DForm = Hal | Mid | Kow ; -- three variants of number 1
DForm = Unit | Ten ;
-- If need to optimise: can remove one multiple of 2, but harder to understand
-- CardOrdDFS = Odfs DForm | Cdfs DForm State ;
--
-- CardOrdState = Ost | Cst State ;
CardOrd = NOrd | NCard ; CardOrd = NOrd | NCard ;

View File

@@ -18,7 +18,7 @@ concrete PhraseSom of Phrase = CatSom ** open Prelude, ResSom in {
UttVP vp = { s = linVP vp } ; UttVP vp = { s = linVP vp } ;
UttAdv adv = adv ; UttAdv adv = adv ;
UttCN n = {s = linCN n } ; UttCN n = {s = linCN n } ;
UttCard n = {s = n.s ! Indefinite} ; UttCard n = {s = n.s ! Mid} ;
UttAP ap = { s = ap.s ! AF Sg Abs } ; UttAP ap = { s = ap.s ! AF Sg Abs } ;
UttInterj i = i ; UttInterj i = i ;

View File

@@ -4,49 +4,54 @@ resource ResSom = ParamSom ** open Prelude, Predef, ParamSom in {
-- Nouns -- Nouns
oper oper
Noun : Type = {s : NForm => Str; g : Gender ; shortPoss : Bool} ; Noun : Type = {
s : NForm => Str ;
sg,
pl : DefArticle ;
shortPoss : Bool ;
} ;
Noun2 : Type = Noun ; -- TODO eventually more parameters? Noun2 : Type = Noun ; -- TODO eventually more parameters?
Noun3 : Type = Noun ; Noun3 : Type = Noun ;
CNoun : Type = Noun ** { CNoun : Type = Noun ** {
mod : Number => Case => Str ; mod : Number => Case => Str ;
hasMod : Bool ; hasMod : Bool ;
isPoss : Bool -- to prevent impossible forms in ComplN2 with Ns that have short possessive, e.g. "the father of NP". isPoss : Bool -- to prevent impossible forms in ComplN2 with Ns that have short possessive, e.g. "father"
} ; } ;
PNoun : Type = {s : Str ; a : Agreement} ; PNoun : Type = {s : Str ; a : Agreement} ;
mkPNoun : Str -> Agreement -> PNoun = \str,agr -> {s = str ; a = agr} ; mkPNoun : Str -> Agreement -> PNoun = \str,agr -> {s = str ; a = agr} ;
mkNoun : (x1,_,_,x4 : Str) -> Gender -> Noun = \wiil,wiilka,wiilal,wiilasha,gender -> mkNoun : (x1,_,_,x4 : Str) -> Gender -> Noun = \wiil,wiilka,wiilal,wiilasha,gender -> {
let bisadi = case gender of s = table {
Def Sg => hooya ; Def Pl => gury ;
Indef Sg => wiil ; Indef Pl => wiilal ;
-- Special forms for feminine nouns
NomSg => bisadi ; Numerative => bisadood
} ;
sg = defAllomorph wiilka ;
pl = defAllomorph wiilasha ;
shortPoss = False
} where {
hooya : Str = case wiilka of {
aabb + "aha" => aabb ;
hooya + "da" => hooya ;
wiila + "sha" => wiila ;
_ => wiil} ;
gury : Str = case wiilasha of {
gury + "aha" => gury ;
magacya + "da" => magacya ;
wiila + "sha" => wiila ;
_ => wiilal} ;
bisadi : Str = case gender of
{ Fem => case wiil of { _ + #c => wiil+"i" ; _ => wiil} ; { Fem => case wiil of { _ + #c => wiil+"i" ; _ => wiil} ;
Masc => wiil } ; Masc => wiil } ;
bisadood = case gender of bisadood : Str = case gender of
{ Fem => case wiilal of {_ + "o" => wiilal+"od" ; _ => wiil} ; { Fem => case wiilal of {_ + "o" => wiilal+"od" ; _ => wiil} ;
Masc => wiil } ; Masc => wiil }
defStems : Str -> Vowel => Str = \s -> case s of {
ilk + "aha" =>
table { vE => ilk+"eh" ;
vI => ilk+"ih" ;
vO => ilk+"oh" ;
vU => ilk+"uh" ;
_ => ilk+"ah"
} ;
_ => table { _ => init s }
} ;
in { s = table {
Indef Sg => wiil ;
Indef Pl => wiilal ;
Def Sg vow => defStems wiilka ! vow ;
Def Pl vow => defStems wiilasha ! vow ;
NomSg => bisadi ; -- Special form for fem. nouns ending in consonant
Numerative => case bisadood of {_+"ood" => bisadood ; _ => wiil}
} ; } ;
g = gender ;
shortPoss = False} ;
------------------------- -------------------------
-- Regular noun paradigms -- Regular noun paradigms
nHooyo, nAabbe, nMas, nUl, nGuri, nXayawaan : Str -> Noun ; nHooyo, nAabbe, nMas, nUl, nGuri, nXayawaan : Str -> Noun ;
@@ -62,10 +67,15 @@ oper
-- 3) Masculine, plural with duplication -- 3) Masculine, plural with duplication
nMas mas = let s = last mas ; nMas mas = let s = last mas ;
a = last (init mas) ; a = last (init mas) ;
ka = allomorph mKa mas ; ka = allomorph mKa mas in
ta = allomorph mTa mas ; mkNoun mas (mas + ka) (mas + a + s) (mas + a + s + ka) Masc ;
sha = case ta of {"sha" => ta ; _ => s + ta } in
mkNoun mas (mas + ka) (mas + a + s) (mas + a + sha) Masc ; -- Irregular one-syllable masculine word
nWiil : (_,_ : Str) -> Noun = \wiil,wiilal ->
let ka = allomorph mKa wiil ;
sha = allomorph mTa wiilal ;
wiila : Str = case wiilal of {wiila + "l" => wiila ; _ => wiilal} in
mkNoun wiil (wiil + ka) wiilal (wiila + sha) Masc ;
-- 4a) Feminine, plural with ó -- 4a) Feminine, plural with ó
nUl ul = let o = case last ul of { "i" => "yo" ; _ => "o" } ; nUl ul = let o = case last ul of { "i" => "yo" ; _ => "o" } ;
@@ -94,10 +104,7 @@ oper
in mkNoun maalin (maalin + ta) maalmo (init maalmo + aha) g ; in mkNoun maalin (maalin + ta) maalmo (init maalmo + aha) g ;
------------------------- -------------------------
-- Smart paradigm -- Smart paradigms
-- Substantiv som slutar på o/ad är så gott som alltid feminina, t.ex. qaáddo sked, bisád katt.
-- Substantiv som slutar på e är så gott som alltid maskulina, t.ex. dúbbe hammare, fúre nyckel.
-- För övriga ord säger ordets form dessvärre väldigt lite om ordets genus. Däremot kan betoningens plats i ordet väldigt ofta avslöja ordets genus. Man kan alltså i flesta fall höra vilket genus ett substantiv har.
mkN1 : Str -> Noun = \n -> case n of { mkN1 : Str -> Noun = \n -> case n of {
_ + ("ad"|"adh") => nUl n ; _ + ("ad"|"adh") => nUl n ;
@@ -110,6 +117,8 @@ oper
| (#v + #c) => nMas n ; | (#v + #c) => nMas n ;
_ => nXayawaan n } ; _ => nXayawaan n } ;
mk2N : Str -> Str -> Noun = nWiil ;
mkNg : Str -> Gender -> Noun = \n,g -> case n of { mkNg : Str -> Gender -> Noun = \n,g -> case n of {
_ -- + ("r"|"n"|"l"|"g") _ -- + ("r"|"n"|"l"|"g")
=> case g of { => case g of {
@@ -130,7 +139,7 @@ oper
useN : Noun -> CNoun ** BaseNP = \n -> n ** useN : Noun -> CNoun ** BaseNP = \n -> n **
{ mod = \\_,_ => [] ; hasMod = False ; { mod = \\_,_ => [] ; hasMod = False ;
a = Sg3 n.g ; isPron,isPoss = False ; a = Sg3 (gender n) ; isPron,isPoss = False ;
} ; } ;
emptyNP : NounPhrase = { emptyNP : NounPhrase = {
@@ -149,9 +158,10 @@ oper
Pronoun : Type = NounPhrase ** { Pronoun : Type = NounPhrase ** {
poss : { -- for PossPron : Pron -> Quant poss : { -- for PossPron : Pron -> Quant
s : DefArticle => Str ;
sp : GenNum => Str ; -- independent forms, e.g. M:kayga F:tayda Pl:kuwayga sp : GenNum => Str ; -- independent forms, e.g. M:kayga F:tayda Pl:kuwayga
s : Str ; -- short possessive suffix: e.g. family members, my/your name short : DefArticle => Str -- short possessive suffix: e.g. family members, my/your name
v : Vowel} ; } ;
sp : Str ; sp : Str ;
} ; } ;
@@ -159,47 +169,47 @@ oper
Sg1 => { Sg1 => {
s = table {Nom => "aan" ; Abs => "i"} ; s = table {Nom => "aan" ; Abs => "i"} ;
a = Sg1 ; isPron = True ; sp = "aniga" ; a = Sg1 ; isPron = True ; sp = "aniga" ;
poss = {s = "ay" ; v = vA ; sp = gnTable "ayg" "ayd" "uwayg"} poss = {s = quantTable "ayg" "ayd" ; short = quantTable "ay" ; sp = gnTable "ayg" "ayd" "uwayg"}
} ; } ;
Sg2 => { Sg2 => {
s = table {Nom => "aad" ; Abs => "ku"} ; s = table {Nom => "aad" ; Abs => "ku"} ;
a = Sg2 ; isPron = True ; sp ="adiga" ; a = Sg2 ; isPron = True ; sp ="adiga" ;
poss = {s = "aa" ; v = vA ; sp = gnTable "aag" "aad" "uwaag"} poss = {s = quantTable "aag" "aad" ; short = quantTable "aa" ; sp = gnTable "aag" "aad" "uwaag"}
} ; } ;
Sg3 Masc => { Sg3 Masc => {
s = table {Nom => "uu" ; Abs => []} ; s = table {Nom => "uu" ; Abs => []} ;
a = Sg3 Masc ; isPron = True ; sp ="isaga" ; a = Sg3 Masc ; isPron = True ; sp ="isaga" ;
poss = {s = "iis" ; v = vI ; sp = gnTable "iis" "iis" "uwiis"} poss = {s, short = quantTable "iis" ; sp = gnTable "iis" "iis" "uwiis"}
} ; } ;
Sg3 Fem => { Sg3 Fem => {
s = table {Nom => "ay" ; Abs => []} ; s = table {Nom => "ay" ; Abs => []} ;
a = Sg3 Fem ; isPron = True ; sp = "iyada" ; a = Sg3 Fem ; isPron = True ; sp = "iyada" ;
poss = {s = "eed" ; v = vE ; sp = gnTable "eed" "eed" "uweed"} poss = {s, short = quantTable "eed" ; sp = gnTable "eed" "eed" "uweed"}
} ; } ;
Pl1 Excl => { Pl1 Excl => {
s = table {Nom => "aan" ; Abs => "na"} ; s = table {Nom => "aan" ; Abs => "na"} ;
a = Pl1 Incl ; isPron = True ; sp ="annaga" ; a = Pl1 Incl ; isPron = True ; sp ="annaga" ;
poss = {s = "een" ; v = vE ; sp = gnTable "eenn" "eenn" "uweenn"} poss = {s = quantTable "eenn" ; short = quantTable "een" ; sp = gnTable "eenn" "eenn" "uweenn"}
} ; } ;
Pl1 Incl => { Pl1 Incl => {
s = table {Nom => "aynu" ; Abs => "ina"} ; s = table {Nom => "aynu" ; Abs => "ina"} ;
a = Pl1 Incl ; isPron = True ; sp ="innaga" ; a = Pl1 Incl ; isPron = True ; sp ="innaga" ;
poss = {s = "een" ; v = vE ; sp = gnTable "eenn" "eenn" "uweenn"} poss = {s = quantTable "eenn" ; short = quantTable "een" ; sp = gnTable "eenn" "eenn" "uweenn"}
} ; } ;
Pl2 => { Pl2 => {
s = table {Nom => "aad" ; Abs => "idin"} ; s = table {Nom => "aad" ; Abs => "idin"} ;
a = Pl2 ; isPron = True ; sp ="idinka" ; a = Pl2 ; isPron = True ; sp ="idinka" ;
poss = {s = "iin" ; v = vI ; sp = gnTable "iinn" "iinn" "uwiinn"} poss = {s = quantTable "iinn" ; short = quantTable "iin" ; sp = gnTable "iinn" "iinn" "uwiinn"}
} ; } ;
Pl3 => { Pl3 => {
s = table {Nom => "ay" ; Abs => []} ; s = table {Nom => "ay" ; Abs => []} ;
a = Pl3 ; isPron = True ; sp = "iyaga" ; a = Pl3 ; isPron = True ; sp = "iyaga" ;
poss = {s = "ood" ; v = vO ; sp = gnTable "ood" "ood" "uwood"} poss = {s, short = quantTable "ood" ; sp = gnTable "ood" "ood" "uwood"}
} ; } ;
Impers => { Impers => {
s = table {Nom => "la" ; Abs => "??"} ; s = table {Nom => "la" ; Abs => "??"} ;
a = Impers ; isPron = True ; sp = "??" ; a = Impers ; isPron = True ; sp = "??" ;
poss = {s = "??" ; v = vA ; sp = gnTable "??" "??" "??"} poss = {s, short = quantTable "??" ; sp = gnTable "??" "??" "??"}
} }
} ; } ;
@@ -218,33 +228,50 @@ oper
-- Det, Quant, Card, Ord -- Det, Quant, Card, Ord
BaseQuant : Type = { BaseQuant : Type = {
s : DefArticle => Case => Str ;
isPoss : Bool ; isPoss : Bool ;
shortPoss : Str ; -- short form of possessive, e.g. family members shortPoss : DefArticle => Str ; -- short form of possessive, e.g. family members
st : State ;
} ; } ;
Determiner : Type = BaseQuant ** { Determiner : Type = BaseQuant ** {
s,
sp : Gender => Case => Str ; sp : Gender => Case => Str ;
d : NForm ; -- combination of number, state and vowel n : Number ;
-- isNum : Bool ; -- placement in NP + whether to choose Numerative from CN isNum : Bool ; -- placement in NP + whether to choose Numerative from CN
} ; } ;
Quant : Type = BaseQuant ** { Quant : Type = BaseQuant ** {
s,
sp : GenNum => Case => Str ; sp : GenNum => Case => Str ;
st : State ;
v : Vowel ;
} ; } ;
Num : Type = { BaseNum : Type = {
s : State => Str ; -- TODO check if enough s : DForm => Str ; -- independent or attribute
n : Number ; -- singular or plural thousand : Str ; -- TODO check where possessive suffix goes
da : DefArticle ;
n : Number
} ;
baseNum : Num = {
s = \\_ => [] ;
thousand = [] ;
da = M KA ;
n = Sg ;
isNum = False
} ;
Num : Type = BaseNum ** {
isNum : Bool -- whether to choose Numerative as the value of NForm isNum : Bool -- whether to choose Numerative as the value of NForm
} ; } ;
Numeral : Type = BaseNum ** {
ord : Str -- whether to choose Numerative as the value of NForm
} ;
baseQuant : BaseQuant = { baseQuant : BaseQuant = {
s = \\alm,c => [] ;
isPoss = False ; isPoss = False ;
shortPoss = [] shortPoss = \\_ => [] ;
st = Indefinite
} ; } ;
defQuant = defQuantBind True ; defQuant = defQuantBind True ;
@@ -252,24 +279,25 @@ oper
defQuantBind : (bind : Bool) -> (s, kan, tan, kuwan : Str) -> Vowel -> Quant = \b,s,spm,spf,spp,v -> defQuantBind : (bind : Bool) -> (s, kan, tan, kuwan : Str) -> Vowel -> Quant = \b,s,spm,spf,spp,v ->
let bind : Str -> Str = \x -> case b of {False => x ; True => BIND ++ x} ; let bind : Str -> Str = \x -> case b of {False => x ; True => BIND ++ x} ;
in baseQuant ** { in baseQuant ** {
s = \\gn,c => s = \\allomorph,c =>
let nom = case v of {NA => "u" ; _ => s + "i"} let nom = case v of {NA => "u" ; _ => s + "i"}
in case c of {Nom => bind nom ; _ => bind s} ; in case c of {
Nom => bind (quantTable nom ! allomorph) ;
_ => bind (quantTable s ! allomorph) } ;
sp = \\gn,c => sp = \\gn,c =>
let i = case c of {Nom => "i"; _ => []} let i = case c of {Nom => "i"; _ => []}
in gnTable (spm + i) (spf + i) (spp + i) ! gn ; in gnTable (spm + i) (spf + i) (spp + i) ! gn ;
st = Definite ; st = Definite ;
v = v ;
} ; } ;
gnTable : (m,f,p : Str) -> (GenNum => Str) = \m,f,p -> gnTable : (m,f,p : Str) -> (GenNum => Str) = \m,f,p ->
table {SgMasc => m ; SgFem => f ; _ => p} ; table {SgMasc => m ; SgFem => f ; _ => p} ;
indefQuant : Quant = baseQuant ** { indefQuant : Quant = baseQuant ** {
s, s = \\da,c => [] ;
sp = \\gn,c => [] ; sp = \\gn,c => [] ;
st = Indefinite ; st = Indefinite ;
v = NA ; -- Will be ignored in DetQuant -- v = NA ; -- Will be ignored in DetQuant
} ; } ;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@@ -609,6 +637,11 @@ oper
c2 = v2.c2 c2 = v2.c2
} ; } ;
passV2 : Verb2 -> VerbPhrase = \v2 -> useV v2 ** {
c2 = passive ;
c3 = v2.c2 ;
} ;
complSlash : VPSlash -> VerbPhrase = \vps -> let np = vps.obj2 in vps ** { complSlash : VPSlash -> VerbPhrase = \vps -> let np = vps.obj2 in vps ** {
comp = \\agr => comp = \\agr =>
case np.a of { case np.a of {
@@ -617,11 +650,6 @@ oper
-- if object is a pronoun, np.s is empty. -- if object is a pronoun, np.s is empty.
p2 = compl np.a vps ++ vps.secObj} -- object combines with the preposition of the verb. p2 = compl np.a vps ++ vps.secObj} -- object combines with the preposition of the verb.
-- secObj in case there was a ditransitive verb. -- secObj in case there was a ditransitive verb.
-- IsPron ag => {p1 = [] ; -- object is a pronoun => nothing is placed before the verb
-- p2 = compl np.a vps ++ vps.secObj} ; -- object combines with the preposition of the verb
-- NotPronP3 => {p1 = np.s ; -- object is a noun => it will come before verb in the sentence
-- p2 = compl np.a vps ++ vps.secObj} -- object combines with the preposition of the verb
} }
} ; } ;
@@ -630,9 +658,9 @@ oper
in prepCombTable ! agr ! combine vp.c2 vp.c3 ; in prepCombTable ! agr ! combine vp.c2 vp.c3 ;
insertComp : VPSlash -> NounPhrase -> VerbPhrase = \vp,np -> insertComp : VPSlash -> NounPhrase -> VerbPhrase = \vp,np ->
let noun = case <np.isPron,np.a> of { let noun : Str = case <np.isPron,np.a> of {
<False> => np.s ! Abs ; <False,_> => np.s ! Abs ;
<True,Sg3 _|Pl3> => (pronTable ! np.a).sp ; -- long object pronoun for 3rd person object <True,(Sg3 _|Pl3)> => (pronTable ! np.a).sp ; -- long object pronoun for 3rd person object
_ => [] } -- no long object for other pronouns _ => [] } -- no long object for other pronouns
in case vp.obj2.a of { in case vp.obj2.a of {
Unassigned => Unassigned =>
@@ -658,11 +686,6 @@ oper
} ; } ;
passV2 : Verb2 -> VerbPhrase = \v2 -> useVc v2 ** {
c2 = passive ;
c3 = v2.c2 ;
} ;
insertAdv : Adverb -> VerbPhrase -> VerbPhrase = \adv,vp -> insertAdv : Adverb -> VerbPhrase -> VerbPhrase = \adv,vp ->
case adv.c2 of { case adv.c2 of {
noPrep => vp ** {adv = adv.s} ; -- The adverb is not formed with PrepNP noPrep => vp ** {adv = adv.s} ; -- The adverb is not formed with PrepNP