1
0
forked from GitHub/gf-core

Maltese RG: fix implementation of CountNP

This commit is contained in:
john
2013-06-11 07:55:48 +00:00
parent 1366c2a53e
commit 7f952b5f8f
4 changed files with 103 additions and 34 deletions

View File

@@ -35,7 +35,7 @@ concrete LexiconMlt of Lexicon = CatMlt **
book_N = mkN "ktieb" "kotba" ; book_N = mkN "ktieb" "kotba" ;
boot_N = mkNColl "żarbuna" "żarbun" "żraben" ; boot_N = mkNColl "żarbuna" "żarbun" "żraben" ;
boss_N = mkN "mgħallem" "mgħallmin" ; boss_N = mkN "mgħallem" "mgħallmin" ;
boy_N = mkN "tifel" "tfal" ; boy_N = mkN "tifel" "subien" ;
bread_N = mkNColl "ħobża" "ħobż" "ħobżiet" ; bread_N = mkNColl "ħobża" "ħobż" "ħobżiet" ;
breast_N = possN (mkN "sider" "sdur") ; breast_N = possN (mkN "sider" "sdur") ;
brother_N2 = mkN2 (possN (mkN "ħu" "aħwa")) ; brother_N2 = mkN2 (possN (mkN "ħu" "aħwa")) ;
@@ -84,7 +84,7 @@ concrete LexiconMlt of Lexicon = CatMlt **
friend_N = possN (mkN "ħabib" "ħbieb") ; -- genderedN friend_N = possN (mkN "ħabib" "ħbieb") ; -- genderedN
fruit_N = mkNColl "frotta" "frott" "frottiet" "frottijiet" ; fruit_N = mkNColl "frotta" "frott" "frottiet" "frottijiet" ;
garden_N = mkN "ġnien" "ġonna" ; garden_N = mkN "ġnien" "ġonna" ;
girl_N = mkN "tifla" "tfal" ; girl_N = mkN "tifla" "tfajliet" ;
glove_N = mkN "ingwanta" "ingwanti" ; glove_N = mkN "ingwanta" "ingwanti" ;
gold_N = mkNColl "deheb" "dehbijiet" ; gold_N = mkNColl "deheb" "dehbijiet" ;
grammar_N = mkN "grammatika" "grammatiki" ; grammar_N = mkN "grammatika" "grammatiki" ;

View File

