1
0
forked from GitHub/gf-rgl

added Bantu functor

This commit is contained in:
benson kituku
2018-10-03 11:17:11 +03:00
parent e2365f60d7
commit c82b09df1a
15 changed files with 1051 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
incomplete concrete AdjectiveBantu of Adjective =
CatBantu ** open CommonBantu, ResBantu, Prelude in {
flags coding=utf8;
lin
PositA a = {s = \\g,n => a.s !AAdj g n ;isPre = True } ;
ComparA a np = {
s = \\g,n => a.s !AComp g n ++ conjThan ++ np.s ! npNom ;
isPre = False} ;
UseComparA a = {s = \\g,n=> a.s !AComp g n;isPre = True};
AdjOrd ord = { -- find why it cannot generate tree
s = \\g,n => ord.s ! g ;
isPre = True
} ;
CAdvAP ad ap np = {
s = \\g,n => ad.s ++ ap.s !g! n ++ ad.p ++ np.s ! npNom ;
isPre = False
} ;
ComplA2 a np = {
s = \\g,n => a.s !AComp g n ++ a.c2 ++ np.s ! NPAcc;
isPre = False
} ;
ReflA2 a ={
s = \\g,n => a.s !AAdj g n ++ a.c2 ++ reflPron ! Ag g n P3 ;
} ;
SentAP ap sc = {
s = \\g,n => ap.s !g! n ++ sc.s ;
isPre = False
} ;
AdAP ada ap = {
s = \\g,n => ada.s ++ ap.s ! g ! n;
isPre = ap.isPre
} ;
UseA2 a2 = {s = \\g, n => a2.s !AAdj g n ;isPre = True } ;
AdvAP ap adv = {s = \\g,n => ap.s ! g ! n ++ adv.s ; isPre = False} ;
}

27
src/bantu/AdverbBantu.gf Normal file
View File

@@ -0,0 +1,27 @@
incomplete concrete AdverbBantu of Adverb =
CatBantu ** open CommonBantu, ResBantu, Prelude in {
lin
PositAdvAdj a = {s = a.s !AAdj G1 Sg} ;
ComparAdvAdj cadv a np =let agr = complAgr np.a
in {
s = cadv.s ++ a.s !AComp agr.g agr.n ++ cadv.p ++ np.s ! npNom
} ;
ComparAdvAdjS cadv a s = {
s = cadv.s ++ a.s !AComp G1 Sg ++ cadv.p ++ s.s
} ;
PrepNP prep np = let agr = complAgr np.a
in {s = prep.s!agr.n!agr.g ++ (np.s ! NPAcc) } ; --s = preOrPost prep.isPre prep.s (np.s ! NPAcc)
AdAdv = cc2 ;
PositAdAAdj a = {s = a.s !AAdj G1 Sg } ;
SubjS = cc2 ;
AdnCAdv cadv = {s = cadv.s ++ cadv.p} ;
}

111
src/bantu/CatBantu.gf Normal file
View File

