1
0
forked from GitHub/gf-core

added swahili (fragments) by Wanjiku Ng'ang'a and Juliet Mutahi

This commit is contained in:
aarne
2011-01-12 08:06:19 +00:00
parent ea0f0102c0
commit 5661ecde18
31 changed files with 1090 additions and 4 deletions

View File

@@ -7,7 +7,7 @@
<P ALIGN="center"><CENTER><H1>The Status of the GF Resource Grammar Library</H1> <P ALIGN="center"><CENTER><H1>The Status of the GF Resource Grammar Library</H1>
<FONT SIZE="4"> <FONT SIZE="4">
<I>Aarne Ranta</I><BR> <I>Aarne Ranta</I><BR>
20101222 20110112
</FONT></CENTER> </FONT></CENTER>
<P> <P>
@@ -346,6 +346,19 @@ are marked in the table
<TD>*AR,IA,TS</TD> <TD>*AR,IA,TS</TD>
</TR> </TR>
<TR> <TR>
<TD>Swa</TD>
<TD>+</TD>
<TD>-</TD>
<TD>-</TD>
<TD>-</TD>
<TD>-</TD>
<TD>-</TD>
<TD>-</TD>
<TD>-</TD>
<TD>-</TD>
<TD>*WN, JM</TD>
</TR>
<TR>
<TD>Swe</TD> <TD>Swe</TD>
<TD>+</TD> <TD>+</TD>
<TD>+</TD> <TD>+</TD>
@@ -463,6 +476,7 @@ JK Janna Khegai,
JS Jordi Saludes, JS Jordi Saludes,
KA Krasimir Angelov, KA Krasimir Angelov,
KP Kuchi Prasad, KP Kuchi Prasad,
JM Juliet Mutahi,
LPj Laurette Pretorius Jr, LPj Laurette Pretorius Jr,
LPs Laurette Pretorius Sr, LPs Laurette Pretorius Sr,
MF Markus Forsberg, MF Markus Forsberg,
@@ -474,7 +488,8 @@ RE Ramona Enache,
SC Server Cimen, SC Server Cimen,
SM Sofy Moradi, SM Sofy Moradi,
SV Shafqat Virk, SV Shafqat Virk,
TH Therese Söderberg TH Therese Söderberg,
WN Wanjiku Ng'ang'a
</P> </P>
<H2>Rules</H2> <H2>Rules</H2>
<P> <P>

View File

@@ -38,6 +38,7 @@ are marked in the table
| Ron | + | + | ++ | + | + | + | + | - | - | *RE | Ron | + | + | ++ | + | + | + | + | - | - | *RE
| Rus | + | + | ++ | + | + | + | - | - | - | JK | Rus | + | + | ++ | + | + | + | - | - | - | JK
| Spa | + | + | ++ | + | + | + | + | + | - | *AR,IA,TS | Spa | + | + | ++ | + | + | + | + | + | - | *AR,IA,TS
| Swa | + | - | - | - | - | - | - | - | - | *WN, JM
| Swe | + | + | ++ | + | + | + | + | + | + | *AR,MF | Swe | + | + | ++ | + | + | + | + | + | + | *AR,MF
| Tha | + | - | - | - | - | - | - | - | - | *AR | Tha | + | - | - | - | - | - | - | - | - | *AR
| Tsn | - | - | - | - | - | - | - | - | - | *LPs,AB | Tsn | - | - | - | - | - | - | - | - | - | *LPs,AB
@@ -85,6 +86,7 @@ JK Janna Khegai,
JS Jordi Saludes, JS Jordi Saludes,
KA Krasimir Angelov, KA Krasimir Angelov,
KP Kuchi Prasad, KP Kuchi Prasad,
JM Juliet Mutahi,
LPj Laurette Pretorius Jr, LPj Laurette Pretorius Jr,
LPs Laurette Pretorius Sr, LPs Laurette Pretorius Sr,
MF Markus Forsberg, MF Markus Forsberg,
@@ -96,8 +98,8 @@ RE Ramona Enache,
SC Server Cimen, SC Server Cimen,
SM Sofy Moradi, SM Sofy Moradi,
SV Shafqat Virk, SV Shafqat Virk,
TH Therese Söderberg TH Therese Söderberg,
WN Wanjiku Ng'ang'a

View File

@@ -0,0 +1,11 @@
concrete AdjectiveSwa of Adjective = CatSwa ** open ResSwa, Prelude , ParamX in {
lin
PositA a = {
s = a.s ! Posit ;
} ;
-- PositA a = a;
}

View File

@@ -0,0 +1,12 @@
concrete AdverbSwa of Adverb = CatSwa ** open ResSwa, Prelude in {
lin
-- PositAdvAdj : A -> Adv ; -- vizuri
PositAdvAdj a = {
s = a.s ! Posit ! AA
} ;
}

View File

