Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a bantu Functor #32

Merged
merged 4 commits into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/bantu/AdjectiveBantu.gf
Original file line number Diff line number Diff line change
@@ -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 changes: 27 additions & 0 deletions src/bantu/AdverbBantu.gf
Original file line number Diff line number Diff line change
@@ -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 changes: 111 additions & 0 deletions src/bantu/CatBantu.gf
Original file line number Diff line number Diff line change
@@ -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 changes: 30 additions & 0 deletions src/bantu/CommonBantu.gf
Original file line number Diff line number Diff line change
@@ -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 = "" ;

}
77 changes: 77 additions & 0 deletions src/bantu/ConjunctionBantu.gf
Original file line number Diff line number Diff line change
@@ -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 changes: 100 additions & 0 deletions src/bantu/DiffBantu.gf
Original file line number Diff line number Diff line change
@@ -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;
}