@@ -0,0 +1,111 @@
incomplete concrete CatBantu of Cat =
CommonX - [Pol]
** open ResBantu, Prelude, ParamX in {
flags optimize=all_subs ;
coding=utf8 ;
lincat
Pol = {s : Str ; b : Bool} ;
S = {s : Str} ;
QS = {s : QForm => Str} ;
RS = {s : Agr => Str ; c : NPCase} ; -- c for it clefts
SSlash = {s : Str ; c2 : Str} ;
-- Sentence
-- Cl = {s : Tense => Anteriority => Bool => Str} ;
-- ClSlash = {
-- s : ResKam.Tense => Anteriority => Bool => Str ;
-- } ;
--
-- Question
-- QCl = {s : ResKam.Tense => Anteriority => Polarity => QForm => Str} ;
IP = {s : NPCase => Str ; n : Number} ;
IComp = {s : Str} ;
IDet = {s : Str ; n : Number} ;
IQuant = {s : Number => Str} ;
-- Relative
{-}
RCl = {
s : ResKam.Tense => Anteriority => Polarity => Agr => Str ;
c : NPCase
} ;
RP = {s : RCase => Str ; a : RAgr} ;
-}
-- Verb
VP = ResBantu.VP ;
VPSlash = ResBantu.SlashVP ;
Comp = {s : Agr => Str} ;
-- Adjective
AP = {s : Gender => Number => Str };
-- Noun
CN = CNoun;
NP = {s : NPCase => Str ; a : Agr} ;
Pron = {s: PronForm=>Str; a : Agr};-- Pronoun ;
Det = {s : DetForm => Str ; n : Number } ;
Predet = {s : Gender =>Str} ;
Ord = { s : Gender => Str } ;
Num = {s : Gender => Str ; n : Number } ;
Card = {s : Gender => Str ; n : Number} ;
Quant = {s : Number => Gender => Str } ;
DAP = {s : DetForm => Str ; n : Number} ;
-- Numeral
Numeral = {s : CardOrd => Gender => Str ; n : Number} ;
Digits = {s : CardOrd => Gender => Str ; n : Number} ;
-- Structural
Conj = {s1,s2 : Str ; n : Number} ;
Subj = {s : Str} ;
Prep = {s: Number => Gender => Str} ;
-- Open lexical classes, e.g. Lexicon
V, VS, VQ, VA, V3,V2,VV, V2S, V2Q, V2V,V2A= Verb ;
-- V2, VV, V2S, V2Q = Verb ** {c2 : Str} ;
-- V3, V2V,V2A = Verb ** {c2, c3 : Prep} ;
A = {s : AForm => Str } ;
A2 = {s :AForm => Str }** {c2 : Str} ;
N = {s : Number => Case => Str ; g : Gender} ;
-- N2 = {s : Number => Case => Str ; g : Gender} ** {c2 : Str} ;
N2 = {s : Number => Case => Str ; g : Gender} ** {c2 : Prep} ;
N3 = {s : Number => Case => Str ; g : Gender} ** {c2,c3 : Prep} ;
PN = {s : Case => Str ; g : Gender} ;
--Tense = {s : Str ; t : ResKam.Tense} ;
linref
SSlash = \ss -> ss.s ++ ss.c2 ;
-- ClSlash = \cls -> cls.s ! Pres ! Simul ! CPos ! oDir ++ cls.c2 ;
-- VP = \vp -> infVP VVAux vp Simul CPos (agrP3 Sg) ;
-- VPSlash = \vps -> infVP VVAux vps Simul CPos (agrP3 Sg) ++ vps.c2;
--
Conj = \conj -> conj.s1 ++ conj.s2 ;
-- V, VS, VQ, VA = \v -> infVP VVAux (predV v) Simul CPos (agrP3 Sg);
-- V2, V2A, V2Q, V2S = \v -> infVP VVAux (predV v) Simul CPos (agrP3 Sg) ++ v.c2;
-- V3 = \v -> infVP VVAux (predV v) Simul CPos (agrP3 Sg) ++ v.c2 ++ v.c3;
-- VV = \v -> infVP VVAux (predVV v) Simul CPos (agrP3 Sg) ;
-- V2V = \v -> infVP VVAux (predVc v) Simul CPos (agrP3 Sg) ;
Det =\d -> d.s!Obj G1;
CN = \cn -> cn.s!Sg!Nom ++ cn.s2!Sg ;
-- A = \a -> a.s ! AAdj G1 Sg ;
-- A2 = \a -> a.s ! AAdj G1 Sg ++ a.c2 ;
N = \n -> n.s ! Sg ! Nom ;
N2 = \n -> n.s ! Sg ! Nom ++ n.c2.s!Sg!G1 ;
N3 = \n -> n.s ! Sg ! Nom ++ n.c2.s!Sg!G1 ++ n.c3.s!Sg!G1 ;
}

30
src/bantu/CommonBantu.gf Normal file
View File

@@ -0,0 +1,30 @@
----1 Auxiliary operations common for Bantu languages
--
-- This module contains operations that are shared by the Bantu
-- languages. The complete set of auxiliary operations needed to
-- implement [Test Test.html] is defined in [ResBantu ResBantu.html],
-- which depends on [DiffBantu DiffBantu.html].
resource CommonBantu = ParamX ** open Prelude in {
flags optimize=all ;
coding=utf8 ;
param
Case = Nom | Loc ;
NPCase = NCase Case | NPAcc | NPNomPoss ;
CardOrd = NCard | NOrd ;
oper
---- Conjunction Agreements (as fas as indep. of Gender) ----
conjPPerson : Person -> Person -> Person = \p,q ->
case <p,q> of {
<_,P1> | <_,P2> => P1 ;
<P1,P3> => P1 ;
<P2,P3> => P2 ;
<P3,P3> => P3
};
artIndef = "" ;
}

View File

@@ -0,0 +1,77 @@
incomplete concrete ConjunctionBantu of Conjunction =
CatBantu ** open CommonBantu, ResBantu, Coordination, Prelude in {
flags optimize=all_subs ;
lin
ConjS = conjunctDistrSS ;
ConjAdv = conjunctDistrSS ;
ConjAdV = conjunctDistrSS ;
ConjNP conj ss = conjunctDistrTable NPCase conj ss ** {
a = Ag (agrFeatures ss.a).g (conjNumber (agrFeatures ss.a).n conj.n) (agrFeatures ss.a).p ; -- a = conjAgr (agrP3 conj.n) ss.a
} ;
ConjAP conj ss = conjunctDistrTable2 Gender Number conj ss;-- ** { isPre = ss.isPre } ;
ConjRS conj ss = conjunctDistrTable Agr conj ss ** {
c = ss.c
} ;
ConjIAdv = conjunctDistrSS ;
ConjCN conj cn = {
s = \\num,c => conj.s1 ++ cn.n1.s ! num!c ++ conj.s2 ++ cn.n2.s ! num!c ;
g = conjGender cn.n1.g cn.n2.g ;
s2 = \\num => [];
} ;
ConjDet c xs = { s = table {
Sub => [] ;
Obj g => xs.s1!Sub ++ c.s2 ++ xs.s2 !Obj g} ;
n = xs.n};
-- These fun's are generated from the list cat's.
BaseS = twoSS ;
ConsS = consrSS comma ;
BaseAdv = twoSS ;
ConsAdv = consrSS comma ;
BaseAdV = twoSS ;
ConsAdV = consrSS comma ;
BaseNP x y = twoTable NPCase x y ** {a = conjAgr Sg x.a y.a} ;
ConsNP xs x = consrTable NPCase comma xs x ** {a = conjAgr Sg xs.a x.a} ;
BaseAP x y = twoTable2 Gender Number x y ;
ConsAP xs x = consrTable2 Gender Number comma xs x ;
BaseRS x y = twoTable Agr x y ** {c = y.c} ;
ConsRS xs x = consrTable Agr comma xs x ** {c = xs.c} ;
BaseIAdv = twoSS ;
ConsIAdv = consrSS comma ;
BaseCN x y = { n1 = x ; n2 = y } ;
ConsCN xs x = {
n1 = {
s = \\num,c => x.n1.s ! num!c ++ comma ++ x.n2.s ! num !c ;
g = x.n2.g ;
s2 = \\num => [] ;
} ;
n2 = xs ;
} ;
BaseDAP x y = twoTable DetForm x y ** {n = y.n} ;
ConsDAP x xs = consrTable DetForm comma x xs ** {n = xs.n} ;
--BaseDet x y = twoTable DetForm x y ** {n = y.n} ;
--ConsDet xs x = consrTable DetForm comma xs x ** {n = xs.n} ;
lincat
[S] = {s1,s2 : Str} ;
[Adv] = {s1,s2 : Str} ;
[AdV] = {s1,s2 : Str} ;
[IAdv] = {s1,s2 : Str} ;
[NP] = {s1,s2 : NPCase => Str ; a : Agr} ;
[AP] = {s1,s2 : Gender => Number => Str} ; --isPre : Bool} ;
[RS] = {s1,s2 : Agr => Str ; c : NPCase} ;
[CN] = {n1,n2 : CNoun } ;
[DAP] = {s1,s2 : DetForm => Str ; n : Number} ;
}