@@ -0,0 +1,4 @@
concrete BackwardSwa of Backward = CatSwa ** open ResSwa in {
}

45
lib/src/swahili/CatSwa.gf Normal file
View File

@@ -0,0 +1,45 @@
--# -path=.:../abstract:../../prelude:../common
concrete CatSwa of Cat = CommonX ** open ResSwa, Prelude in {
flags optimize=all_subs ;
lincat
CN = {s,s1,s2 : Number => Str; g : Gender ; anim : Animacy ; hasAdj : Bool } ;
N = {s : Number => Str; g : Gender ; anim : Animacy } ;
N2 = {s : Number => Str; g : Gender ; anim : Animacy } ** {c2 : Str} ;
N3 = {s : Number => Str; g : Gender ; anim : Animacy } ** {c2,c3 : Str} ;
Pron = {s :Number => Str ; p : Person};
V,VA = Verb ; -- = {s : VForm => Str} ;
V2 = Verb ** {c2 : Str} ;
NP = {s : Case => Str ; a : Agr} ;
A = {s : Degree => AForm => Str} ;
AP = {s : AForm => Str} ;
Det = {s : Gender => Case => Animacy => Str ; n : Number } ;
Quant = {s : Number => Gender => Animacy => Case => Str} ;
Predet,Ord = {s : Str} ;
-- Open lexical classes, e.g. Lexicon
-- Verb
VP = ResSwa.VP ;
-- Numeral
Num = {s : Gender => Str ; n : Number} ;
{--
Num = {s : Gender => Animacy => Str ; n : Number} ;
Card = {s : Gender => Animacy => Str ; n : Number} ;
Digits = {s : Str ; n : Number} ;
--}
--Prepositions
Prep = {s : Str} ;
-- Sentence
Cl = Clause ;
}

View File

@@ -0,0 +1,7 @@
--# -path=.:../abstract:../common
concrete CompatibilitySwa of Compatibility = CatSwa ** open Prelude, ResSwa in {
}

View File

@@ -0,0 +1,6 @@
concrete ConjunctionSwa of Conjunction =
CatSwa ** open ResSwa, Coordination, Prelude in {
}

View File

@@ -0,0 +1,6 @@
concrete ExtraSwa of ExtraSwaAbs = CatSwa **
open ResSwa, Coordination, Prelude, MorphoSwa in {
lin that1_Quant = {s = \\n,nc,g => mkQuant SpHr n nc g P3} ;
}

View File

@@ -0,0 +1,4 @@
abstract ExtraSwaAbs = Extra ** {
}

View File

@@ -0,0 +1,9 @@
--# -path=.:../abstract:../common:prelude
concrete GrammarSwa of Grammar =NounSwa , AdjectiveSwa , StructuralSwa ,VerbSwa , SentenceSwa , AdverbSwa
** {
flags startcat = Phr ; unlexer = text ; lexer = text ;
} ;

View File

@@ -0,0 +1,7 @@
concrete IdiomSwa of Idiom = CatSwa ** open Prelude, ResSwa in {
flags optimize=all_subs ;
}

View File

@@ -0,0 +1,8 @@
--# -path=.:prelude:../abstract:../common
concrete IrregSwa of IrregSwaAbs = CatSwa ** open ParadigmsSwa in {
flags optimize=values ;
}

View File

@@ -0,0 +1,3 @@
abstract IrregSwaAbs = Cat ** {
}

View File

@@ -0,0 +1,10 @@
--# -path=.:../abstract:../common:../prelude
concrete LangSwa of Lang =
GrammarSwa,
LexiconSwa
** {
flags startcat = Phr ; unlexer = text ; lexer = text ;
} ;

View File

