From 9fa07fb22dcfc258e615519e5e864c7fc96e6b00 Mon Sep 17 00:00:00 2001 From: Meowyam Date: Mon, 21 Mar 2022 17:28:45 +0800 Subject: [PATCH] working tests for verbal affixes and tenses, add kepada (to a person), initial groundwork for animacy, numerals --- src/malay/AdjectiveMay.gf | 2 ++ src/malay/AdverbMay.gf | 2 ++ src/malay/CatMay.gf | 6 ++++ src/malay/LexiconMay.gf | 6 ++-- src/malay/NounMay.gf | 35 ++++++++++++++++-------- src/malay/NumeralMay.gf | 1 + src/malay/ParadigmsMay.gf | 1 + src/malay/ParamMay.gf | 6 ++++ src/malay/ResMay.gf | 3 ++ src/malay/StructuralMay.gf | 13 ++++++++- src/malay/unittest/numerals.gftest | 28 +++++++++++++++++++ src/malay/unittest/tenses.gftest | 3 ++ src/malay/unittest/verbal_affixes.gftest | 11 ++++---- 13 files changed, 96 insertions(+), 21 deletions(-) diff --git a/src/malay/AdjectiveMay.gf b/src/malay/AdjectiveMay.gf index af6b454c4..2df3e73a0 100644 --- a/src/malay/AdjectiveMay.gf +++ b/src/malay/AdjectiveMay.gf @@ -39,6 +39,8 @@ concrete AdjectiveMay of Adjective = CatMay ** open ResMay, Prelude in { -- AdjOrd ord = ord ** { -- compar = [] -- } ; + -- AdjOrd : Ord -> AP = + AdjOrd ord = ord ; -- Sentence and question complements defined for all adjectival -- phrases, although the semantics is only clear for some adjectives. diff --git a/src/malay/AdverbMay.gf b/src/malay/AdverbMay.gf index 36458f821..d7b65fd70 100644 --- a/src/malay/AdverbMay.gf +++ b/src/malay/AdverbMay.gf @@ -13,6 +13,8 @@ lin -- : Prep -> NP -> Adv ; PrepNP prep np = {s = applyPrep prep np} ; + -- PrepNP to_Prep (UsePron youSg_Pron) + -- Adverbs can be modified by 'adadjectives', just like adjectives. --AdAdv : AdA -> Adv -> Adv ; -- very quickly diff --git a/src/malay/CatMay.gf b/src/malay/CatMay.gf index 04dead49a..61ca8867a 100644 --- a/src/malay/CatMay.gf +++ b/src/malay/CatMay.gf @@ -126,4 +126,10 @@ concrete CatMay of Cat = CommonX - [IAdv] ** open ResMay, Prelude in { ClSlash = \cl -> cl.subj ++ cl.pred ! Root ! Pos ++ cl.c2.s; RCl = \cl -> cl.subj ++ cl.pred ! P1 ! Pos; Cl = \cl -> cl.subj ++ cl.pred ! Active ! Pos; + Det = linDet ; } + +-- Determiner : Type = Quant ** { +-- pr : Str ; -- prefix for numbers +-- n : NumType ; -- number as in 5 (noun in singular), Sg or Pl +-- } ; \ No newline at end of file diff --git a/src/malay/LexiconMay.gf b/src/malay/LexiconMay.gf index f01645b7b..76552b4ea 100644 --- a/src/malay/LexiconMay.gf +++ b/src/malay/LexiconMay.gf @@ -19,7 +19,7 @@ lin ask_V2Q = mkV2 "tanya" ; ---- -- B -lin baby_N = mkN "bayi" ; +lin baby_N = mkN "bayi" Animate ; lin back_N = mkN "belakang" ; -- lin bad_A = mkA "" ; lin bank_N = mkN "bank" ; @@ -29,7 +29,7 @@ lin beautiful_A = mkA "cantik" ; lin beer_N = mkN "bir" ; -- lin beg_V2V = mkV2 "" ; -- lin belly_N = mkN "" ; --- lin big_A = mkA "" ; +lin big_A = mkA "besar" ; -- lin bike_N = mkN "" ; -- lin bird_N = mkN "" ; -- lin bite_V2 = mkV2 "" ; @@ -208,7 +208,7 @@ lin king_N = mkN "raja" ; -- lin language_N = mkN "" ; -- lin laugh_V = mkV "" ; -- lin leaf_N = mkN "" ; --- lin learn_V2 = mkV2 (prefixV (mkV "ajar" Ber)) emptyPrep ; +lin learn_V2 = mkV2 (prefixV (mkV "ajar" Ber)) emptyPrep ; -- lin leather_N = mkN "" ; -- lin leave_V2 = mkV2 "" ; -- lin leg_N = mkN "" ; diff --git a/src/malay/NounMay.gf b/src/malay/NounMay.gf index 2bfed1f77..3f3b4966a 100644 --- a/src/malay/NounMay.gf +++ b/src/malay/NounMay.gf @@ -51,7 +51,7 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in { -- : Det -> NP ; DetNP det = emptyNP ** { - s = \\_ => det.s ; + s = \\_ => linDet det ; } ; -- MassNP : CN -> NP ; @@ -71,10 +71,12 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in { n = num.n } ; - -- : Quant -> Num -> Ord -> Det ; -- these five best - -- DetQuantOrd quant num ord = - -- let theseFive = DetQuant quant num in theseFive ** { - -- } ; + -- : Quant -> Num -> Ord -> Det ; + DetQuantOrd quant num ord = quant ** { + pr = num.s ; + n = num.n ; + s = ord.s ++ quant.s ; + } ; -- Whether the resulting determiner is singular or plural depends on the -- cardinal. @@ -107,18 +109,21 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in { OrdDigits digs = digs ** { s = digs.s ! NOrd } ; -} -- : Numeral -> Ord ; - -- OrdNumeral num = num ** { - -- s = \\_ => num.ord - -- } ; + OrdNumeral num = { + s = num.ord + } ; -- : A -> Ord ; - -- OrdSuperl a = { - -- } ; + OrdSuperl a = { + s = "ter" ++ BIND ++ a.s + } ; -- One can combine a numeral and a superlative. -- : Numeral -> A -> Ord ; -- third largest - -- OrdNumeralSuperl num a = num ** { } ; + OrdNumeralSuperl num a = { + s = num.ord ++ "ter" ++ BIND ++ a.s + } ; -- : Quant DefArt = mkQuant [] ; @@ -199,6 +204,14 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in { } } ; + + -- : Det -> NP -> NP ; + CountNP det np = np ** + { + s = \\pos => "ke" ++ BIND ++ linDet det ++ BIND ++ "-" ++ BIND ++ linDet det ++ np.s ! pos; + } ; -- Nonsense for DefArt or IndefArt + + -- : CN -> NP -> CN ; -- glass of wine / two kilos of red apples -- PartNP cn np = cn ** { -- } ; diff --git a/src/malay/NumeralMay.gf b/src/malay/NumeralMay.gf index 1367a5ede..a0d391937 100644 --- a/src/malay/NumeralMay.gf +++ b/src/malay/NumeralMay.gf @@ -96,6 +96,7 @@ oper } ; -- To make Sub* funs directly from a string. + -- ordnumeral from here mkNum : Str -> LinNumber = \s -> { n = Pl ; s = \\_ => s ; -- Indep vs. Attrib only matters for number 1 diff --git a/src/malay/ParadigmsMay.gf b/src/malay/ParadigmsMay.gf index 2df74b94a..5a1732e1f 100644 --- a/src/malay/ParadigmsMay.gf +++ b/src/malay/ParadigmsMay.gf @@ -93,6 +93,7 @@ oper mkN = overload { mkN : Str -> N = \s -> lin N (mkNoun s) ; + mkN : Str -> Animacy -> N = \s,a -> lin N (mkNoun s) ; } ; diff --git a/src/malay/ParamMay.gf b/src/malay/ParamMay.gf index abe7164df..95212a54c 100644 --- a/src/malay/ParamMay.gf +++ b/src/malay/ParamMay.gf @@ -85,6 +85,8 @@ param NPAgr = NotPron | IsPron Person ; + Animacy = Animate | Inanimate ; + oper poss2str : Possession -> Str = \p -> case p of { Bare => [] ; @@ -130,6 +132,10 @@ param param PrepType = DirObj | EmptyPrep | OtherPrep ; + +-------------------------------------------------------------------------------- +-- Adverbs + -------------------------------------------------------------------------------- -- Verbs param diff --git a/src/malay/ResMay.gf b/src/malay/ResMay.gf index b3b26586a..66e9da433 100644 --- a/src/malay/ResMay.gf +++ b/src/malay/ResMay.gf @@ -81,6 +81,9 @@ oper isPre : Bool ; } ; + linDet : Determiner -> Str = \det -> det.pr ++ det.s ; + +-- add field in determiner for kedua-dua numbers Determiner : Type = Quant ** { pr : Str ; -- prefix for numbers n : NumType ; -- number as in 5 (noun in singular), Sg or Pl diff --git a/src/malay/StructuralMay.gf b/src/malay/StructuralMay.gf index 670ce8896..ff737ef32 100644 --- a/src/malay/StructuralMay.gf +++ b/src/malay/StructuralMay.gf @@ -110,7 +110,18 @@ lin in_Prep = mkPrep "di" ; -- lin part_Prep = mkPrep ; lin possess_Prep = mkPrep [] ; -- TODO check Mintz p. 39-40, 2.2.1.2 -- lin through_Prep = mkPrep ; -lin to_Prep = mkPrep "ke" ; +-- lin to_Prep = mkPrep "ke" ; +lin to_Prep = + let ke : Preposition = mkPrep "ke"; + kepada : Preposition = mkPrep "kepada" ; + in ke ** { + obj = kepada.obj + } ; + +-- lin have_V2 = let have' : V2 = mkV2 "ada" in have' ** { +-- s = \\_ => "ada" ; +-- passive = "diadakan" ; +-- } ; -- lin under_Prep = mkPrep "" ; lin with_Prep = mkPrep "dengan" ; -- lin without_Prep = mkPrep "" ; diff --git a/src/malay/unittest/numerals.gftest b/src/malay/unittest/numerals.gftest index cf6aa05b5..974728290 100644 --- a/src/malay/unittest/numerals.gftest +++ b/src/malay/unittest/numerals.gftest @@ -9,3 +9,31 @@ LangMay: lima kucing ini Lang: DetCN (DetQuant (PossPron i_Pron) (NumCard (NumNumeral (num (pot2as3 (pot2 (pot0 n7))))))) (UseN cat_N) LangEng: my seven hundred cats LangMay: tujuh ratus kucing aku + +Lang: AdjCN (AdjOrd (OrdNumeral (num (pot2as3 (pot1as2 (pot0as1 (pot0 n2))))))) (UseN cat_N) +LangEng: second cat +LangMay: kucing kedua + +Lang: DetQuantOrd IndefArt NumPl (OrdNumeral (num (pot2as3 (pot1as2 (pot0as1 (pot0 n2)))))) +LangEng: second +LangMay: kedua + +Lang: UttNP (DetCN (DetQuantOrd (PossPron i_Pron) NumSg (OrdNumeral (num (pot2as3 (pot1as2 (pot0as1 (pot0 n2))))))) (UseN cat_N)) +LangEng: my second cat +LangMay: kucing kedua aku + +Lang: UttNP (DetCN (DetQuantOrd (PossPron i_Pron) (NumCard (NumNumeral (num (pot2as3 (pot1as2 (pot0as1 (pot0 n2))))))) (OrdNumeral (num (pot2as3 (pot1as2 (pot0as1 (pot0 n2))))))) (UseN cat_N)) +LangEng: my two second cats +LangMay: dua kucing kedua aku + +Lang: CountNP (DetQuant IndefArt (NumCard (NumNumeral (num (pot2as3 (pot1as2 (pot0as1 (pot0 n2)))))))) (DetCN (DetQuant (PossPron i_Pron) NumPl) (UseN cat_N)) +LangEng: two of my cats +LangMay: kedua-dua kucing aku + +Lang: MassNP (AdjCN (AdjOrd (OrdNumeralSuperl (num (pot2as3 (pot1as2 (pot0as1 (pot0 n3))))) big_A)) (UseN cat_N)) +LangEng: third biggest cat +LangMay: kucing ketiga terbesar + +Lang: MassNP (AdjCN (AdjOrd (OrdSuperl big_A)) (UseN cat_N)) +LangEng: biggest cat +LangMay: kucing terbesar \ No newline at end of file diff --git a/src/malay/unittest/tenses.gftest b/src/malay/unittest/tenses.gftest index df49f4e6f..51ef0bf69 100644 --- a/src/malay/unittest/tenses.gftest +++ b/src/malay/unittest/tenses.gftest @@ -23,3 +23,6 @@ LangMay: sekiranya aku berjalan , kucing akan berjalan Lang: ExtAdvS (SubjS when_Subj (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseV walk_V)))) (UseCl (TTAnt TFut ASimul) PPos (PredVP (DetCN (DetQuant DefArt NumSg) (UseN cat_N)) (UseV walk_V))) LangEng: when I walk , the cat will walk LangMay: kalau aku berjalan , kucing akan berjalan + +--- + diff --git a/src/malay/unittest/verbal_affixes.gftest b/src/malay/unittest/verbal_affixes.gftest index 7875f2c92..7fecec8d3 100644 --- a/src/malay/unittest/verbal_affixes.gftest +++ b/src/malay/unittest/verbal_affixes.gftest @@ -14,7 +14,7 @@ LangMay: kucing aku berjalan -- As a verbal complement Lang: UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant (PossPron i_Pron) NumSg) (UseN cat_N)) (ComplVV want_VV (UseV walk_V)))) LangEng: my cat wants to walk -LangMay: kucing aku mahu jalan +LangMay: kucing aku mahu berjalan -- Transitive verbs @@ -25,7 +25,7 @@ LangMay: aku membaca buku ini -- As a verbal complement Lang: UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplVV want_VV (ComplSlash (SlashV2a read_V2) (DetCN (DetQuant this_Quant NumSg) (UseN book_N)))))) LangEng: I want to read this book -LangMay: aku mahu baca buku ini +LangMay: aku mahu membaca buku ini -- How about words like mengajar and belajar? Is the prefix more important here? @@ -37,10 +37,9 @@ Lang: UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (AdvVP (Com LangEng: I teach science in the school LangMay: aku mengajar sains di sekolah --- The way the grammar is currently defined, we'd get the same output for both "I want to learn/study science". Is this correct, or should one or both of the verbs keep the ber/meng prefix in this context? Lang: UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (AdvVP (ComplVV want_VV (ComplSlash (SlashV2a teach_V2) (MassNP (UseN science_N)))) (PrepNP in_Prep (DetCN (DetQuant DefArt NumSg) (UseN school_N)))))) LangEng: I want to teach science in the school -LangMay: aku mahu ajar sains di sekolah +LangMay: aku mahu mengajar sains di sekolah Lang: UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (AdvVP (ComplVV want_VV (ComplSlash (SlashV2a learn_V2) (MassNP (UseN science_N)))) (PrepNP in_Prep (DetCN (DetQuant DefArt NumSg) (UseN school_N)))))) LangEng: I want to learn science in the school @@ -62,12 +61,12 @@ LangMay: buku ini diajar di sekolah Lang: DetCN (DetQuant IndefArt NumSg) (RelCN (UseN cat_N) (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (UseV walk_V)))) LangEng: a cat that walks -LangMay: kucing yang jalan +LangMay: kucing yang berjalan -- In a context Lang: UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a buy_V2) (DetCN (DetQuant IndefArt NumSg) (RelCN (UseN cat_N) (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (UseV walk_V)))))))) LangEng: I buy a cat that walks -LangMay: aku membeli kucing yang jalan +LangMay: aku membeli kucing yang berjalan -- Transitive verbs