100
src/bantu/DiffBantu.gf Normal file
View File

@@ -0,0 +1,100 @@
--1 Differences between Bantu languages
interface DiffBantu = open CommonBantu, Prelude in {
flags coding=utf8 ;
-- HL: everything depending on Gender is not common, so it must not
-- be in CommonBantu, but here in DiffBantu.
oper
Gender : PType ;
firstGender : Gender ; -- G1
secondGender : Gender ; -- G2
Noun : Type = {s : Number => Case => Str ; g : Gender};
CNoun : Type = {s : Number => Case => Str ; g : Gender; s2 : Number => Str};
AAgr : Type = {g : Gender ; n : Number} ;
param
Agr = Ag Gender Number Person ;
oper
-- AGRE = {g : Gender ; n : Number ; p : Person} ;
Agre : Type = {g : Gender ; n : Number ; p : Person} ;
agre : Gender -> Number -> Person -> Agre = \g,n,p -> {g = g ; n = n ; p = p} ;
agrFeatures : Agr -> Agre = \a -> case a of {Ag g n p => {g = g ; n = n ; p = p}} ;
getGender : Agr -> Gender = \a -> case a of {Ag g _ _ => g};
getNumber : Agr -> Number = \a -> case a of {Ag _ n _ => n};
getPerson : Agr -> Person = \a -> case a of {Ag _ _ p => p};
clitAgr : Agr -> {n : Number ; p : Person} = \a -> case a of {
Ag _ n p => {n = n; p = p}
} ;
complAgr : Agr -> {g : Gender ; n : Number} = \a -> case a of {
Ag g n _ => {g = g ; n = n}
} ;
predetAgr : Agr -> {g : Gender} = \a -> case a of {
Ag g _ _ => {g = g}
} ;
verbAgr : Agr -> {g : Gender ; n : Number ; p : Person} = \a -> case a of {
Ag g n p => {g = g ; n = n ; p = p}
} ; -- verbAgr = agrFeatures, why both? HL
detAgr : Agr -> {g : Gender ; p : Person} = \a -> case a of {
Ag g _ p => {g = g; p = p}
} ;
agrG1 : Number -> Person -> Agr = \n,p ->
Ag firstGender n p ;
dapagr : Gender -> Person -> Agr = \g,p ->
Ag g Sg p ;
agrP3 : Gender -> Number -> Agr = \g,n ->
Ag g n P3 ;
aagr : Gender -> Number -> AAgr = \g,n ->
{g = g ; n = n} ;
---- Conjunction Agreements----
conjAgr : Number -> Agr -> Agr -> Agr = \n,xa,ya ->
let
x = agrFeatures xa ; y = agrFeatures ya
in
Ag (conjGender x.g y.g) (conjNumber (conjNumber x.n y.n) n)
(conjPPerson x.p y.p) ;
conjGender : Gender -> Gender -> Gender ;
param
-- AForm = AAdj Gender Number | AComp Gender Number ;
PronForm= Pers | Poss Number Gender;
DetForm = Sub | Obj Gender ;
-- HL: the above is material removed from CommonBantu and adapted --
oper
conjThan : Str ; --one of them in bantu
conjThat : Str ;
superVery : Str ; -- one of bantu
reflPron : Agr => Str ; -- second of bantu.
param
VForm ;
DForm ;
AForm;
oper
ProunSgprefix : Gender -> Str ; -- added, HL
ProunPlprefix : Gender -> Str ; -- added, HL
Cardoneprefix : Gender -> Str;
Cardtwoprefix : Gender -> Str;
Allpredetprefix : Gender -> Str;
PrefixPlNom : Gender -> Str;
mkprefix,Ordprefix : Gender -> Str;
Cardprefix : Gender -> Str ;
Mostpredetprefix : Gender -> Str;
Adjpprefix : Gender -> Number -> Str;
VowelAdjprefix: Gender -> Number -> Str;
ConsonantAdjprefix: Gender -> Number -> Str;
}