@@ -0,0 +1,99 @@
--# -path=.:../abstract:../../prelude:../common
concrete LexiconSwa of Lexicon = CatSwa **
open ParadigmsSwa, Prelude in {
flags
optimize=values ;
lin
bird_N = regN "ndege" e_e animate;
country_N = regN "nchi" e_e inanimate ;
cousin_N = regN "binamu" e_ma animate;
cow_N = regN "ngombe" e_e animate;
doctor_N = regN "daktari" e_ma animate ;
dog_N = regN "mbwa" e_e animate ;
door_N = regN "mlango" m_mi inanimate;
enemy_N = regN "adui" e_ma animate;
father_N = regN "baba" e_e animate;
fish_N = regN "samaki" e_e animate;
friend_N = regN "rafiki" e_ma animate;
garden_N = regN "shamba" e_ma inanimate;
girl_N = regN "msichana" m_wa animate ;
lamp_N = regN "taa" e_e inanimate ;
man_N = regN "mwanaume" m_wa animate ;
tree_N = regN "mti" m_mi inanimate ;
water_N = regN "maji" ma_ma inanimate ;
woman_N = regN "mwanamke" m_wa animate ;
ear_N = regN "sikio" e_ma inanimate ;
eye_N = mkN "jicho" "macho" ji_ma inanimate ;
fingernail_N = regN "ukucha" u_e inanimate ;
nose_N = regN "pua" e_ma inanimate;
person_N = regN "mtu" m_wa animate ;
road_N = regN "barabara" e_e inanimate;
tooth_N = regN "jino" ji_ma inanimate ;
wife_N = regN "bibi" e_ma animate ;
river_N = regN "mto" m_mi inanimate ;
come_V = regV "kuja";
walk_V = regV "tembea";
sleep_V = regV "lala";
smell_V = regV "nuka";
stand_V = regV "simama";
stop_V = regV "simama";
swell_V = regV "fura";
swim_V = regV "ogelea";
think_V = regV "waza";
travel_V = regV "safiri";
big_A = regA "kubwa";
beautiful_A = regA "rembo" ;
black_A = regA "eusi";
blue_A = regA "buluu" ;
broad_A = regA "pana" ;
brown_A = regA "hudhurungi" ;
clean_A = regA "safi" ;
clever_A = regA "hodari" ;
cold_A = regA "baridi";
correct_A = regA "sahihi" ;
dirty_A = regA "chafu" ;
dry_A = regA "kavu" ;
dull_A = regA "liofifia" ;
full_A = regA "tele" ;
good_A = regA "zuri" ;
green_A = regA "kijani";
heavy_A = regA "zito" ;
hot_A = regA "moto" ;
important_A = regA "muhimu" ;
long_A = regA "refu" ;
narrow_A = regA "embamba" ;
near_A = regA "karibu" ;
new_A = regA "pya" ;
old_A = regA "zee" ;
ready_A = regA "tayari" ;
red_A = regA "ekundu" ;
rotten_A = regA "oza" ;
round_A = regA "viringo" ;
sharp_A = regA "kali" ;
short_A = regA "fupi" ;
small_A = regA "dogo" ;
smooth_A = regA "laini" ;
straight_A = regA "nyofu" ;
stupid_A = regA "jinga" ;
thick_A = regA "nene" ;
thin_A = regA "embamba" ;
ugly_A = regA "baya";
certain_A = regA "hakika" ;
warm_A = regA "fufutende" ;
wet_A = regA "nyevu" ;
white_A = regA "eupe" ;
wide_A = regA "pana" ;
yellow_A = regA "njano" ;
young_A = regA "bichi" ;
father_N2 = mkN2 (regN "baba" e_e animate) (mkPrep "ya") ;
mother_N2 = mkN2 (regN "mama" e_e animate) (mkPrep "ya");
brother_N2 = mkN2 (regN "ndugu" e_e animate) (mkPrep "ya") ;
} ;

View File

@@ -0,0 +1,6 @@
--# -path=.:../common:../abstract
resource MakeStructuralSwa = open CatSwa, ParadigmsSwa, ResSwa, MorphoSwa, Prelude in {
}

View File