@@ -36,6 +36,7 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
lin lin
-- Det -> CN -> NP -- Det -> CN -> NP
-- the man
DetCN det cn = DetCN det cn =
let let
-- To stop complaining about lock fields -- To stop complaining about lock fields
@@ -63,6 +64,7 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
} ; } ;
-- Quant -> Num -> Det -- Quant -> Num -> Det
-- these five
DetQuant quant num = { DetQuant quant num = {
s = \\gen => s = \\gen =>
let gennum = case num.n of { NumX Sg => GSg gen ; _ => GPl } let gennum = case num.n of { NumX Sg => GSg gen ; _ => GPl }
@@ -80,6 +82,7 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
} ; } ;
-- Quant -> Num -> Ord -> Det -- Quant -> Num -> Ord -> Det
-- these five best
--- Almost an exact copy of DetQuant, consider factoring together --- Almost an exact copy of DetQuant, consider factoring together
DetQuantOrd quant num ord = { DetQuantOrd quant num ord = {
s = \\gen => s = \\gen =>
@@ -96,6 +99,7 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
} ; } ;
-- Det -> NP -- Det -> NP
-- these five
DetNP det = { DetNP det = {
s = \\c => det.s ! Masc ; s = \\c => det.s ! Masc ;
a = agrP3 (numform2num det.n) Masc ; a = agrP3 (numform2num det.n) Masc ;
@@ -120,6 +124,7 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
} ; } ;
-- PN -> NP -- PN -> NP
-- John
UsePN pn = { UsePN pn = {
s = \\c => pn.s ; s = \\c => pn.s ;
a = pn.a ; a = pn.a ;
@@ -128,6 +133,7 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
} ; } ;
-- Pron -> NP -- Pron -> NP
-- he
UsePron p = { UsePron p = {
s = table { s = table {
NPNom => p.s ! Personal ; NPNom => p.s ! Personal ;
@@ -140,6 +146,7 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
} ; } ;
-- Pron -> Quant -- Pron -> Quant
-- my (house)
PossPron p = { PossPron p = {
s = \\_ => p.s ! Possessive ; s = \\_ => p.s ! Possessive ;
clitic = p.s ! Suffixed ; clitic = p.s ! Suffixed ;
@@ -149,18 +156,22 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
} ; } ;
-- Predet -> NP -> NP -- Predet -> NP -> NP
-- only the man
PredetNP pred np = overwriteNPs np (\\c => pred.s ++ np.s ! c) ; PredetNP pred np = overwriteNPs np (\\c => pred.s ++ np.s ! c) ;
-- NP -> V2 -> NP -- NP -> V2 -> NP
-- the man seen
PPartNP np v2 = case v2.hasPastPart of { PPartNP np v2 = case v2.hasPastPart of {
True => overwriteNPs np (\\c => np.s ! c ++ (v2.s ! VPastPart (toGenNum np.a)).s1) ; -- raġel rieqed True => overwriteNPs np (\\c => np.s ! c ++ (v2.s ! VPastPart (toGenNum np.a)).s1) ; -- raġel rieqed
False => overwriteNPs np (\\c => np.s ! c ++ (v2.s ! VImpf (toVAgr np.a)).s1) -- mara tisma' False => overwriteNPs np (\\c => np.s ! c ++ (v2.s ! VImpf (toVAgr np.a)).s1) -- mara tisma'
} ; } ;
-- NP -> RS -> NP -- NP -> RS -> NP
-- Paris, which is here
RelNP np rs = overwriteNPs np (\\c => np.s ! c ++ "," ++ rs.s ! np.a ) ; RelNP np rs = overwriteNPs np (\\c => np.s ! c ++ "," ++ rs.s ! np.a ) ;
-- NP -> Adv -> NP -- NP -> Adv -> NP
-- Paris today
AdvNP np adv = overwriteNPs np (\\c => np.s ! c ++ adv.s) ; AdvNP np adv = overwriteNPs np (\\c => np.s ! c ++ adv.s) ;
-- Num -- Num
@@ -171,23 +182,29 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
NumCard n = n ** {hasCard = True} ; NumCard n = n ** {hasCard = True} ;
-- Digits -> Card -- Digits -> Card
-- 51
NumDigits d = {s = d.s ; n = d.n} ; NumDigits d = {s = d.s ; n = d.n} ;
-- Digits -> Ord -- Digits -> Ord
-- 51st
OrdDigits d = {s = d.s} ; OrdDigits d = {s = d.s} ;
-- Numeral -> Card -- Numeral -> Card
-- fifty-one
NumNumeral numeral = {s = numeral.s ! NCard; n = numeral.n} ; NumNumeral numeral = {s = numeral.s ! NCard; n = numeral.n} ;
-- Numeral -> Ord -- Numeral -> Ord
-- fifty-first
OrdNumeral numeral = {s = numeral.s ! NOrd} ; OrdNumeral numeral = {s = numeral.s ! NOrd} ;
-- AdN -> Card -> Card -- AdN -> Card -> Card
-- almost 51
AdNum adn card = card ** { AdNum adn card = card ** {
s = \\c => adn.s ++ card.s ! c ; s = \\c => adn.s ++ card.s ! c ;
} ; } ;
-- A -> Ord -- A -> Ord
-- warmest
OrdSuperl a = { OrdSuperl a = {
s = \\c => case a.hasComp of { s = \\c => case a.hasComp of {
True => a.s ! ASuperl ; True => a.s ! ASuperl ;
@@ -196,6 +213,7 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
} ; } ;
-- CN -> NP -- CN -> NP
-- (beer)
MassNP cn = { MassNP cn = {
s = \\c => cn.s ! Collective ; s = \\c => cn.s ! Collective ;
a = agrP3 Sg cn.g ; a = agrP3 Sg cn.g ;
@@ -204,18 +222,23 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
} ; } ;
-- N -> CN -- N -> CN
-- house
UseN n = n ; UseN n = n ;
-- N2 -> CN -- N2 -> CN
-- mother
UseN2 n2 = n2 ; -- just ignore the c2 UseN2 n2 = n2 ; -- just ignore the c2
-- N3 -> N2 -- N3 -> N2
-- distance (from this city)
Use2N3 n3 = n3 ** { c2 = n3.c2 } ; Use2N3 n3 = n3 ** { c2 = n3.c2 } ;
-- N3 -> N2 -- N3 -> N2
-- distance (to Paris)
Use3N3 n3 = n3 ** { c2 = n3.c3 } ; Use3N3 n3 = n3 ** { c2 = n3.c3 } ;
-- N2 -> NP -> CN -- N2 -> NP -> CN
-- mother of the king
ComplN2 n2 np = { ComplN2 n2 np = {
s = \\num => n2.s ! num ++ prepNP n2.c2 np ; s = \\num => n2.s ! num ++ prepNP n2.c2 np ;
g = n2.g ; g = n2.g ;
@@ -225,6 +248,7 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
} ; } ;
-- N3 -> NP -> N2 -- N3 -> NP -> N2
-- distance from this city (to Paris)
ComplN3 n3 np = { ComplN3 n3 np = {
s = \\num => n3.s ! num ++ prepNP n3.c3 np ; s = \\num => n3.s ! num ++ prepNP n3.c3 np ;
g = n3.g ; g = n3.g ;
@@ -235,48 +259,49 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude in {
} ; } ;
-- AP -> CN -> CN -- AP -> CN -> CN
-- big house
AdjCN ap cn = overwriteCNs cn (\\num => preOrPost ap.isPre (ap.s ! mkGenNum num cn.g) (cn.s ! num)) ; AdjCN ap cn = overwriteCNs cn (\\num => preOrPost ap.isPre (ap.s ! mkGenNum num cn.g) (cn.s ! num)) ;
-- CN -> RS -> CN -- CN -> RS -> CN
-- house that John bought
RelCN cn rs = overwriteCNs cn (\\num => cn.s ! num ++ rs.s ! agrP3 (nounnum2num num) cn.g) ; RelCN cn rs = overwriteCNs cn (\\num => cn.s ! num ++ rs.s ! agrP3 (nounnum2num num) cn.g) ;
-- CN -> Adv -> CN -- CN -> Adv -> CN
-- house on the hill
AdvCN cn adv = overwriteCNs cn (\\num => cn.s ! num ++ adv.s) ; AdvCN cn adv = overwriteCNs cn (\\num => cn.s ! num ++ adv.s) ;
-- CN -> SC -> CN -- CN -> SC -> CN
-- question where she sleeps
SentCN cn sc = overwriteCNs cn (\\num => cn.s ! num ++ sc.s) ; SentCN cn sc = overwriteCNs cn (\\num => cn.s ! num ++ sc.s) ;
-- CN -> NP -> CN -- CN -> NP -> CN
-- Appossition: city Paris
ApposCN cn np = overwriteCNs cn (\\num => cn.s ! num ++ np.s ! NPNom) ; -- known to be overgenerating ApposCN cn np = overwriteCNs cn (\\num => cn.s ! num ++ np.s ! NPNom) ; -- known to be overgenerating
-- CN -> NP -> CN
-- Possessive: house of mine
PossNP cn np = overwriteCNs cn (\\num => cn.s ! num ++ prepNP prep_ta np) ; PossNP cn np = overwriteCNs cn (\\num => cn.s ! num ++ prepNP prep_ta np) ;
-- CN -> NP -> CN
-- Partitive: glass of wine
PartNP cn np = overwriteCNs cn (\\num => cn.s ! num ++ prepNP prep_ta np) ; PartNP cn np = overwriteCNs cn (\\num => cn.s ! num ++ prepNP prep_ta np) ;
-- Det -> NP -> NP -- Det -> NP -> NP
--- LEAKS ? -- three of them, some of the boys
-- CountNP det np = { CountNP det np =
-- s = \\c => det.s ! np.a.g ++ np.s ! c ; let
-- a = agrP3 (numform2num det.n) np.a.g ; dets = case det.n of {
-- isPron = False ; NumX Sg => wiehed ! np.a.g ;
-- isDefn = np.isDefn ; _ => det.s ! np.a.g
-- } ;
oper
prep_ta = lin Prep {
s = table {
Indefinite => "ta'" ;
Definite => makePreFull "tal-" "ta" "t'"
} ;
enclitic : Agr => Str = \\agr => case toVAgr agr of {
AgP1 Sg => "tiegħi" ;
AgP2 Sg => "tiegħek" ;
AgP3Sg Masc => "tiegħu" ;
AgP3Sg Fem => "tagħha" ;
AgP1 Pl => "tagħna" ;
AgP2 Pl => "tagħkom" ;
AgP2Pl => "tagħhom"
} ; } ;
takesDet = True ; in {
joinsVerb = False ; s = \\c => case np.isPron of {
True => dets ++ prep_minn.enclitic ! np.a;
False => dets ++ prep_minn.s ! (bool2definiteness np.isDefn) ++ np.s ! c
} ;
a = agrP3 (numform2num det.n) np.a.g ;
isPron = False ;
isDefn = np.isDefn ;
} ; } ;
oper oper

View File

@@ -348,6 +348,8 @@ resource ResMlt = ParamX ** open Prelude, Predef, Maybe in {
isPresent = False ; isPresent = False ;
} ; } ;
{- Preposition ---------------------------------------------------------- -}
Preposition = { Preposition = {
s : Definiteness => Str ; s : Definiteness => Str ;
enclitic : Agr => Str ; -- when suffixed by pronouns; magħ-ha enclitic : Agr => Str ; -- when suffixed by pronouns; magħ-ha
@@ -355,6 +357,42 @@ resource ResMlt = ParamX ** open Prelude, Predef, Maybe in {
joinsVerb : Bool ; -- True for for_Prep (I.O. suffix) joinsVerb : Bool ; -- True for for_Prep (I.O. suffix)
} ; } ;
prep_ta : Preposition = {
s = table {
Indefinite => "ta'" ;
Definite => makePreFull "tal-" "ta" "t'"
} ;
enclitic : Agr => Str = \\agr => case toVAgr agr of {
AgP1 Sg => "tiegħi" ;
AgP2 Sg => "tiegħek" ;
AgP3Sg Masc => "tiegħu" ;
AgP3Sg Fem => "tagħha" ;
AgP1 Pl => "tagħna" ;
AgP2 Pl => "tagħkom" ;
AgP2Pl => "tagħhom"
} ;
takesDet = True ;
joinsVerb = False ;
} ;
prep_minn : Preposition = {
s = table {
Indefinite => "minn" ;
Definite => makePreFull "mill-" "mi" "m"
} ;
enclitic : Agr => Str = \\agr => case toVAgr agr of {
AgP1 Sg => "minni" ;
AgP2 Sg => "minnek" ;
AgP3Sg Masc => "minnu" ;
AgP3Sg Fem => "minnha" ;
AgP1 Pl => "minna" ;
AgP2 Pl => "minnkom" ;
AgP2Pl => "minnhom"
} ;
takesDet = True ;
joinsVerb = False ;
} ;
{- Pronoun -------------------------------------------------------------- -} {- Pronoun -------------------------------------------------------------- -}
oper oper
@@ -1164,6 +1202,12 @@ resource ResMlt = ParamX ** open Prelude, Predef, Maybe in {
_ => False _ => False
} ; } ;
wiehed : Gender => Str =
table {
Masc => "wieħed" ;
Fem => "waħda"
} ;
artIndef : Str = [] ; --- is this a source of leaks? artIndef : Str = [] ; --- is this a source of leaks?
artDef : Str = artDef : Str =

View File

@@ -33,18 +33,18 @@ concrete StructuralMlt of Structural = CatMlt **
{- Determiner ----------------------------------------------------------- -} {- Determiner ----------------------------------------------------------- -}
all_Predet = ss "kollha" ; all_Predet = ss "kollha" ;
every_Det = mkDeterminer singular "kull" ; --- KULĦADD every_Det = mkDeterminer singular "kull" ;
few_Det = mkDeterminer plural "ftit" ; few_Det = mkDeterminer plural "ftit" ;
many_Det = mkDeterminer plural "ħafna" ; many_Det = mkDeterminer plural "ħafna" ;
most_Predet = ss "il-maġġoranza ta'" ; --- TAL-, TAN- most_Predet = ss "il-maġġoranza ta'" ; --- tal-, tan-
much_Det = mkDeterminer singular "ħafna" ; much_Det = mkDeterminer singular "ħafna" ;
only_Predet = ss "biss" ; only_Predet = ss "biss" ;
someSg_Det = mkDeterminer singular "xi" ; someSg_Det = mkDeterminer singular "xi" ;
somePl_Det = mkDeterminer plural "xi" ; somePl_Det = mkDeterminer plural "xi uħud" ;
not_Predet = ss "mhux" ; not_Predet = ss "mhux" ;
how8many_IDet = { how8many_IDet = {
s = "kemm" ; -- KEMM IL-... s = "kemm" ; -- kemm il-...
n = plural n = plural
} ; } ;
@@ -76,7 +76,7 @@ concrete StructuralMlt of Structural = CatMlt **
"qabli" "qablek" "qablu" "qabilha" "qabilna" "qabilkom" "qabilhom" ; "qabli" "qablek" "qablu" "qabilha" "qabilna" "qabilkom" "qabilhom" ;
behind_Prep = after_Prep ; behind_Prep = after_Prep ;
between_Prep = mkPrep "bejn" ; between_Prep = mkPrep "bejn" ;
by8agent_Prep = mkPrep "minn" "mill-" "mit-" ; by8agent_Prep = prep_minn ; -- mkPrep "minn" "mill-" "mit-" ;
by8means_Prep = mkPrep "bi" "b'" "bil-" "bit-" "bl-" ; by8means_Prep = mkPrep "bi" "b'" "bil-" "bit-" "bl-" ;
during_Prep = mkPrep "waqt" ; during_Prep = mkPrep "waqt" ;
for_Prep = mkPrep "għal" "għall-" "għall-" "għat-" "għall-" for_Prep = mkPrep "għal" "għall-" "għall-" "għat-" "għall-"
@@ -87,7 +87,7 @@ concrete StructuralMlt of Structural = CatMlt **
in_Prep = mkPrep "fi" "f'" "fil-" "fit-" "fl-" ; in_Prep = mkPrep "fi" "f'" "fil-" "fit-" "fl-" ;
on_Prep = mkPrep "fuq" ; on_Prep = mkPrep "fuq" ;
part_Prep = possess_Prep ; part_Prep = possess_Prep ;
possess_Prep = mkPrep "ta'" "t'" "tal-" "tat-" "tal-" ; possess_Prep = prep_ta ; -- mkPrep "ta'" "t'" "tal-" "tat-" "tal-" ;
through_Prep = mkPrep "minn ġo" "minn ġo" "minn ġol-" "minn ġot-" "minn ġol-" through_Prep = mkPrep "minn ġo" "minn ġo" "minn ġol-" "minn ġot-" "minn ġol-"
"minn ġo fija" "minn ġo fik" "minn ġo fih" "minn ġo fiha" "minn ġo fina" "minn ġo fikom" "minn ġo fihom" "minn ġo fija" "minn ġo fik" "minn ġo fih" "minn ġo fiha" "minn ġo fina" "minn ġo fikom" "minn ġo fihom"
False ; False ;
@@ -125,8 +125,8 @@ concrete StructuralMlt of Structural = CatMlt **
here_Adv = mkAdv "hawn" ; here_Adv = mkAdv "hawn" ;
here7to_Adv = mkAdv ["s'hawnhekk"] ; here7to_Adv = mkAdv ["s'hawnhekk"] ;
here7from_Adv = mkAdv ["minn hawnhekk"] ; here7from_Adv = mkAdv ["minn hawnhekk"] ;
less_CAdv = C.mkCAdv "inqas" "minn" ; --- INQAS MILL-IEĦOR less_CAdv = C.mkCAdv "inqas" "minn" ; --- inqas mill-ieħor
more_CAdv = C.mkCAdv "iktar" "minn" ; --- IKTAR MIT-TNEJN more_CAdv = C.mkCAdv "iktar" "minn" ; --- iktar mit-tnejn
quite_Adv = mkAdv "pjuttost" ; quite_Adv = mkAdv "pjuttost" ;
so_AdA = mkAdA "allura" ; so_AdA = mkAdA "allura" ;
somewhere_Adv = mkAdv "x'imkien" ; somewhere_Adv = mkAdv "x'imkien" ;