169
src/bantu/NounBantu.gf Normal file
View File

@@ -0,0 +1,169 @@
incomplete concrete NounBantu of Noun =
-- HL: Structural added for part_Prep, possess_Prep; contains Cat
CatBantu ** open Structural, ResBantu, Prelude in {
flags optimize=all_subs ; coding = utf8 ;
lin
-- Det -> CN -> NP
-- e.g. 'the man'
DetCN det cn =let g = cn.g ; n = det.n in {
s = \\c => det.s!Sub ++ cn.s ! det.n !npcase2case c ++ det.s!Obj g ++ cn.s2!det.n;
a =Ag cn.g det.n P3 ;
} ;
-- PN -> NP
-- e.g. 'John'
UsePN pn = {s = \\c => pn.s !npcase2case c ; a = Ag pn.g Sg P3 } ;
-- Pron -> NP
-- e.g. 'he'
UsePron pron = let agr = verbAgr pron.a;
n=agr.n; g=agr.g
in {s = table {
NCase c => pron.s!Pers ;
NPAcc => pron.s!Pers ;
NPNomPoss => pron.s!Poss n g };
a = Ag agr.g agr.n agr.p;
} ;
-- Predet -> NP -> NP
-- e.g. 'only the man'
PredetNP pred np =
let agr = predetAgr np.a in {
s = \\c => np.s ! NCase Nom ++ pred.s ! agr.g ;
a =Ag agr.g Pl P3 ;
} ;
{-} PPartNP np v2 = {
s = \\c => np.s ! c ++ v2.s ! VPPart ;
a = np.a
} ;
-}
RelNP np rs = {
s = \\c => np.s ! NCase Nom ++ frontComma ++ rs.s ! np.a ++ finalComma ;
a = np.a
} ;
-- NP -> Adv -> NP
-- e.g. 'Paris today'
AdvNP np adv = {
s = \\c => np.s ! NCase Nom ++ adv.s ;
a = np.a
} ;
ExtAdvNP np adv = {
s = \\c => np.s ! NCase Nom ++ embedInCommas adv.s ;
a = np.a
} ;
DetQuant quant num = { s = table{ Sub => [];
Obj g=>quant.s ! num.n! g ++ num.s !g };
n = num.n } ;
DetQuantOrd quant num ord ={ s = table{ Sub => [];
Obj g=>quant.s ! num.n! g ++ num.s! g ++ ord.s ! g };
n = num.n } ;
DetNP det = { s = \\c => det.s!Obj G1 ;
a = agrP3 G1 det.n } ;
PossPron pron = { s = \\n,g => pron.s!Poss n g } ;
NumSg = {s = \\_ => []; n = Sg };--; hasCard = False} ;
NumPl = {s = \\_ => []; n = Pl };--; hasCard = False} ;
--b NoOrd = {s = []} ;
NumCard n = n ;--** {hasCard = True} ;
NumDigits n = {s = n.s ! NCard ; n = n.n} ;
OrdDigits n = { s = n.s ! NOrd} ;
NumNumeral numeral = {s = numeral.s ! NCard; n = numeral.n} ;
OrdNumeral numeral = {s = numeral.s ! NOrd} ;
AdNum adn num = {s = \\g => adn.s ++ num.s!g ; n = num.n} ;
OrdSuperl a ={s = \\g => a.s! AAdj g Sg ++ superVery} ;-- find how to include plular
OrdNumeralSuperl n a = {s = \\g => n.s ! NOrd !g ++ a.s !AAdj g Sg } ;--what PL
-- DefArt = { s = \\n,g => []} ; --what PL
IndefArt, DefArt = { s = \\n,g =>[] } ;
--IndefArt = {s = \\ n,g => artIndef } ;
-- CN -> NP
MassNP cn = let g = cn.g ; n = Sg | Pl in {
s = \\c => cn.s ! n! npcase2case c;
a = Ag g n P3 ;
} ;
UseN n = { s = n.s ; s2 = \\_ => [] ; g = n.g} ; --n
UseN2 n = { s = n.s ; s2 = \\_ => [] ; g = n.g} ;--n ;
UseN3 n = { s = n.s ; s2 = \\_ => [] ; g = n.g} ; --n ;
Use2N3 f = {
s = \\n,c => f.s ! n ! Nom ;
s2 = \\_ => [] ;
g = f.g ;
c2 = f.c2
} ;
Use3N3 f = {
s = \\n,c => f.s ! n ! Nom ;
s2 = \\_ => [] ;
g = f.g ;
c2 = f.c3
} ;
ComplN2 n2 np = {s = \\n,c => n2.s ! n ! Nom ++ n2.c2.s!n!n2.g ++ np.s ! NCase Nom ;
s2 = \\_ => [] ;
g = n2.g
};
ComplN3 n3 np = {
s = \\n,c => n3.s ! n ! Nom ++ n3.c2.s!n!n3.g ++ np.s ! NCase Nom;
g = n3.g ;
c2 = n3.c3
} ;
AdjCN ap cn = {s = cn.s ; g = cn.g;
s2 = \\n =>cn.s2! n ++ ap.s ! cn.g ! n} ;
RelCN cn rs = {
s = \\n,c => cn.s ! n ! Nom ++ rs.s ! Ag cn.g n P3 ; s2 =\\n => []; --another persons
g = cn.g
} ;
-- AP -> CN -> CN
-- e.g. 'big house'
AdvCN cn ad = {s = \\n,c => cn.s ! n ! Nom ++ ad.s ;s2 =\\n => []; g = cn.g} ;
SentCN cn sc = {s = \\n,c => cn.s ! n ! Nom ++ sc.s ; s2 =\\n => []; g = cn.g} ;
-- ApposCN cn np = {s = \\n,c => cn.s ! n ! Nom ++ np.s ! NCase Nom ; s2 =\\n => []; g = cn.g} ;
-- PossNP : CN -> NP -> CN
-- e.g. 'house of Paris', 'house of mine'
PossNP cn np =let agr = detAgr np.a in
{s = \\n,c => cn.s ! n ! Nom ++ possess_Prep.s! n!cn.g ++ np.s ! NPNomPoss;
s2 =\\n => []; g = cn.g} ;
-- PartNP : CN -> NP -> CN
-- e.g. 'glass of wine'
PartNP cn np = {s = \\n,c => cn.s ! n ! Nom ++ part_Prep.s! n!cn.g ++ np.s ! NPAcc ; s2 =\\n => []; g = cn.g} ;
-- CountNP : Det -> NP -> NP
-- e.g. 'three of them', 'some of the boys'
CountNP det np = let agr = verbAgr np.a
in {
s = \\c => det.s!Obj agr.g ++ part_Prep.s!agr.n!agr.g ++ np.s!c ;--NPAcc was removed
a = Ag agr.g agr.n agr.p
} ;
AdjDAP det ap = { s = table{ Sub => [] ;
Obj g =>det.s!Obj g ++ ap.s!g !det.n};
n = det.n };
DetDAP d = { s=d.s; n=d.n };
ApposCN cn np = let agr = complAgr np.a in
{s = \\n,c => np.s ! NCase Nom --++ possess_Prep.s!n!agr.g
++ cn.s !n ! Nom ; s2 =\\n => ""; g = cn.g} ;
}