@@ -0,0 +1,229 @@
--# -path=.:../abstract:../../prelude:../common
--1 A Simple Swahili Resource Morphology
--
-- This resource morphology contains definitions needed in the resource
-- syntax. To build a lexicon, it is better to use $ParadigmsSwa$, which
-- gives a higher-level access to this module.
resource MorphoSwa = open Prelude, (Predef=Predef), ResSwa in {
flags optimize=all ;
--$Nouns--
oper
CommonNoun : Type = {s : Number => Str; g : Gender ; anim : Animacy } ;
numForms : Str -> Str -> Number => Str = \bon,bons ->
table {Sg => bon ; Pl => bons} ;
mkNoun : (Number => Str) -> Gender -> Animacy -> CommonNoun = \mecmecs,gen,anim ->
{s = mecmecs ; g = gen ; anim = anim} ;
mkNounIrreg : Str -> Str -> Gender -> Animacy -> CommonNoun = \mec,mecs,gen,anim ->
mkNoun (numForms mec mecs) gen anim ;
mkNomReg : Str -> Gender -> Animacy -> CommonNoun = \mtu,gen,anim ->
let watu = case gen of {
g1_2 => case Predef.take 3 mtu of {
"mwa" => Predef.drop 1 mtu ;
"mwi" => "wa"+ Predef.drop 2 mtu ;
_ => "wa" + Predef.drop 1 mtu
}; -- mtu/watu
g3_4 => "mi" + Predef.drop 1 mtu ; -- mti/miti
g5_6 => "me" + Predef.drop 2 mtu ; -- jicho/macho
g5a_6 => "ma" + mtu ; -- somo/masomo
g7_8 => "vi" + Predef.drop 2 mtu ; -- kitabu/vitabu
g11_6 => "ma" + Predef.drop 1 mtu ; -- ugonjwa/magonjwa
g11_10 => Predef.drop 1 mtu ; -- ukuta/kuta
_ => mtu -- ma_ma (maji/maji); e_e (taa/taa); u_u (uhuru/uhuru)
};
in mkNounIrreg mtu watu gen anim ;
mkNn : Str -> Str -> Gender -> Animacy -> CommonNoun = \mec,mecs,gen,anim ->
mkNoun (numForms mec mecs) gen anim ;
--Autonomous Personal Pronoun
mkPronoun :Number -> Person-> Str= \n,p ->
case <n,p> of {
<Sg,P1> => "mimi" ;
<Sg,P2> => "wewe" ;
<Sg,P3> => "yeye" ;
<Pl,P1> => "sisi" ;
<Pl,P2> => "nyinyi" ;
<Pl,P3> => "wao"
};
--$Verbs
{--
VerbprefixR : Agr -> Str = \a -> Verbprefix a.n a.g a.anim a.p ;
Verbprefix : Number -> Gender -> Animacy -> Person -> Str = \n,g,anim,p ->
case <anim,n,g,p> of {
<_,Sg,_,P1> => "ni" ;
<_,Sg,_,P2> => "u" ;
<_,Pl,_,P1> => "tu" ;
<_,Pl,_,P2> => "m" ;
<AN,Sg,_,_> => "a" ;
<AN,Pl,_,_> => "wa" ;
<_,Sg,g1_2,_> => "a" ;
<_,Pl,g1_2,_> => "wa" ;
<_,Sg,g3_4,_> => "u" ;
<_,Pl,g3_4,_> => "i" ;
<_,Sg,g5_6,_> => "li" ;
<_,Pl,g5_6,_> => "ya" ;
<_,Sg,g5a_6,_> => "li" ;
<_,Pl,g5a_6,_> => "ya" ;
<AN,Sg,g6,_> => "a" ;
<AN,Pl,g6,_> => "wa" ;
<_,Sg,g6,_> => "ya" ;
<_,Pl,g6,_> => "ya" ;
<_,Sg,g7_8,_> => "ki" ;
<_,Pl,g7_8,_> => "vi" ;
<_,Sg,g9_10,_> => "i" ;
<_,Pl,g9_10,_> => "zi" ;
<_,_,g11,_> => "u" ;
<_,Sg,g11_6,_> => "u" ;
<_,Pl,g11_6,_> => "ya" ;
<_,Sg,g11_10,_> => "u" ;
<_,Pl,g11_10,_> => "zi"
} ;
Verbprefix : Number -> Gender -> Animacy -> Person -> Str = \n,g,anim,p ->
case <anim,n,g,p> of {
<AN,Sg,_,P1> => "ni" ;
<AN,Pl,_,P1> => "tu" ;
<_,_,_,_> => ""
} ;
mkV : Str -> {s : VForm => Str} =
\cheza -> {
s = table {
--VInf => "ku"+cheza ;
VInf => case Predef.take 2 cheza of {
"ku" => cheza;
_ => "ku"+cheza
};
VImper n p => case <n,p> of {<Sg,P2> => init cheza + "eni";<_,_> => cheza};
VPres n g anim p => Verbprefix n g anim p ++ "na" ++ cheza;
VPast n g anim p => Verbprefix n g anim p ++ "li" ++ cheza ;
VFut n g anim p => Verbprefix n g anim p ++ "ta" ++ cheza
}
} ;
--}
--2 Adjectives
-- To form the adjectival and the adverbial forms, two strings are needed
-- in the worst case. (First without degrees.)
Adj = {s : AForm => Str} ;
VowelAdjprefix : Number -> Gender -> Animacy -> Str = \n,g,anim ->
case <anim,n,g> of {
<AN,Sg,_> => "mw" ;
<AN,Pl,_> => "w" ;
<_,Sg,g1_2> => "mw" ;
<_,Pl,g1_2> => "w" ;
<_,Sg,g3_4> => "mw" ;
<_,Pl,g3_4> => "m" ;
<_,Sg,g5_6> => "nj" ;
<_,Pl,g5_6> => "m" ;
<_,Sg,g5a_6> => "mw" ;
<_,Pl,g5a_6> => "ny" ;
<_,Sg,g6> => "m" ;
<_,Pl,g6> => "m" ;
<_,Sg,g7_8> => "ki" ;
<_,Pl,g7_8> => "vi" ;
<_,Sg,g9_10> => "ny" ;
<_,Pl,g9_10> => "" ;
<_,_,g11> => "m" ;
<_,Sg,g11_6> => "m" ;
<_,Pl,g11_6> => "ma" ;
<_,Sg,g11_10> => "ny" ;
<_,Pl,g11_10> => "m"
} ;
ConsonantAdjprefix : Number -> Gender -> Animacy -> Str = \n,g,anim ->
case <anim,n,g> of {
<AN,Sg,_> => "m" ;
<AN,Pl,_> => "wa" ;
<_,Sg,g1_2> => "m" ;
<_,Pl,g1_2> => "wa" ;
<_,Sg,g3_4> => "" ;
<_,Pl,g3_4> => "" ;
<_,Sg,g5_6> => "" ;
<_,Pl,g5_6> => "ma" ;
<_,Sg,g5a_6> => "" ;
<_,Pl,g5a_6> => "ma" ;
<_,Sg,g6> => "ma" ;
<_,Pl,g6> => "ma" ;
<_,Sg,g7_8> => "ki" ;
<_,Pl,g7_8> => "vi" ;
<_,Sg,g9_10> => "i" ;
<_,Pl,g9_10> => "" ;
<_,_,g11> => "m" ;
<_,Sg,g11_6> => "m" ;
<_,Pl,g11_6> => "ma" ;
<_,Sg,g11_10> => "m" ;
<_,Pl,g11_10> => "n"
} ;
mkAdjective : Str -> Adj = \zuri ->
{
s = table {
AF n g anim => case Predef.take 1 zuri of {
"a"|"e"|"i"|"o"|"u" => VowelAdjprefix n g anim + zuri;
_ => ConsonantAdjprefix n g anim +zuri
};
AA => zuri
}
} ;
mkDeterminer : Number -> Str -> {s : Str ; n : Number} = \n,s ->
{s = s ; n = n} ;
mkQuant : Spatial -> Number -> Gender -> Animacy -> Case -> Person -> Str = \sp,n,g,anim,c,p ->
let
pfx = "foo" ; ---- Verbprefix n g anim p ;
in
case <anim,n,c> of {
<AN,Sg,Nom> => case <sp> of {
<SpHrObj> => "huyu" ;
<HrObj> => "huyo" ;
<_> => "yule" } ;
<_,_,_> => case <sp> of {
<SpHrObj> => "h" + Predef.dp 1 (Verbprefix n g anim p) + Verbprefix n g anim p ; --sphrobj ;
-- <HrObj> => mkQuantEnd (Predef.tk 1 sphrobj) ;
<HrObj> => mkQuantEnd (Predef.tk 1 ("h" + Predef.dp 1 (Verbprefix n g anim p) + Verbprefix n g anim p)) ;
<_> => Verbprefix n g anim p + "le" }
} ;
mkQuantEnd : Str -> Str = \stem ->
let
suffix = Predef.dp 1 stem ;
front = Predef.tk 1 stem
in
case <suffix> of {
<"i"> => stem + "yo" ;
<"k"> => front + "cho" ;
<"v"> => front + "vyo" ;
<"w"> => front + "o" ;
<_> => stem + "o"
} ;
} ;

