forked from GitHub/gf-core
Maltese: new reduced verb implementation, using binding for pronominal suffixes
Also include some syntax stuff adapted from Angelo Zammit's dissertation.
These sections in the code are marked with [AZ]
The old verbs implementation can still be found at this point in the GitHub repo:
7b3f4a049d
This commit is contained in:
@@ -1,38 +1,62 @@
|
||||
-- ResMlt.gf: Language-specific parameter types, morphology, VP formation
|
||||
--
|
||||
-- Maltese Resource Grammar Library
|
||||
-- John J. Camilleri, 2012
|
||||
-- John J. Camilleri 2009 -- 2013
|
||||
-- Angelo Zammit 2012
|
||||
-- Licensed under LGPL
|
||||
|
||||
--# -path=.:../abstract:../common:../prelude
|
||||
|
||||
resource ResMlt = ParamX - [Tense] ** open Prelude, Predef in {
|
||||
resource ResMlt = ParamX ** open Prelude, Predef in {
|
||||
|
||||
flags coding=utf8 ;
|
||||
|
||||
{- General -------------------------------------------------------------- -}
|
||||
|
||||
param
|
||||
|
||||
{- General -}
|
||||
|
||||
Gender = Masc | Fem ;
|
||||
Gender = Masc | Fem ;
|
||||
|
||||
GenNum =
|
||||
GSg Gender -- dak, dik
|
||||
| GPl ; -- dawk
|
||||
| GPl -- dawk
|
||||
;
|
||||
|
||||
Agr =
|
||||
oper
|
||||
-- Agreement system corrected based on comments by [AZ]
|
||||
Agr : Type = { g : Gender ; n : Number ; p : Person } ;
|
||||
|
||||
mkAgr : Gender -> Number -> Person -> Agr = \g,n,p -> {g = g ; n = n ; p = p} ;
|
||||
|
||||
toVAgr : Agr -> VAgr = \agr ->
|
||||
case <agr.p,agr.n> of {
|
||||
<P1,num> => AgP1 num;
|
||||
<P2,num> => AgP2 num;
|
||||
<P3,Sg> => AgP3Sg agr.g;
|
||||
<P3,Pl> => AgP3Pl
|
||||
} ;
|
||||
|
||||
toAgr : VAgr -> Agr = \vagr ->
|
||||
case vagr of {
|
||||
AgP1 num => mkAgr Masc num P1 ; --- sorry ladies
|
||||
AgP2 num => mkAgr Masc num P2 ;
|
||||
AgP3Sg gen => mkAgr gen Pl P3 ;
|
||||
AgP3Pl => mkAgr Masc Pl P3
|
||||
} ;
|
||||
|
||||
param
|
||||
-- Agreement for verbs
|
||||
VAgr =
|
||||
AgP1 Number -- jiena, aħna
|
||||
| AgP2 Number -- inti, intom
|
||||
| AgP3Sg Gender -- huwa, hija
|
||||
| AgP3Pl -- huma
|
||||
;
|
||||
;
|
||||
|
||||
NPCase = Nom | Gen ;
|
||||
param
|
||||
NPCase = Nom | CPrep ; -- [AZ]
|
||||
|
||||
Animacy =
|
||||
Animate
|
||||
| Inanimate
|
||||
;
|
||||
-- Animacy = Animate | Inanimate ;
|
||||
|
||||
-- Definiteness =
|
||||
-- Definite -- eg IL-KARTA. In this context same as Determinate
|
||||
@@ -40,7 +64,7 @@ resource ResMlt = ParamX - [Tense] ** open Prelude, Predef in {
|
||||
-- ;
|
||||
|
||||
|
||||
{- Numerals -}
|
||||
{- Numeral -------------------------------------------------------------- -}
|
||||
|
||||
CardOrd = NCard | NOrd ;
|
||||
|
||||
@@ -51,60 +75,107 @@ resource ResMlt = ParamX - [Tense] ** open Prelude, Predef in {
|
||||
| Ten -- 20-99
|
||||
| Hund -- 100..999
|
||||
--| Thou -- 1000+
|
||||
;
|
||||
;
|
||||
|
||||
Num_Number =
|
||||
Num_Sg
|
||||
| Num_Dl
|
||||
| Num_Pl
|
||||
;
|
||||
;
|
||||
|
||||
Num_Case =
|
||||
NumNominative -- TNEJN, ĦAMSA, TNAX, MIJA
|
||||
| NumAdjectival ; -- ŻEWĠ, ĦAMES, TNAX-IL, MITT
|
||||
NumNominative -- TNEJN, ĦAMSA, TNAX, MIJA
|
||||
| NumAdjectival -- ŻEWĠ, ĦAMES, TNAX-IL, MITT
|
||||
;
|
||||
|
||||
|
||||
{- Nouns -}
|
||||
{- Nouns ---------------------------------------------------------------- -}
|
||||
|
||||
oper
|
||||
Noun : Type = {
|
||||
s : Noun_Number => Str ;
|
||||
g : Gender ;
|
||||
-- anim : Animacy ; -- is the noun animate? e.g. TABIB
|
||||
} ;
|
||||
|
||||
ProperNoun : Type = {
|
||||
s : Str ;
|
||||
a : Agr ; -- ignore a.p (always P3)
|
||||
} ;
|
||||
|
||||
NounPhrase : Type = {
|
||||
s : NPCase => Str ;
|
||||
a : Agr ;
|
||||
isPron : Bool ;
|
||||
} ;
|
||||
|
||||
param
|
||||
Noun_Sg_Type =
|
||||
Singulative -- eg ĦUTA
|
||||
| Collective -- eg ĦUT
|
||||
;
|
||||
;
|
||||
Noun_Pl_Type =
|
||||
Determinate -- eg ĦUTIET
|
||||
| Indeterminate -- eg ĦWIET
|
||||
;
|
||||
;
|
||||
Noun_Number =
|
||||
Singular Noun_Sg_Type -- eg ĦUTA / ĦUT
|
||||
| Dual -- eg WIDNEJN
|
||||
| Plural Noun_Pl_Type -- eg ĦUTIET / ĦWIET
|
||||
;
|
||||
;
|
||||
|
||||
NForm =
|
||||
NRegular -- WIĊĊ
|
||||
| NPronSuffix Agr ; -- WIĊĊU
|
||||
{- Pronoun -------------------------------------------------------------- -}
|
||||
|
||||
oper
|
||||
-- [AZ]
|
||||
Pronoun = {
|
||||
s : PronForm => {c1, c2: Str} ;
|
||||
a : Agr ;
|
||||
} ;
|
||||
|
||||
{- Verb -}
|
||||
param
|
||||
PronForm =
|
||||
Personal -- JIENA
|
||||
| Possessive -- TIEGĦI
|
||||
| Suffixed PronCase
|
||||
;
|
||||
|
||||
PronCase =
|
||||
Acc -- Accusative: rajtu
|
||||
| Dat -- Dative: rajtlu
|
||||
| Gen -- Genitive: qalbu
|
||||
;
|
||||
|
||||
{- Verb ----------------------------------------------------------------- -}
|
||||
|
||||
oper
|
||||
Verb : Type = {
|
||||
s : VForm => Str ;
|
||||
i : VerbInfo ;
|
||||
} ;
|
||||
|
||||
VerbInfo : Type = {
|
||||
class : VClass ;
|
||||
form : VDerivedForm ;
|
||||
root : Root ; -- radicals
|
||||
patt : Pattern ; -- vowels extracted from mamma
|
||||
patt2: Pattern ; -- vowel changes; default to patt (experimental)
|
||||
-- in particular, patt2 is used to indicate whether an IE sould be shortened
|
||||
-- to an I or an E (same for entire verb)
|
||||
imp : Str ; -- Imperative Sg. Gives so much information jaħasra!
|
||||
} ;
|
||||
|
||||
param
|
||||
-- Possible verb forms (tense + person)
|
||||
VForm =
|
||||
VPerf Agr -- Perfect tense in all pronoun cases
|
||||
| VImpf Agr -- Imperfect tense in all pronoun cases
|
||||
VPerf VAgr -- Perfect tense in all pronoun cases
|
||||
| VImpf VAgr -- Imperfect tense in all pronoun cases
|
||||
| VImp Number -- Imperative is always P2, Sg & Pl
|
||||
-- | VPresPart GenNum -- Present Particible for Gender/Number
|
||||
-- | VPastPart GenNum -- Past Particible for Gender/Number
|
||||
-- | VVerbalNoun -- Verbal Noun
|
||||
;
|
||||
|
||||
-- Inflection of verbs for pronominal suffixes
|
||||
VSuffixForm =
|
||||
VSuffixNone -- eg FTAĦT
|
||||
| VSuffixDir Agr -- eg FTAĦTU
|
||||
| VSuffixInd Agr -- eg FTAĦTLU
|
||||
| VSuffixDirInd GenNum Agr -- eg FTAĦTHULU. D.O. is necessarily 3rd person.
|
||||
;
|
||||
|
||||
VDerivedForm =
|
||||
FormI
|
||||
| FormII
|
||||
@@ -125,7 +196,7 @@ resource ResMlt = ParamX - [Tense] ** open Prelude, Predef in {
|
||||
| Weak VWeakClass
|
||||
| Quad VQuadClass
|
||||
| Loan
|
||||
-- | Irregular
|
||||
| Irregular
|
||||
;
|
||||
VStrongClass =
|
||||
Regular
|
||||
@@ -142,64 +213,138 @@ resource ResMlt = ParamX - [Tense] ** open Prelude, Predef in {
|
||||
QStrong
|
||||
| QWeak
|
||||
;
|
||||
-- VRomanceEnding =
|
||||
-- _ARE -- kanta
|
||||
-- | _ERE | _IRE -- vinċa, serva --- we don't need this distinction, just always use IRE
|
||||
-- ;
|
||||
-- VQuadClass =
|
||||
-- BiradicalBase
|
||||
-- | RepeatedC3
|
||||
-- | RepeatedC1
|
||||
-- | AdditionalC4
|
||||
-- ;
|
||||
|
||||
|
||||
{- Adjective -}
|
||||
|
||||
AForm =
|
||||
APosit GenNum
|
||||
| ACompar
|
||||
| ASuperl
|
||||
;
|
||||
|
||||
oper
|
||||
|
||||
{- ===== Type declarations ===== -}
|
||||
|
||||
Noun : Type = {
|
||||
s : Noun_Number => NForm => Str ;
|
||||
g : Gender ;
|
||||
-- anim : Animacy ; -- is the noun animate? e.g. TABIB
|
||||
VerbParts : Type = { stem, dir, ind, pol : Str } ;
|
||||
mkVParts = overload {
|
||||
mkVParts : Str -> Str -> VerbParts = \a,d -> {stem=a; dir=[]; ind=[]; pol=d} ;
|
||||
mkVParts : Str -> Str -> Str -> Str -> VerbParts = \a,b,c,d -> {stem=a; dir=b; ind=c; pol=d} ;
|
||||
} ;
|
||||
joinVParts : VerbParts -> Str = \vb -> vb.stem ++ vb.dir ++ vb.ind ++ vb.ind ;
|
||||
|
||||
-- [AZ]
|
||||
VP : Type = {
|
||||
s : VPForm => Anteriority => Polarity => VerbParts ; -- verb
|
||||
s2 : Agr => Str ; -- complement
|
||||
-- a1 : Str ;
|
||||
-- a2 : Str ;
|
||||
} ;
|
||||
|
||||
ProperNoun : Type = {
|
||||
s : Str ;
|
||||
g : Gender ;
|
||||
param
|
||||
-- [AZ]
|
||||
VPForm =
|
||||
VPIndicat Tense VAgr
|
||||
| VPImperat Number
|
||||
;
|
||||
|
||||
oper
|
||||
|
||||
-- [AZ]
|
||||
insertObj : (Agr => Str) -> VP -> VP = \obj,vp -> {
|
||||
s = vp.s ;
|
||||
s2 = obj ;
|
||||
-- a1 = vp.a1 ;
|
||||
-- a2 = vp.a2 ;
|
||||
} ;
|
||||
|
||||
Verb : Type = {
|
||||
s : VForm => VSuffixForm => Polarity => Str ;
|
||||
i : VerbInfo ;
|
||||
copula_kien = {
|
||||
s : (VForm => Str) = table {
|
||||
VPerf (AgP1 Sg) => "kont" ;
|
||||
VPerf (AgP2 Sg) => "kont" ;
|
||||
VPerf (AgP3Sg Masc) => "kien" ;
|
||||
VPerf (AgP3Sg Fem) => "kienet" ;
|
||||
VPerf (AgP1 Pl) => "konna" ;
|
||||
VPerf (AgP2 Pl) => "kontu" ;
|
||||
VPerf (AgP3Pl) => "kienu" ;
|
||||
VImpf (AgP1 Sg) => "nkun" ;
|
||||
VImpf (AgP2 Sg) => "tkun" ;
|
||||
VImpf (AgP3Sg Masc) => "jkun" ;
|
||||
VImpf (AgP3Sg Fem) => "tkun" ;
|
||||
VImpf (AgP1 Pl) => "nkunu" ;
|
||||
VImpf (AgP2 Pl) => "tkunu" ;
|
||||
VImpf (AgP3Pl) => "jkunu" ;
|
||||
VImp (Pl) => "kun" ;
|
||||
VImp (Sg) => "kunu"
|
||||
} ;
|
||||
i : VerbInfo = mkVerbInfo (Irregular) (FormI) (mkRoot "k-w-n") (mkPattern "ie") ;
|
||||
} ;
|
||||
|
||||
VerbInfo : Type = {
|
||||
class : VClass ;
|
||||
form : VDerivedForm ;
|
||||
root : Root ; -- radicals
|
||||
patt : Pattern ; -- vowels extracted from mamma
|
||||
patt2: Pattern ; -- vowel changes; default to patt (experimental)
|
||||
-- in particular, patt2 is used to indicate whether an IE sould be shortened
|
||||
-- to an I or an E (same for entire verb)
|
||||
imp : Str ; -- Imperative Sg. Gives so much information jaħasra!
|
||||
-- Adapted from [AZ]
|
||||
CopulaVP : VP = {
|
||||
s = \\vpf,ant,pol =>
|
||||
case <vpf> of {
|
||||
<VPIndicat Past vagr> => polarise (copula_kien.s ! VPerf vagr) pol ;
|
||||
<VPIndicat Pres vagr> => polarise (copula_kien.s ! VImpf vagr) pol ;
|
||||
<VPImperat num> => polarise (copula_kien.s ! VImp num) pol ;
|
||||
_ => Predef.error "tense not implemented"
|
||||
} ;
|
||||
s2 = \\agr => [] ;
|
||||
} where {
|
||||
polarise : Str -> Polarity -> VerbParts = \s,pol ->
|
||||
mkVParts s (case pol of { Neg => BIND ++ "x" ; _ => [] }) ;
|
||||
} ;
|
||||
|
||||
-- [AZ]
|
||||
predV : Verb -> VP = \verb -> {
|
||||
s = \\vpf,ant,pol =>
|
||||
let
|
||||
ma = "ma" ;
|
||||
mhux = "mhux" ;
|
||||
b1 : Str -> VerbParts = \s -> mkVParts s [] ;
|
||||
b2 : Str -> VerbParts = \s -> mkVParts s (BIND ++ "x") ;
|
||||
in
|
||||
case vpf of {
|
||||
VPIndicat tense vagr =>
|
||||
let
|
||||
kien = joinVParts (CopulaVP.s ! VPIndicat Past vagr ! Simul ! pol) ;
|
||||
in
|
||||
case <tense,ant,pol> of {
|
||||
<Pres,Simul,Pos> => b1 (verb.s ! VImpf vagr) ; -- norqod
|
||||
<Pres,Anter,Pos> => b1 (kien ++ verb.s ! VImpf vagr) ; -- kont norqod
|
||||
<Past,Simul,Pos> => b1 (verb.s ! VPerf vagr) ; -- rqadt
|
||||
<Past,Anter,Pos> => b1 (kien ++ verb.s ! VPerf vagr) ; -- kont rqadt
|
||||
<Fut, Simul,Pos> => b1 ("se" ++ verb.s ! VImpf vagr) ; -- se norqod
|
||||
<Fut, Anter,Pos> => b1 (kien ++ "se" ++ verb.s ! VImpf vagr) ; -- kont se norqod
|
||||
|
||||
<Pres,Simul,Neg> => b2 (ma ++ verb.s ! VImpf vagr) ; -- ma norqodx
|
||||
<Pres,Anter,Neg> => b1 (ma ++ kien ++ verb.s ! VImpf vagr) ; -- ma kontx norqod
|
||||
<Past,Simul,Neg> => b2 (ma ++ verb.s ! VPerf vagr) ; -- ma rqadtx
|
||||
<Past,Anter,Neg> => b1 (ma ++ kien ++ verb.s ! VPerf vagr) ; -- ma kontx rqadt
|
||||
<Fut, Simul,Neg> => b1 (mhux ++ "se" ++ verb.s ! VImpf vagr) ; -- mhux se norqod
|
||||
<Fut, Anter,Neg> => b1 (ma ++ kien ++ "se" ++ verb.s ! VImpf vagr) ; -- ma kontx se norqod
|
||||
|
||||
<Cond,_,Pos> => b1 (kien ++ verb.s ! VImpf vagr) ; -- kont norqod
|
||||
<Cond,_,Neg> => b1 (ma ++ kien ++ verb.s ! VImpf vagr) -- ma kontx norqod
|
||||
} ;
|
||||
VPImperat num => b2 (verb.s ! VImp num) -- torqodx
|
||||
};
|
||||
s2 = \\agr => [] ;
|
||||
-- a1 = [] ;
|
||||
-- n2 = \\_ => [] ;
|
||||
-- a2 = [] ;
|
||||
} ;
|
||||
|
||||
{- Adjective ------------------------------------------------------------ -}
|
||||
|
||||
oper
|
||||
Adjective : Type = {
|
||||
s : AForm => Str ;
|
||||
} ;
|
||||
|
||||
param
|
||||
AForm =
|
||||
APosit GenNum
|
||||
| ACompar
|
||||
| ASuperl
|
||||
;
|
||||
|
||||
{- ===== Some character classes ===== -}
|
||||
{- Other ---------------------------------------------------------------- -}
|
||||
|
||||
oper
|
||||
|
||||
{- ~~~ Some character classes ~~~ -}
|
||||
|
||||
Letter : pattern Str = #( "a" | "b" | "ċ" | "d" | "e" | "f" | "ġ" | "g" | "għ" | "h" | "ħ" | "i" | "ie" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "ż" | "z" );
|
||||
Consonant : pattern Str = #( "b" | "ċ" | "d" | "f" | "ġ" | "g" | "għ" | "h" | "ħ" | "j" | "k" | "l" | "m" | "n" | "p" | "q" | "r" | "s" | "t" | "v" | "w" | "x" | "ż" | "z" );
|
||||
CoronalCons : pattern Str = #( "ċ" | "d" | "n" | "r" | "s" | "t" | "x" | "ż" | "z" ); -- "konsonanti xemxin"
|
||||
@@ -207,40 +352,38 @@ resource ResMlt = ParamX - [Tense] ** open Prelude, Predef in {
|
||||
SonorantCons : pattern Str = #( "l" | "m" | "n" | "r" ); -- See {SA pg13}. Currently unused, but see DoublingConsN below
|
||||
DoublingConsT : pattern Str = #( "ċ" | "d" | "ġ" | "s" | "x" | "ż" | "z" ); -- require doubling when prefixed with 't', eg DDUM, ĠĠORR, SSIB, TTIR, ŻŻID {GM pg68,2b} {OM pg90}
|
||||
DoublingConsN : pattern Str = #( "l" | "m" | "r" ); -- require doubling when prefixed with 'n', eg LLAĦĦAQ, MMUR, RRID {OM pg90}
|
||||
StrongCons : pattern Str = #( "b" | "ċ" | "d" | "f" | "ġ" | "g" | "għ" | "h" | "ħ" | "k" | "l" | "m" | "n" | "p" | "q" | "r" | "s" | "t" | "v" | "x" | "ż" | "z" );
|
||||
WeakCons : pattern Str = #( "j" | "w" );
|
||||
Vowel : pattern Str = #( "a" | "e" | "i" | "o" | "u" );
|
||||
VowelIE : pattern Str = #( "a" | "e" | "i" | "ie" | "o" | "u" );
|
||||
Digraph : pattern Str = #( "ie" );
|
||||
SemiVowel : pattern Str = #( "għ" | "j" );
|
||||
|
||||
V = Vowel ;
|
||||
C = Consonant ;
|
||||
LC = LiquidCons ;
|
||||
Vwl = Vowel ;
|
||||
Cns = Consonant ;
|
||||
LCns = LiquidCons ;
|
||||
|
||||
EorI : Str = "e" | "i" ;
|
||||
IorE : Str = "i" | "e" ;
|
||||
|
||||
{- ===== Roots & Patterns ===== -}
|
||||
{- ~~~ Roots & Patterns ~~~ -}
|
||||
|
||||
Pattern : Type = {V1, V2 : Str} ;
|
||||
Root : Type = {C1, C2, C3, C4 : Str} ;
|
||||
|
||||
-- Make a root object. Accepts following overloads:
|
||||
-- mkRoot
|
||||
-- mkRoot "k-t-b"
|
||||
-- mkRoot "k-t-b-l"
|
||||
-- mkoot (empty root)
|
||||
-- mkRoot "k-t-b" / mkRoot "k-t-b-l"
|
||||
-- mkRoot "k" "t" "b"
|
||||
-- mkRoot "k" "t" "b" "l"
|
||||
mkRoot : Root = overload {
|
||||
mkRoot : Root =
|
||||
{ C1=[] ; C2=[] ; C3=[] ; C4=[] } ;
|
||||
mkRoot : Str -> Root = \root ->
|
||||
case toLower root of {
|
||||
c1@#Consonant + "-" + c2@#Consonant + "-" + c3@#Consonant =>
|
||||
{ C1=c1 ; C2=c2 ; C3=c3 ; C4=[] } ; -- "k-t-b"
|
||||
c1@#Consonant + "-" + c2@#Consonant + "-" + c3@#Consonant + "-" + c4@#Consonant =>
|
||||
{ C1=c1 ; C2=c2 ; C3=c3 ; C4=c4 } ; -- "k-t-b-l"
|
||||
_ => { C1=(charAt 0 root) ; C2=(charAt 1 root) ; C3=(charAt 2 root) ; C4=(charAt 3 root) } -- "ktb" (not recommended)
|
||||
mkRoot : Str -> Root = \s ->
|
||||
case toLower s of {
|
||||
c1 + "-" + c2 + "-" + c3 + "-" + c4 => { C1=c1 ; C2=c2 ; C3=c3 ; C4=c4 } ; -- "k-t-b-l"
|
||||
c1 + "-" + c2 + "-" + c3 => { C1=c1 ; C2=c2 ; C3=c3 ; C4=[] } ; -- "k-t-b"
|
||||
_ => Predef.error("Cannot make root from:"++s)
|
||||
} ;
|
||||
mkRoot : Str -> Str -> Str -> Root = \c1,c2,c3 ->
|
||||
{ C1=toLower c1 ; C2=toLower c2 ; C3=toLower c3 ; C4=[] } ;
|
||||
@@ -302,7 +445,7 @@ resource ResMlt = ParamX - [Tense] ** open Prelude, Predef in {
|
||||
} ;
|
||||
|
||||
|
||||
{- ===== Conversions ===== -}
|
||||
{- ~~~ Conversions ~~~ -}
|
||||
|
||||
numnum2nounnum : Num_Number -> Noun_Number = \n ->
|
||||
case n of {
|
||||
@@ -311,13 +454,22 @@ resource ResMlt = ParamX - [Tense] ** open Prelude, Predef in {
|
||||
} ;
|
||||
|
||||
|
||||
{- ===== Useful helper functions ===== -}
|
||||
{- ~~~ Useful helper functions ~~~ -}
|
||||
|
||||
-- Non-existant form
|
||||
--- If changed, also see: MorphoMlt.verbPolarityTable
|
||||
noexist : Str = "NOEXIST" ;
|
||||
|
||||
-- New names for the drop/take operations
|
||||
takePfx = Predef.take ;
|
||||
dropPfx = Predef.drop ;
|
||||
takeSfx = Predef.dp ;
|
||||
dropSfx = Predef.tk ;
|
||||
--- dependent on defn of ResMlt.noexist
|
||||
takePfx : Int -> Str -> Str = \n,s -> case s of { "NOEXIST" => noexist ; _ => Predef.take n s } ;
|
||||
dropPfx : Int -> Str -> Str = \n,s -> case s of { "NOEXIST" => noexist ; _ => Predef.drop n s } ;
|
||||
takeSfx : Int -> Str -> Str = \n,s -> case s of { "NOEXIST" => noexist ; _ => Predef.dp n s } ;
|
||||
dropSfx : Int -> Str -> Str = \n,s -> case s of { "NOEXIST" => noexist ; _ => Predef.tk n s } ;
|
||||
-- takePfx = Predef.take ;
|
||||
-- dropPfx = Predef.drop ;
|
||||
-- takeSfx = Predef.dp ;
|
||||
-- dropSfx = Predef.tk ;
|
||||
|
||||
-- Get the character at the specific index (0-based).
|
||||
-- Negative indices behave as 0 (first character). Out of range indexes return the empty string.
|
||||
@@ -338,27 +490,26 @@ resource ResMlt = ParamX - [Tense] ** open Prelude, Predef in {
|
||||
-- } ;
|
||||
|
||||
-- Prefix with a 'n'/'t' or double initial consonant, as necessary. See {OM pg 90}
|
||||
pfx_N : Str -> Str = \s -> case takePfx 1 s of {
|
||||
pfx_N : Str -> Str = \s -> case s of {
|
||||
"" => [] ;
|
||||
m@#DoublingConsN => m + s ;
|
||||
"NOEXIST" => noexist ; --- dependent on defn of ResMlt.noexist
|
||||
m@#DoublingConsN + _ => m + s ;
|
||||
_ => "n" + s
|
||||
} ;
|
||||
pfx_T : Str -> Str = \s -> case takePfx 1 s of {
|
||||
pfx_T : Str -> Str = \s -> case s of {
|
||||
"" => [] ;
|
||||
d@#DoublingConsT => d + s ;
|
||||
"NOEXIST" => noexist ; --- dependent on defn of ResMlt.noexist
|
||||
d@#DoublingConsT + _ => d + s ;
|
||||
_ => "t" + s
|
||||
} ;
|
||||
-- This is just here to standardise
|
||||
-- pfx_J : Str -> Str = \s -> case takePfx 1 s of {
|
||||
-- "" => [] ;
|
||||
-- _ => "j" + s
|
||||
-- } ;
|
||||
pfx_J : Str -> Str = \s -> pfx "j" s ;
|
||||
|
||||
-- Generically prefix a string (avoiding empty strings)
|
||||
pfx : Str -> Str -> Str = \p,s -> case <p,s> of {
|
||||
<_, ""> => [] ;
|
||||
<"", str> => str ;
|
||||
<_, "NOEXIST"> => noexist ; --- dependent on defn of ResMlt.noexist
|
||||
<"NOEXIST", str> => str ; --- dependent on defn of ResMlt.noexist
|
||||
<px, str> => px + str
|
||||
} ;
|
||||
|
||||
@@ -368,6 +519,7 @@ resource ResMlt = ParamX - [Tense] ** open Prelude, Predef in {
|
||||
sfx : Str -> Str -> Str = \a,b ->
|
||||
case <a,takePfx 1 b> of {
|
||||
<"",_> => [] ;
|
||||
<"NOEXIST",_> => noexist ; --- dependent on defn of ResMlt.noexist
|
||||
<ke+"nn","n"> => ke+"n"+b ;
|
||||
<ha+"kk","k"> => ha+"k"+b ;
|
||||
<ho+"ll","l"> => ho+"l"+b ;
|
||||
@@ -436,114 +588,59 @@ resource ResMlt = ParamX - [Tense] ** open Prelude, Predef in {
|
||||
_ => [] -- ?
|
||||
} ;
|
||||
|
||||
artIndef = [] ;
|
||||
artIndef : Str =
|
||||
pre {
|
||||
"lill-" ;
|
||||
"lil" / strs { "a" ; "e" ; "i" ; "o" ; "u" ; "h" ; "għ" } ;
|
||||
"liċ-" ++ BIND / strs { "ċ" } ;
|
||||
"lid-" ++ BIND / strs { "d" } ;
|
||||
"lin-" ++ BIND / strs { "n" } ;
|
||||
"lir-" ++ BIND / strs { "r" } ;
|
||||
"lis-" ++ BIND / strs { "s" } ;
|
||||
"lit-" ++ BIND / strs { "t" } ;
|
||||
"lix-" ++ BIND / strs { "x" } ;
|
||||
"liż-" ++ BIND / strs { "ż" } ;
|
||||
"liz-" ++ BIND / strs { "z" }
|
||||
} ;
|
||||
|
||||
artDef : Str =
|
||||
pre {
|
||||
"il-" ;
|
||||
"l-" / strs { "a" ; "e" ; "i" ; "o" ; "u" ; "h" ; "għ" } ;
|
||||
"iċ-" / strs { "ċ" } ;
|
||||
"id-" / strs { "d" } ;
|
||||
"in-" / strs { "n" } ;
|
||||
"ir-" / strs { "r" } ;
|
||||
"is-" / strs { "s" } ;
|
||||
"it-" / strs { "t" } ;
|
||||
"ix-" / strs { "x" } ;
|
||||
"iż-" / strs { "ż" } ;
|
||||
"iz-" / strs { "z" }
|
||||
"l-" ++ BIND / strs { "a" ; "e" ; "i" ; "o" ; "u" ; "h" ; "għ" } ;
|
||||
"iċ-" ++ BIND / strs { "ċ" } ;
|
||||
"id-" ++ BIND / strs { "d" } ;
|
||||
"in-" ++ BIND / strs { "n" } ;
|
||||
"ir-" ++ BIND / strs { "r" } ;
|
||||
"is-" ++ BIND / strs { "s" } ;
|
||||
"it-" ++ BIND / strs { "t" } ;
|
||||
"ix-" ++ BIND / strs { "x" } ;
|
||||
"iż-" ++ BIND / strs { "ż" } ;
|
||||
"iz-" ++ BIND / strs { "z" }
|
||||
} ;
|
||||
|
||||
{- ===== Worst-case functions ===== -}
|
||||
{- ~~~ Worst-case functions ~~~ -}
|
||||
|
||||
-- Noun: Takes all forms and a gender
|
||||
-- Params:
|
||||
-- Singulative, eg KOXXA
|
||||
-- Collective, eg KOXXOX
|
||||
-- Double, eg KOXXTEJN
|
||||
-- Determinate Plural, eg KOXXIET
|
||||
-- Indeterminate Plural
|
||||
-- Gender
|
||||
-- mkNoun : (_,_,_,_,_ : NForm => Str) -> Gender -> Noun = \sing,coll,dual,det,ind,gen -> {
|
||||
-- s = table {
|
||||
-- Singular Singulative => sing ;
|
||||
-- Singular Collective => coll ;
|
||||
-- Dual => dual ;
|
||||
-- Plural Determinate => det ;
|
||||
-- Plural Indeterminate => ind
|
||||
-- } ;
|
||||
-- g = gen ;
|
||||
-- -- anim = Inanimate ;
|
||||
-- } ;
|
||||
|
||||
-- Make a noun animate
|
||||
animateNoun : Noun -> Noun ;
|
||||
animateNoun = \n -> n ** {anim = Animate} ;
|
||||
|
||||
-- Build an empty pronominal suffix table
|
||||
nullSuffixTable : Str -> (NForm => Str) ;
|
||||
nullSuffixTable = \s -> table {
|
||||
NRegular => s ;
|
||||
NPronSuffix _ => []
|
||||
-- Singulative, eg KOXXA
|
||||
-- Collective, eg KOXXOX
|
||||
-- Double, eg KOXXTEJN
|
||||
-- Determinate Plural, eg KOXXIET
|
||||
-- Indeterminate Plural
|
||||
-- Gender
|
||||
mkNoun : (_,_,_,_,_ : Str) -> Gender -> Noun = \sing,coll,dual,det,ind,gen -> {
|
||||
s = table {
|
||||
Singular Singulative => sing ;
|
||||
Singular Collective => coll ;
|
||||
Dual => dual ;
|
||||
Plural Determinate => det ;
|
||||
Plural Indeterminate => ind
|
||||
} ;
|
||||
g = gen ;
|
||||
-- anim = Inanimate ;
|
||||
} ;
|
||||
|
||||
-- Build a noun's pronominal suffix table
|
||||
mkSuffixTable : (NForm => Str) = overload {
|
||||
|
||||
mkSuffixTable : (_ : Str) -> (NForm => Str) = \wicc ->
|
||||
table {
|
||||
NRegular => wicc ;
|
||||
NPronSuffix (AgP1 Sg) => wicc + "i" ;
|
||||
NPronSuffix (AgP2 Sg) => wicc + "ek" ;
|
||||
NPronSuffix (AgP3Sg Masc) => wicc + "u" ;
|
||||
NPronSuffix (AgP3Sg Fem) => wicc + "ha" ;
|
||||
NPronSuffix (AgP1 Pl) => wicc + "na" ;
|
||||
NPronSuffix (AgP2 Pl) => wicc + "kom" ;
|
||||
NPronSuffix (AgP3Pl) => wicc + "hom"
|
||||
} ;
|
||||
|
||||
mkSuffixTable : (_,_,_,_,_,_,_,_ : Str) -> (NForm => Str) = \isem,ismi,ismek,ismu,isimha,isimna,isimkom,isimhom ->
|
||||
table {
|
||||
NRegular => isem ;
|
||||
NPronSuffix (AgP1 Sg) => ismi ;
|
||||
NPronSuffix (AgP2 Sg) => ismek ;
|
||||
NPronSuffix (AgP3Sg Masc) => ismu ;
|
||||
NPronSuffix (AgP3Sg Fem) => isimha ;
|
||||
NPronSuffix (AgP1 Pl) => isimna ;
|
||||
NPronSuffix (AgP2 Pl) => isimkom ;
|
||||
NPronSuffix (AgP3Pl) => isimhom
|
||||
} ;
|
||||
|
||||
} ;
|
||||
|
||||
-- mkNoun = overload {
|
||||
|
||||
-- mkNoun : (_,_,_,_,_ : Str) -> Gender -> Noun = \sing,coll,dual,det,ind,gen -> {
|
||||
-- s = table {
|
||||
-- Singular Singulative => (nullSuffixTable sing) ;
|
||||
-- Singular Collective => (nullSuffixTable coll) ;
|
||||
-- Dual => (nullSuffixTable dual) ;
|
||||
-- Plural Determinate => (nullSuffixTable det) ;
|
||||
-- Plural Indeterminate => (nullSuffixTable ind)
|
||||
-- } ;
|
||||
-- g = gen ;
|
||||
-- -- anim = Inanimate ;
|
||||
-- } ;
|
||||
|
||||
mkNoun : (_,_,_,_,_ : NForm => Str) -> Gender -> Noun = \sing,coll,dual,det,ind,gen -> {
|
||||
s = table {
|
||||
Singular Singulative => sing ;
|
||||
Singular Collective => coll ;
|
||||
Dual => dual ;
|
||||
Plural Determinate => det ;
|
||||
Plural Indeterminate => ind
|
||||
} ;
|
||||
g = gen ;
|
||||
-- anim = Inanimate ;
|
||||
} ;
|
||||
|
||||
-- } ;
|
||||
|
||||
-- Adjective: Takes all forms (except superlative)
|
||||
-- adjective: Takes all forms (except superlative)
|
||||
-- Params:
|
||||
-- Masculine, eg SABIĦ
|
||||
-- Feminine, eg SABIĦA
|
||||
|
||||
Reference in New Issue
Block a user