31
src/bantu/PhraseBantu.gf Normal file
View File

@@ -0,0 +1,31 @@
incomplete concrete PhraseBantu of Phrase =
CatBantu ** open CommonBantu, ResBantu, Prelude in { }
{-}
flags optimize = all_subs ;
lin
PhrUtt pconj utt voc = {s = pconj.s ++ utt.s ++ voc.s} ;
UttS s = {s = s.s ! Indic} ;
UttQS qs = {s = qs.s ! QDir} ;
UttImpSg pol imp = {s = pol.s ++ imp.s ! pol.p ! ImpF Sg False ! Fem} ;
UttImpPl pol imp = {s = pol.s ++ imp.s ! pol.p ! ImpF Pl False ! Fem} ;
UttImpPol pol imp = {s = pol.s ++ imp.s ! pol.p ! ImpF Sg True ! Fem} ;
UttIP ip = {s = ip.s ! Nom} ; --- Acc also
UttIAdv iadv = iadv ;
UttNP np = {s = (np.s ! Nom).ton} ;
UttVP vp = {s = infVP vp (agrP3 Fem Sg)} ; --- Agr
UttAdv adv = adv ;
UttCN n = {s = n.s ! Sg} ;
UttAP ap = {s = ap.s ! AF Masc Sg} ;
UttCard n = {s = n.s ! Masc} ;
UttInterj i = i ;
NoPConj = {s = []} ;
PConjConj conj = {s = conj.s2} ;
NoVoc = {s = []} ;
VocNP np = {s = "," ++ (np.s ! Nom).ton} ;
-}

118
src/bantu/QuestionBantu.gf Normal file
View File