View File

@@ -0,0 +1,83 @@
concrete NounSwa of Noun = CatSwa ** open MorphoSwa, ResSwa, Prelude in {
flags optimize=all_subs ;
lin
UseN noun = {
s = noun.s ;
s1 = noun.s ;
s2 = noun.s ;
g = noun.g ;
anim = noun.anim ;
hasAdj = False
} ;
UseN2 noun = {
s = noun.s ;
s1 = noun.s ;
s2 = noun.s ;
g = noun.g ;
anim = noun.anim ;
hasAdj = False
} ;
-- Num
NumSg = {s = \\_ => [] ; n = Sg} ;
NumPl = {s = \\_ => [] ; n = Pl} ;
DetQuant quant num = {
s = \\g,c,anim => quant.s ! num.n ! g ! anim ! c ++ num.s ! g;
n = num.n
};
AdjCN ap cn =
let
anim = cn.anim ;
g = cn.g;
mod = cn.hasAdj
in{
s = \\n => cn.s ! n ++ ap.s ! (AF n g anim) ;
s1 = \\n => cn.s1 ! n;
s2=case <mod> of {
<False> => \\n => ap.s ! (AF n g anim);
<True> => \\n => cn.s2 ! n ++ ap.s ! (AF n g anim)
};
g = g ;
anim = anim ;
hasAdj=True
} ;
--DetCN : Det -> CN -> NP ; -- mtu huyo
DetCN det cn =
let
anim = cn.anim ;
g = cn.g ;
n = det.n ;
mod = cn.hasAdj
in case <mod> of {
<False> => {
s = \\c => cn.s ! n ++ det.s ! g ! c ! anim ;
a = agr n g anim P3
} ;
<True> => {
s = \\c => cn.s1 ! n ++ det.s ! g ! c ! anim ++ cn.s2 ! n ;
a = agr n g anim P3
}
};
}

View File

@@ -0,0 +1,4 @@
concrete NumeralSwa of Numeral = CatSwa ** open ResSwa in {
}

View File

@@ -0,0 +1 @@
resource OverloadSwa = Overload with (Grammar = GrammarSwa) ;

View File