@@ -0,0 +1,118 @@
incomplete concrete QuestionBantu of Question =
CatBantu ** open CommonBantu, ResBantu, Prelude in {
{-
flags optimize=all_subs ;
lin
QuestCl cl = {
s = \\t,a,p =>
let cls = cl.s ! DDir ! t ! a ! p ---- DInv?
in table {
QDir => cls ! Indic ;
QIndir => subjIf ++ cls ! Indic
}
} ;
QuestVP qp vp = {
s = \\t,a,b,_ =>
let
cl = mkClause (qp.s ! Nom) False False (agrP3 qp.a.g qp.a.n) vp
in
cl.s ! DDir ! t ! a ! b ! Indic
} ;
QuestSlash ip slash = {
s = \\t,a,p =>
let
cls : Direct -> Str =
\d -> slash.s ! ip.a ! d ! t ! a ! p ! Indic ;
who = slash.c2.s ++ ip.s ! slash.c2.c
in table {
QDir => who ++ cls DInv ;
QIndir => who ++ cls DDir
}
} ;
QuestIAdv iadv cl = {
s = \\t,a,p,q =>
let
ord = case q of {
QDir => iAdvQuestionInv ;
QIndir => iAdvQuestionInv
} ;
cls = cl.s ! ord ! t ! a ! p ! Indic ;
why = iadv.s
in why ++ cls
} ;
QuestIComp icomp np = {
s = \\t,a,p,_ =>
let
vp = predV (selectCopula icomp.cop) ;
cls = (mkClause (np.s ! Nom).comp np.hasClit np.isPol np.a vp).s !
DInv ! t ! a ! p ! Indic ;
why = icomp.s ! complAgr np.a ;
in why ++ cls
} ;
PrepIP p ip = {
s = p.s ++ ip.s ! p.c
} ;
AdvIP ip adv = {
s = \\c => ip.s ! c ++ adv.s ;
a = ip.a
} ;
IdetCN idet cn =
let
g = cn.g ;
n = idet.n ;
a = aagr g n
in {
s = \\c => idet.s ! g ! c ++ cn.s ! n ;
a = a
} ;
IdetIP idet =
let
g = Masc ; ---- Fem in Extra
n = idet.n ;
a = aagr g n
in {
s = \\c => idet.s ! g ! c ;
a = a
} ;
IdetQuant idet num =
let
n = num.n ;
in {
s = \\g,c => idet.s ! n ! g ! c ++ num.s ! g ;
n = n
} ;
AdvIAdv i a = {s = i.s ++ a.s} ;
CompIAdv a = {s = \\_ => a.s ; cop = estarCopula} ;
CompIP p = {s = \\_ => p.s ! Nom ; cop = serCopula} ;
lincat
QVP = ResBantu.VP ;
lin
ComplSlashIP vp ip = insertObject vp.c2 (heavyNP {s = ip.s ; a = {g = ip.a.g ; n = ip.a.n ; p = P3}}) vp ;
AdvQVP vp adv = insertAdv adv.s vp ;
AddAdvQVP vp adv = insertAdv adv.s vp ;
QuestQVP qp vp = {
s = \\t,a,b,_ =>
let
cl = mkClause (qp.s ! Nom) False False (agrP3 qp.a.g qp.a.n) vp
in
cl.s ! DDir ! t ! a ! b ! Indic
} ;
-}
}

View File

@@ -0,0 +1,50 @@
incomplete concrete RelativeBantu of Relative =
CatBantu ** open Prelude, CommonBantu, ResBantu in {
{-
flags optimize=all_subs ;
lin
RelCl cl = {
s = \\ag,t,a,p,m => pronSuch ! complAgr ag ++ conjThat ++
cl.s ! DDir ! t ! a ! p ! m ;
c = Nom
} ;
--- more efficient to compile than case inside mkClause; see log.txt
RelVP rp vp = case rp.hasAgr of {
True => {s = \\ag =>
(mkClause
(rp.s ! False ! complAgr ag ! Nom) False False
(Ag rp.a.g rp.a.n P3)
vp).s ! DDir ; c = Nom} ;
False => {s = \\ag =>
(mkClause
(rp.s ! False ! complAgr ag ! Nom) False False
ag
vp).s ! DDir ; c = Nom
}
} ;
RelSlash rp slash = {
s = \\ag,t,a,p,m =>
let aag = complAgr ag
in
slash.c2.s ++
rp.s ! False ! aag ! slash.c2.c ++
slash.s ! aag ! DDir ! t ! a ! p ! m ; --- ragr
c = Acc
} ;
FunRP p np rp = {
s = \\_,a,c => (np.s ! Nom).ton ++ p.s ++ rp.s ! True ! a ! p.c ;
a = complAgr np.a ;
hasAgr = True
} ;
IdRP = {
s = relPron ;
a = {g = Masc ; n = Sg} ;
hasAgr = False
} ;
-}
}

93
src/bantu/ResBantu.gf Normal file
View File

@@ -0,0 +1,93 @@
--1 Bantu auxiliary operations.
interface ResBantu = DiffBantu ** open CommonBantu in {
flags
optimize=all ;
coding=utf8 ;
--2 Constants uniformly defined in terms of language-dependent constants
oper
npNom : NPCase = NCase Nom ;
npLoc : NPCase = NCase Loc ;
npcase2case : NPCase -> Case = \nc -> case nc of {NCase c => c ; _ => Nom} ;
mkNP : (i,my : Str) -> Gender -> Number -> Person ->
{s : NPCase => Str ; a : Agr} = \i,my,g,n,p ->
{ s = table {
NCase Nom => i ;
NPAcc => my ;
NCase Loc | NPNomPoss => my -- works for normal genitives, "whose", etc.
} ;
a = Ag g n p ;
};
regNP : Str ->Gender -> Number -> {s : NPCase => Str ; a : Agr} = \that,g, n ->
mkNP that that g n P3 ;
mkPron: (i, mine : Str) -> Gender -> Number -> Person ->
{s: PronForm => Str ; a : Agr} = \i,mine, g,n,p ->
{ s = table {
Pers => i;
Poss n g => case <n,g> of {
<Sg ,_> => ProunSgprefix g + mine ;
<Pl,_> => ProunPlprefix g + mine}
} ;
a = Ag g n p } ;
Verb : Type = {s : Bool => VForm => Str} ;
VerbForms : Type = Tense => Anteriority => Bool => Agre => Str;
VP : Type = {s:VerbForms ; obj : Agr => Str};
SlashVP = VP ** {c2 : Str} ;
predV : Verb -> VP = \verb -> {
s = \\t,ant,b,agre =>
let
inf = verb.s !b! VInf ;
pres = verb.s !True! VPres agre.g agre.n agre.p ;
presn = verb.s !False! VPres agre.g agre.n agre.p ;
past = verb.s !True! VPast agre.g agre.n agre.p ;
pastn = verb.s !False! VPast agre.g agre.n agre.p ;
fut = verb.s !True! VFut agre.g agre.n agre.p ;
futn = verb.s !False! VFut agre.g agre.n agre.p ;
in
case <t,ant,b> of {
<Pres,_, True> => pres ;
<Fut, _, True> => fut ; --# notpresent
<Pas, _, True> => past ; --# notpresent
<Pres,_, False> => presn ;
<Fut, _, False> => futn ; --# notpresent
<Pas, _, False> => pastn
-- ; <_, _, _> => inf --# notpresent -- never reached
} ;
obj = \\_ => [] };
Clause : Type = {
s : Tense => Anteriority => Bool => Str
} ;
mkClause : Str -> Agre -> VP -> Clause =
\subj,agr,vp -> {
s = \\t,a,b =>
let
verb = vp.s ! t ! a ! b ! agr
in
subj ++ verb
} ;
finalComma : Str = pre {"," | "." => []; "" => SOFT_BIND ++ ","; _ => []} ;
frontComma : Str = SOFT_BIND ++ "," ;
}
-- insertObject:
-- p -cat=Cl -tr "la femme te l' envoie"
-- PredVP (DetCN (DetSg DefSg NoOrd) (UseN woman_N))
-- (ComplV3 send_V3 (UsePron he_Pron) (UsePron thou_Pron))
-- la femme te l' a envoyé
--
-- p -cat=Cl -tr "la femme te lui envoie"
-- PredVP (DetCN (DetSg DefSg NoOrd) (UseN woman_N))
-- (ComplV3 send_V3 (UsePron thou_Pron) (UsePron he_Pron))
-- la femme te lui a envoyée

View File

@@ -0,0 +1,74 @@
incomplete concrete SentenceBantu of Sentence =
CatBantu ** open Prelude, CommonBantu, ResBantu in {
{-
flags optimize=all_subs ;
coding=utf8 ;
lin
PredVP np vp = mkClause (np.s ! npNom) np.a vp ;
PredSCVP sc vp = mkClause sc.s (agrP3 Sg) vp ;
ImpVP vp = {
s = \\pol,n =>
let
agr = AgP2 (numImp n) ;
verb = infVP VVAux vp Simul CPos agr ;
dont = case pol of {
CNeg True => "don't" ;
CNeg False => "do" ++ "not" ;
_ => []
}
in
dont ++ verb
} ;
SlashVP np vp =
mkClause (np.s ! npNom) np.a vp ** {c2 = vp.c2} ;
AdvSlash slash adv = {
s = \\t,a,b,o => slash.s ! t ! a ! b ! o ++ adv.s ;
c2 = slash.c2
} ;
SlashPrep cl prep = cl ** {c2 = prep.s} ;
SlashVS np vs slash =
mkClause (np.s ! npNom) np.a
(insertObj (\\_ => conjThat ++ slash.s) (predV vs)) **
{c2 = slash.c2} ;
EmbedS s = {s = conjThat ++ s.s} ;
EmbedQS qs = {s = qs.s ! QIndir} ;
EmbedVP vp = {s = infVP VVInf vp Simul CPos (agrP3 Sg)} ; --- agr
UseCl t p cl = {
s = t.s ++ p.s ++ cl.s ! t.t ! t.a ! p.b } ;
-- UseCl t p cl = {s = t.s ++ p.s ++ cl.s ! t.t ! p.b} ;
UseQCl t p cl = {
s = \\q => t.s ++ p.s ++ cl.s ! t.t ! t.a ! ctr p.p ! q
} ;
UseRCl t p cl = {
s = \\r => t.s ++ p.s ++ cl.s ! t.t ! t.a ! ctr p.p ! r ;
c = cl.c
} ;
UseSlash t p cl = {
s = t.s ++ p.s ++ cl.s ! t.t ! t.a ! ctr p.p ! oDir ;
c2 = cl.c2
} ;
AdvS a s = {s = a.s ++ s.s} ;
ExtAdvS a s = {s = a.s ++ frontComma ++ s.s} ;
SSubjS a s b = {s = a.s ++ frontComma ++ s.s ++ b.s} ;
RelS s r = {s = s.s ++ frontComma ++ r.s ! agrP3 Sg} ;
oper
ctr : CPolarity -> CPolarity = \x -> x ;
--- ctr = contrNeg True ; -- contracted negations
-}
}

View File

@@ -0,0 +1,41 @@
incomplete concrete SymbolBantu of Symbol =
CatBantu ** open Prelude, CommonBantu, ResBantu in {
lin
SymbPN i = {s = i.s ; g = Masc} ;
IntPN i = {s = i.s ; g = Masc} ;
FloatPN i = {s = i.s ; g = Masc} ;
NumPN i = {s = i.s!Masc ; g = Masc} ;
CNIntNP cn i = heavyNP {
s = \\c => prepCase c ++ cn.s ! Sg ++ i.s ;
a = agrP3 cn.g Sg ;
hasClit = False
} ;
CNSymbNP det cn xs = let g = cn.g in heavyNP {
s = \\c => det.s ! g ! c ++ cn.s ! det.n ++ xs.s ;
a = agrP3 g det.n ;
hasClit = False
} ;
CNNumNP cn i = heavyNP {
s = \\c => artDef False cn.g Sg c ++ cn.s ! Sg ++ i.s ! Masc ;
a = agrP3 cn.g Sg ;
hasClit = False
} ;
SymbS sy = {s = \\_ => sy.s} ;
SymbNum n = {s = \\_ => n.s ; isNum = True ; n = Pl} ;
SymbOrd n = {s = \\_ => n.s ++ BIND ++ "º"} ; -- feminine variant ª, also variants 1.º and 1.ª
lincat
Symb, [Symb] = SS ;
lin
MkSymb s = s ;
BaseSymb = infixSS "et" ; ----
ConsSymb = infixSS "," ;
}