@@ -0,0 +1,171 @@
--# -path=.:../abstract:../../prelude:../common
--1 Swahili Lexical Paradigms
resource ParadigmsSwa = open(Predef=Predef), Prelude, MorphoSwa,ResSwa,CatSwa in {
flags optimize=all ;
--2 Parameters
--
-- To abstract over gender names, we define the following identifiers.
oper
Animacy : Type ;
animate : Animacy ;
inanimate : Animacy ;
-- To abstract over number names, we define the following.
Number : Type ;
singular : Number ;
plural : Number ;
-- To abstract over case names, we define the following.
Case : Type ;
nominative : Case ;
locative : Case ;
-- To abstract over nounclass names, we define the following.
Gender : Type ;
m_wa :Gender ;
m_mi : Gender ;
ji_ma : Gender ;
e_ma : Gender ;
ma_ma : Gender ;
ki_vi : Gender ;
e_e : Gender ;
u_u : Gender ;
u_ma : Gender ;
u_e : Gender ;
--2 Nouns
-- Worst case: give all four forms and the semantic gender.
mkN : (mtu,watu : Str) -> Gender -> Animacy -> N ;
-- The regular function captures the variants for nouns depending on Gender and Number
regN : Str -> Gender -> Animacy -> N ;
-- In practice the worst case is just: give singular and plural nominative.
mk2N : (mtu , watu : Str) -> Gender -> Animacy -> N ;
mk2N x y g anim = mkNounIrreg x y g anim ** {lock_N = <>};
mkN2 : N -> Prep -> N2 ;
mkN2 : N -> Prep -> N2 = \n,p -> n ** {c2 = p.s ; lock_N2 = <>} ;
mkPrep : Str -> Prep ;
-- mkPrep p = {s = p ; c = CPrep PNul ; isDir = False ; lock_Prep = <>} ;
mkPrep p = {s = p ; lock_Prep = <>} ;
--3 Relational nouns
--
-- Relational nouns ("fille de x") need a case and a preposition.
-- All nouns created by the previous functions are marked as
-- $nonhuman$. If you want a $human$ noun, wrap it with the following
-- function:
-- genderN : Gender -> N -> N ;
-- For regular adjectives, the adverbial form is derived. This holds
-- even for cases with the variation "happy - happily".
regA : Str -> A ;
-- If comparison is formed by "kuliko", as usual in Swahili,
-- the following pattern is used:
compADeg : A -> A ;
--2 Definitions of paradigms
--
-- The definitions should not bother the user of the API. So they are
-- hidden from the document.
--.
Animacy = ResSwa.Animacy ;
Number = ResSwa.Number ;
Case = ResSwa.Case ;
Gender = ResSwa.Gender ;
animate = AN ;
inanimate = IN ;
singular = Sg ;
plural = Pl ;
nominative = Nom ;
locative = Loc ;
m_wa = g1_2 ;
m_mi = g3_4 ;
ji_ma = g5_6 ;
e_ma = g5a_6 ;
ma_ma = g6 ;
ki_vi = g7_8 ;
e_e = g9_10 ;
u_u = g11 ;
u_ma = g11_6 ;
u_e = g11_10 ;
VForm = ResSwa.VForm ;
-- regN x g anim = mkNomReg x g anim ** {lock_N = <>} ;
regN = \x,g,anim ->
mkNomReg x g anim ** {lock_N = <>} ;
-- mkN x y g anim = mkNounIrreg x y g anim ** {lock_N = <>} ;
mkN = \x,y,g,anim ->
mkNounIrreg x y g anim ** {lock_N = <>} ;
-- Adjectives
regA a = compADeg {
s = \\_ => (mkAdjective a).s ;
lock_A = <>} ;
compADeg a =
{
s = table {
Posit => a.s ! Posit ;
_ => \\f => a.s ! Posit ! f ++ "kuliko"
} ;
lock_A = <>} ;
-- Verbs
regV : Str -> V ;
regV = \enda -> mkV enda ** {s1 = [] ; lock_V = <>} ;
{--
mkV2 = overload {
mkV2 : Str -> V2 = \s -> dirV2 (regV s) ;
mkV2 : V -> V2 = dirV2 ;
mkV2 : V -> Prep -> V2 = mmkV2
} ;
mmkV2 : V -> Prep -> V2 ;
mmkV2 v p = v ** {c2 = p ; lock_V2 = <>} ;
dirV2 : V -> V2 = \v -> mmkV2 v "na" ;
--}
--2 Adverbs
-- Adverbs are not inflected. Most lexical ones have position
-- after the verb.
mkAdv : Str -> Adv ;
mkAdv x = ss x ** {lock_Adv = <>} ;
} ;

View File

@@ -0,0 +1,5 @@
concrete PhraseSwa of Phrase = CatSwa ** open Prelude, ResSwa in {
}

View File

@@ -0,0 +1,3 @@
concrete QuestionSwa of Question = CatSwa ** open ResSwa, Prelude in {
}