15
src/bantu/Tense10Bantu.gf Normal file
View File

@@ -0,0 +1,15 @@
incomplete concrete TenseBantu of Tense =
CatBantu [Tense,Temp], TenseX [Ant,AAnter,ASimul] **
open ResBantu, CommonBantu, Prelude in {
lin
TTAnt t a = {s = a.s ++ t.s ; a = a.a ; t = t.t} ;
TPres = {s = []} ** {t = RPres} ;
TPast = {s = []} ** {t = RPast} ; --# notpresent
TFut = {s = []} ** {t = RFut} ; --# notpresent
TCond = {s = []} ** {t = RCond} ; --# notpresent
PPos = {s = [] ; p = RPos} ;
PNeg = {s = [] ; p = RNeg False} ;
}

69
src/bantu/VerbBantu.gf Normal file
View File

@@ -0,0 +1,69 @@
incomplete concrete VerbBantu of Verb =
CatBantu ** open Prelude, CommonBantu, ResBantu in {
{-
flags optimize=all_subs ;
lin
UseV = predV ;
SlashV2a v = predV v ** {c2 = v.c2 ; gapInMiddle = False} ;
Slash2V3 v np =
insertObjc (\\_ => v.c2 ++ np.s ! NPAcc) (predV v ** {c2 = v.c3 ; gapInMiddle = False}) ;
Slash3V3 v np =
insertObjc (\\_ => v.c3 ++ np.s ! NPAcc) (predVc v) ; ----
ComplVV v vp = insertObj (\\a => infVP v.typ vp Simul CPos a) (predVV v) ; ---- insertExtra?
ComplVS v s = insertExtra (conjThat ++ s.s) (predV v) ;
--- ComplVS v s = insertObj (variants {\\_ => conjThat ++ s.s; \\_ => s.s}) (predV v) ;
ComplVQ v q = insertExtra (q.s ! QIndir) (predV v) ;
-- ComplVA v ap = insertObj (ap.s (predV v)) ;
SlashV2V v vp = insertObjc (\\a => v.c3 ++ infVP v.typ vp Simul CPos a) (predVc v) ;
SlashV2S v s = insertExtrac (conjThat ++ s.s) (predVc v) ; ---- insertExtra?
--- SlashV2S v s = insertObjc (variants {\\_ => conjThat ++ s.s; \\_ => s.s}) (predVc v) ;
SlashV2Q v q = insertExtrac (q.s ! QIndir) (predVc v) ;
-- SlashV2A v ap = insertObjc (\\a => ap.s ! a) (predVc v) ; ----
ComplSlash vp np = case vp.gapInMiddle of {
True => insertObjPre (\\_ => vp.c2 ++ np.s ! NPAcc) vp ;
False => insertObj (\\_ => vp.c2 ++ np.s ! NPAcc) vp
} ;
SlashVV vv vp =
insertObj (\\a => infVP vv.typ vp Simul CPos a) (predVV vv) **
{c2 = vp.c2 ; gapInMiddle = vp.gapInMiddle} ;
SlashV2VNP vv np vp =
insertObjPre (\\_ => vv.c2 ++ np.s ! NPAcc)
(insertObjc (\\a => vv.c3 ++ infVP vv.typ vp Simul CPos a) (predVc vv)) **
{c2 = vp.c2 ; gapInMiddle = vp.gapInMiddle} ;
UseComp comp = insertObj comp.s (predAux auxBe) ;
AdvVP vp adv = insertObj (\\_ => adv.s) vp ;
ExtAdvVP vp adv = insertObj (\\_ => frontComma ++ adv.s ++ finalComma) vp ;
AdVVP adv vp = insertAdV adv.s vp ;
AdvVPSlash vp adv = insertObj (\\_ => adv.s) vp ** {c2 = vp.c2 ; gapInMiddle = vp.gapInMiddle} ;
AdVVPSlash adv vp = insertAdV adv.s vp ** {c2 = vp.c2 ; gapInMiddle = vp.gapInMiddle} ;
ReflVP v = insertObjPre (\\a => v.c2 ++ reflPron ! a) v ;
PassV2 v = insertObj (\\_ => v.s ! VPPart ++ v.p) (predAux auxBe) ;
---b UseVS, UseVQ = \vv -> {s = vv.s ; c2 = [] ; isRefl = vv.isRefl} ; -- no "to"
--CompAP ap = ap ;
CompNP np = {s = \\_ => np.s ! NPAcc} ;
CompAdv a = {s = \\_ => a.s} ;
CompCN cn = {s = \\a => case (fromAgr a).n of {
Sg => artIndef ++ cn.s ! Sg ! Nom ;
Pl => cn.s ! Pl ! Nom
}
} ;
-- UseCopula = auxBe ;
VPSlashPrep vp p = vp ** {c2 = p.s!Sg!G1 } ;
-}
}