View File

@@ -0,0 +1,4 @@
concrete RelativeSwa of Relative = CatSwa ** open ResSwa in {
}

171
lib/src/swahili/ResSwa.gf Normal file
View File

@@ -0,0 +1,171 @@
--# -path=.:../abstract:../common:../../prelude
--1 Swahili auxiliary operations.
-- This module contains operations that are needed to make the
-- resource syntax work. To define everything that is needed to
-- implement $Test$, it moreover contains regular lexical
-- patterns needed for $Lex$.
resource ResSwa = ParamX ** open Prelude in {
flags optimize=all ;
--For $Noun$
-- This is the worst-case $Case$ needed for pronouns.
param Case = Nom | Loc ;
param Animacy = AN | IN ;
param Gender = g1_2 | g3_4 | g5_6 | g5a_6 | g6 | g7_8 | g9_10 | g11 | g11_6 | g11_10 ;
--2 For $Adjective$
AForm = AF Number Gender Animacy
| AA ;
-- The order of sentence is needed already in $VP$.
Order = ODir | OQuest ;
--2 For $Verb$
-- Verbs will take one of the five forms
param
VForm = VInf
| VImper Number Person
| VPres Number Gender Animacy Person
| VPast Number Gender Animacy Person
| VFut Number Gender Animacy Person;
oper
Verb : Type = {s : VForm => Str} ;
VerbForms : Type = Tense => Anteriority => Polarity => Agr => Str ;
VP : Type = {
s : VerbForms ;
s2 : Agr => Str
} ;
mkV : Str -> {s : VForm => Str} =
\cheza -> {
s = table {
VInf => case Predef.take 2 cheza of {
"ku" => cheza;
_ => "ku"+cheza
};
VImper n p => case <n,p> of{
<Sg,P2> => init cheza + "eni";
<_,_> => cheza};
VPres n g anim p => Verbprefix n g anim p + "na" + cheza;
VPast n g anim p => Verbprefix n g anim p + "li" + cheza ;
VFut n g anim p => Verbprefix n g anim p + "ta" + cheza
}
} ;
predV : Verb -> VP = \verb -> {
s = \\t,ant,b,agr =>
let
inf = verb.s ! VInf ;
imper = verb.s ! VImper agr.n agr.p;
pres = verb.s ! VPres agr.n agr.g agr.anim agr.p ;
past = verb.s ! VPast agr.n agr.g agr.anim agr.p ;
fut = verb.s ! VFut agr.n agr.g agr.anim agr.p ;
in
case <t,ant,b> of {
<_,Anter,Pos> => imper;
<Pres,Simul,Pos> => pres ;
<Past,Anter,Pos> => past ;
<Fut, Anter,Pos> => fut ;
<_,_,_> => inf
} ;
s2 = \\_ => []
} ;
Verbprefix : Number -> Gender -> Animacy -> Person -> Str = \n,g,anim,p ->
case <anim,n,g,p> of {
<AN,Sg,_,P1> => "ni" ;
<AN,Sg,_,P2> => "u" ;
<AN,Pl,_,P1> => "tu" ;
<AN,Pl,_,P2> => "m" ;
<AN,Sg,_,_> => "a" ;
<AN,Pl,_,_> => "wa" ;
<_,Sg,g1_2,_> => "a" ;
<_,Pl,g1_2,_> => "wa" ;
<_,Sg,g3_4,_> => "u" ;
<_,Pl,g3_4,_> => "i" ;
<_,Sg,g5_6,_> => "li" ;
<_,Pl,g5_6,_> => "ya" ;
<_,Sg,g5a_6,_> => "li" ;
<_,Pl,g5a_6,_> => "ya" ;
<IN,_,g6,_> => "ya" ;
<IN,Sg,g7_8,_> => "ki" ;
<IN,Pl,g7_8,_> => "vi" ;
<IN,Sg,g9_10,_> => "i" ;
<IN,Pl,g9_10,_> => "zi" ;
<IN,_,g11,_> => "u" ;
<IN,Sg,g11_6,_> => "u" ;
<IN,Pl,g11_6,_> => "ya" ;
<IN,Sg,g11_10,_> => "u" ;
<IN,Pl,g11_10,_> => "zi"
} ;
-- Auxiliary verbs have special negative forms.
param
VVForm =
VVF VForm
| VVPresNeg
| VVPastNeg --# notpresent
;
--Adjectives
oper Adj = {s : AForm => Str} ;
--2 For $Quantifiers$
-- A 3-dimensional system of quantifiers (demonstrative pronouns) based on position of object, hearer + speaker
-- need to find linguistic term to express this
param Spatial = SpHrObj | SpHr | HrObj ; --w.r.t object
-- Agreement of adjectives, verb phrases, and relative pronouns.
oper
AGR = {n : Number ; g : Gender ; anim : Animacy ; p : Person} ;
Agr : Type = {n : Number ; g : Gender ; anim : Animacy ; p : Person} ;
agr : Number -> Gender -> Animacy -> Person -> Agr = \n,g,anim,p -> {n = n ; g = g ; anim = anim ; p = p} ;
-- For $Sentence$.
Clause : Type = {
s : Tense => Anteriority => Polarity => Str
} ;
mkClause : Str -> Agr -> VP -> Clause =
\subj,agr,vp -> {
s = \\t,a,b =>
let
verb = vp.s ! t ! a ! b ! agr
in
subj ++ verb
} ;
}

View File

@@ -0,0 +1,9 @@
concrete SentenceSwa of Sentence = CatSwa ** open Prelude, ResSwa in {
flags optimize=all_subs ;
lin
PredVP np vp = mkClause (np.s ! Nom) np.a vp ;
}

View File

@@ -0,0 +1,15 @@
concrete StructuralSwa of Structural = CatSwa **
open MorphoSwa, ResSwa, ParadigmsSwa,
(C = ConstructX), Prelude in {
flags optimize=all ;
lin
this_Quant = {s = \\n,g,anim,c => mkQuant SpHrObj n g anim Nom P3} ;
this_Quant1 = {s = \\n,g,anim,c => mkQuant HrObj n g anim Nom P3} ;
that_Quant = {s = \\n,g,anim,c => mkQuant SpHr n g anim Nom P3} ;
}

View File

@@ -0,0 +1,7 @@
--# -path=.:../abstract:../common
concrete SymbolSwa of Symbol = CatSwa ** open Prelude, ResSwa in {
}

View File

@@ -0,0 +1,8 @@
concrete VerbSwa of Verb = CatSwa ** open ResSwa in {
flags optimize=all_subs ;
lin
UseV = predV ;
}

122
lib/src/swahili/noun0.gf Normal file
View File

@@ -0,0 +1,122 @@
concrete NounSwa of Noun = CatSwa ** open MorphoSwa, ResSwa, Prelude in {
flags optimize=all_subs ;
lin
UseN noun = {
s = noun.s ;
s1 = noun.s ;
s2 = noun.s ;
g = noun.g ;
anim = noun.anim ;
hasAdj = False
} ;
UseN2 noun = {
s = noun.s ;
s1 = noun.s ;
s2 = noun.s ;
g = noun.g ;
anim = noun.anim ;
hasAdj = False
} ;
{-- Use2N3 noun = {
s = noun.s ;
s1 = noun.s ;
s2 = noun.s ;
g = noun.g ;
anim = noun.anim ;
hasAdj = False;
c2 = noun.c2
} ;
--}
{--
AdjCN ap cn =
let
anim = cn.anim ;
g = cn.g
in {
s = \\n => cn.s ! n ++ ap.s ! (AF n g anim) ;
s1 = \\n => cn.s ! n ;
s2 = \\n => ap.s ! (AF n g anim) ;
g = g ;
anim = anim ;
hasAdj = True
} ;
AdjCN ap cn =
let
anim = cn.anim ;
g = cn.g;
mod = cn.hasAdj
in{
s = \\n => cn.s ! n ++ ap.s ! (AF n g anim) ;
s1 = \\n => cn.s1 ! n;
--s2 = \\n => cn.s2 ++ ap.s ! (AF n g anim) ;
s2=case <mod> of {
<False> => \\n => ap.s ! (AF n g anim);
<True> => \\n => cn.s2 ! n ++ ap.s ! (AF n g anim)
};
g = g ;
anim = anim ;
hasAdj=True
} ;
--}
-- Num
NumSg = {s = \\_ => [] ; n = Sg} ;
NumPl = {s = \\_ => [] ; n = Pl} ;
-- DetQuant : Quant -> Num -> Det ; -- these five
-- Det = {s : Gender => Animacy => Case => Str ; n : Number} ;
-- Quant = {s : Number => Gender => Animacy => Case => Str} ;
-- Num = {s : Gender => Animacy => Str ; n : Number} ;
DetQuant quant num = {
s = \\g,anim,c => quant.s ! num.n ! g ! anim ! c ++ num.s ! g ;
n = num.n
};
--DetCN : Det -> CN -> NP ; -- mtu huyo
{--
DetCN det cn =
let
anim = cn.anim ;
g = cn.g ;
n = det.n ;
mod = cn.hasAdj
in case <mod> of {
<False> => {
--s = \\c => n ++ det.s ! g ! c ++ cn.s ! n ++ det.s2 ;
s =\\c => c ++ cn.s ! n ++ det.s ! g ! anim ;
a = agr n g anim P3
} ;
<True> => {
s = cn.s1 ! n ++ det.s ! g ! anim ++ cn.s2 ! n ;
a = agr n g anim P3
}
};
--}
}