1
0
forked from GitHub/gf-rgl

merge of the manual and automatic grammars

This commit is contained in:
Krasimir Angelov
2025-11-06 11:47:31 +01:00
parent 066d6f9c85
commit 6b93e87363
14 changed files with 13140 additions and 482 deletions

View File

@@ -10,14 +10,14 @@ concrete AdjectiveGla of Adjective = CatGla ** open ResGla, Prelude in {
} ;
-- : A -> AP ;
PositA a = a ** {
compar = [] ;
} ;
--PositA a = a ** {
-- compar = [] ;
-- } ;
-- : A -> NP -> AP ;
ComparA a np = a ** {
compar = np.s
} ;
--ComparA a np = a ** {
-- compar = np.s
-- } ;
-- : A2 -> NP -> AP ; -- married to her
-- ComplA2 a2 np = a2 ** { } ;
@@ -26,7 +26,7 @@ concrete AdjectiveGla of Adjective = CatGla ** open ResGla, Prelude in {
-- ReflA2 a2 = a2 ** { } ;
-- : A2 -> AP ; -- married
UseA2 = PositA ;
-- UseA2 = PositA ;
-- : A -> AP ; -- warmer
-- UseComparA a = a ** {

View File

@@ -15,13 +15,13 @@ lin
PrepNP prep np = {
s = prepAndArt ++ noun
} where {
defaultCase : CoreCase = prep.c2 ! getDefi np.a ;
defaultCase : Case = prep.c2 ! getDefi np.a ;
complCase : Case = case <defaultCase, np.a> of {
<Dat NoMutation, NotPron (DPoss _ (Sg1|Sg2|Sg3 Masc))>
=> CC (Dat Lenited) ; -- force lenition if possessive triggers it
=> Dat Lenited ; -- force lenition if possessive triggers it
<Nom NoMutation, NotPron (DPoss _ (Sg1|Sg2|Sg3 Masc))>
=> CC (Nom Lenited) ; -- force lenition if possessive triggers it
_ => CC defaultCase } ;
=> Nom Lenited ; -- force lenition if possessive triggers it
_ => defaultCase } ;
prepStr : Str = prep.s ! agr2pagr np.a ; -- can be Prep or Prep+Pron merged
artStr : Str = np.art ! complCase ;
prepAndArt : Str = case np.a of {

View File

@@ -1,6 +1,6 @@
--# -path=.:../abstract:../common:../prelude
concrete AllGla of AllGlaAbs =
LangGla,
ExtendGla
LangGla -- ,
-- ExtendGla
;

View File

@@ -49,7 +49,7 @@ concrete CatGla of Cat = CommonX ** open ResGla, Coordination, Prelude in {
-- Many atomic noun phrases e.g. "everybody"
-- are constructed in StructuralGla.
CN = ResGla.LinCN ;
CN = ResGla.LinN ;
NP = ResGla.LinNP ;
Pron = LinPron ;
Det = ResGla.LinDet ; -- s : Str , n : Number
@@ -93,17 +93,17 @@ concrete CatGla of Cat = CommonX ** open ResGla, Coordination, Prelude in {
V = ResGla.LinV ;
VV -- verb-phrase-complement verb e.g. "want"
= SS ;
= ResGla.LinV ;
V2A, -- verb with NP and AP complement e.g. "paint"
V2V, -- verb with NP and V complement e.g. "cause"
V2S, -- verb with NP and S complement e.g. "tell"
V2Q, -- verb with NP and Q complement e.g. "ask"
V2 = SS ;
V3 = SS ;
V2 = LinV ** {c2 : LinPrep} ;
V3 = LinV ** {c2,c3 : LinPrep} ;
A = SS ;
A2 = SS ;
A = LinA ;
A2 = LinA ** {c2 : LinPrep} ;
N = ResGla.LinN ;
N2 = ResGla.LinN ;
@@ -116,6 +116,7 @@ concrete CatGla of Cat = CommonX ** open ResGla, Coordination, Prelude in {
LN = SS ; -- Location name, e.g. "Sweden"
linref
NP = linNP ;
Cl = linCl ;
}

View File

@@ -0,0 +1,77 @@
concrete DocumentationGla of Documentation = CatGla ** open
ResGla, Prelude, HTML in {
lincat
Inflection = {t : Str; s1,s2,s3 : Str} ;
Definition = {s : Str} ;
Document = {s : Str} ;
Tag = {s : Str} ;
lin
InflectionN,InflectionN2,InflectionN3 = \x -> {
t="n" ;
s1=heading1 ("Noun"++
case x.g of {
Masc => "(masculine)" ;
Fem => "(feminine)"
}) ;
s2=frameTable (
tr (th "" ++ th "Sg" ++ th "Pl") ++
tr (intagAttr "th" "colspan=\"3\"" "indefinite") ++
tr (th "nom" ++ td (x.s ! Nom NoMutation ! Indef ! Sg) ++ td (x.s ! Nom NoMutation ! Indef ! Pl)) ++
tr (th "dat" ++ td (x.s ! Dat NoMutation ! Indef ! Sg) ++ td (x.s ! Dat NoMutation ! Indef ! Pl)) ++
tr (th "gen" ++ td (x.s ! Gen ! Indef ! Sg) ++ td (x.s ! Gen ! Indef ! Pl)) ++
tr (intagAttr "th" "colspan=\"3\"" "definite") ++
tr (th "nom" ++ td (x.s ! Nom NoMutation ! Def ! Sg) ++ td (x.s ! Nom NoMutation ! Def ! Pl)) ++
tr (th "dat" ++ td (x.s ! Dat NoMutation ! Def ! Sg) ++ td (x.s ! Dat NoMutation ! Def ! Pl)) ++
tr (th "gen" ++ td (x.s ! Gen ! Def ! Sg) ++ td (x.s ! Gen ! Def ! Pl)) ++
tr (th "voc" ++ td (x.voc ! Sg) ++ td (x.voc ! Pl))) ;
s3=[]
} ;
lin
InflectionV,InflectionV2,InflectionV2A,InflectionV2Q,InflectionV2S,InflectionV2V,InflectionV3,InflectionVA,InflectionVQ,InflectionVS,InflectionVV = \x -> {
t="v" ;
s1=heading1 "Verb" ;
s2=frameTable (
tr (th "s" ++ td (x.s)) ++
tr (intagAttr "th" "rowspan=\"2\"" "Conditional" ++ th "Sg" ++ td (x.conditional ! Sg)) ++
tr (th "Pl" ++ td (x.conditional ! Pl)) ++
tr (intagAttr "th" "rowspan=\"6\"" "Imperative" ++ intagAttr "th" "rowspan=\"2\"" "P1" ++ th "Sg" ++ td (x.imperative ! P1 ! Sg)) ++
tr (th "Pl" ++ td (x.imperative ! P1 ! Pl)) ++
tr (intagAttr "th" "rowspan=\"2\"" "P2" ++ th "Sg" ++ td (x.imperative ! P2 ! Sg)) ++
tr (th "Pl" ++ td (x.imperative ! P2 ! Pl)) ++
tr (intagAttr "th" "rowspan=\"2\"" "P3" ++ th "Sg" ++ td (x.imperative ! P3 ! Sg)) ++
tr (th "Pl" ++ td (x.imperative ! P3 ! Pl)) ++
tr (intagAttr "th" "rowspan=\"4\"" "Indicative" ++ th "Fut" ++ td (x.future ! Indep)) ++
tr (th "Past" ++ td (x.past ! Indep)) ++
tr (th "Participle" ++ td (x.participle))) ;
s3=[]
} ;
lin
InflectionA,InflectionA2 = \x -> {
t="a" ;
s1=heading1 "Adjective" ;
s2=frameTable (
tr (intagAttr "th" "rowspan=\"2\"" "" ++
th "masculine" ++ th "feminine") ++
tr (intagAttr "th" "colspan=\"2\"" "singular") ++
tr (th "Nom" ++ td (x.s ! ASg (Nom NoMutation) Masc) ++ td (x.s ! ASg (Nom NoMutation) Fem)) ++
tr (th "Dat" ++ td (x.s ! ASg (Dat NoMutation) Masc) ++ td (x.s ! ASg (Dat NoMutation) Fem)) ++
tr (th "Gen" ++ td (x.s ! ASg Gen Masc) ++ td (x.s ! ASg Gen Fem)) ++
tr (th "Voc" ++ td (x.voc ! Masc) ++ td (x.voc ! Fem)) ++
tr (intagAttr "th" "rowspan=\"2\"" "" ++ intagAttr "th" "colspan=\"2\"" "plural") ++
tr ( intagAttr "td" "colspan=\"2\"" (x.s ! APl))) ++
heading2 "Comparative" ++
paragraph (x.compar) ;
s3=[]
} ;
lin
NoDefinition t = {s=t.s};
MkDefinition t d = {s="<p><b>Definition:</b>"++t.s++d.s++"</p>"};
MkDefinitionEx t d e = {s="<p><b>Definition:</b>"++t.s++d.s++"</p><p><b>Example:</b>"++e.s++"</p>"};
lin
MkDocument d i e = {s = i.s1 ++ d.s ++ i.s2 ++ i.s3 ++ e.s} ;
MkTag i = {s = i.t} ;
}

View File

@@ -31,5 +31,6 @@ concrete ExtendGla of Extend = CatGla
, UseComp_ser, UseComp_estar
, iFem_Pron, weFem_Pron, youFem_Pron, youPlFem_Pron, youPolFem_Pron, youPolPlFem_Pron, youPolPl_Pron, theyFem_Pron, theyNeutr_Pron
, GenModNP
, PiedPipingQuestSlash, PiedPipingRelSlash, SubjunctRelCN
] with (Grammar=GrammarGla) ;

View File

@@ -1,5 +1,6 @@
--# -path=.:../abstract:../common:../prelude:../api
concrete LangGla of Lang =
GrammarGla,
LexiconGla,
ConstructionGla ;
LexiconGla
,DocumentationGla --# notpresent
;

View File

@@ -31,7 +31,7 @@ lin beg_V2V = mkV2V (mkV "") ;
lin belly_N = mkN "" ;
lin big_A = mkA "" ;
lin bike_N = mkN "" ;-}
lin bird_N = smartN "eun" "eòin" "eòin" Masc ;{-
lin bird_N = mkN "eun" "eòin" "eòin" Masc ;{-
lin bite_V2 = mkV2 "" ;
lin black_A = mkA "" ;
lin blood_N = mkN "" ;
@@ -86,9 +86,9 @@ lin cut_V2 = mkV2 "" ;
----
-- D
lin day_N = mkN "" ; -}
lin day_N = mkN "" ;
lin die_V = mkV "die" ;
{-lin dig_V = mkV "" ;
lin dig_V = mkV "" ;
lin dirty_A = mkA "" ;
lin distance_N3 = mkN3 (mkN "") ;
lin do_V2 = mkV2 "" ;
@@ -161,7 +161,7 @@ lin green_A = mkA "" ;
-- H
lin hair_N = mkN "" ;-}
lin hand_N = smartN "làmh" Fem ;{-
lin hand_N = mkN "làmh" Fem ;{-
lin harbour_N = mkN "" ;
lin hat_N = mkN "" ;
lin hate_V2 = mkV2 "" ;
@@ -199,7 +199,7 @@ lin know_VS = mkV "" ;
----
-- L
lin lake_N = smartN "loch" "locha" "lochan" Masc ;
lin lake_N = mkN "loch" "locha" "lochan" Masc ;
{-
lin lamp_N = mkN "" ;
lin language_N = mkN "" ;
@@ -223,7 +223,7 @@ lin love_V2 = mkV2 "" ;
----
-- M
-}lin man_N = smartN "fear" Masc ;{-
-}lin man_N = mkN "fear" Masc ;{-
lin married_A2 = mkA2 (mkA "") ;
lin meat_N = mkN "" ;
lin milk_N = mkN "" ;
@@ -408,7 +408,7 @@ lin window_N = mkN "" ;
lin wine_N = mkN "" ;
lin wing_N = mkN "" ;
lin wipe_V2 = mkV2 "" ;-}
lin woman_N = smartN "boireannach" Masc ;{-
lin woman_N = mkN "boireannach" Masc ;{-
lin wonder_VQ = mkVQ (mkV "") ;
lin wood_N = mkN "" ;
lin worm_N = mkN "" ;

10648
src/gaelic/MorphoGla.gf Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,10 @@ concrete NounGla of Noun = CatGla ** open ResGla, Prelude in {
-- : Det -> CN -> NP
DetCN det cn = emptyNP ** {
art = det.s ! cn.g ;
s = \\c => cn.s ! getNForm det.dt c ;
s = \\c => case det.dt of {
DDef n sp => cn.s ! c ! sp ! n ;
DPoss n _ => cn.s ! c ! Def ! n -- ????????????????
} ;
a = NotPron det.dt ;
} ;
@@ -20,7 +23,7 @@ concrete NounGla of Noun = CatGla ** open ResGla, Prelude in {
-- : Pron -> NP ;
-- Assuming that lincat Pron = lincat NP
UsePron pron = emptyNP ** pron ** {
s = \\c => pron.s ! npc2cc c ;
s = pron.s ;
a = IsPron pron.a
} ;
{-
@@ -58,7 +61,7 @@ concrete NounGla of Noun = CatGla ** open ResGla, Prelude in {
-}
-- MassNP : CN -> NP ;
MassNP cn = emptyNP ** {
s = \\c => cn.s ! getNForm (DDef Sg Indefinite) c -- no article, singular indefinite forms, open for cases+mutations
s = \\c => cn.s ! c ! Indef ! Sg -- no article, singular indefinite forms, open for cases+mutations
} ;
@@ -132,16 +135,23 @@ concrete NounGla of Noun = CatGla ** open ResGla, Prelude in {
DefArt = ResGla.defArt ;
-- : Quant
IndefArt = mkQuant [] (QDef Indefinite) ;
IndefArt = {
s = \\_ => [] ;
sp = [] ;
qt = QDef Indef ;
} ;
-- : Pron -> Quant -- my
PossPron pron = mkQuant pron.poss (QPoss pron.a) ;
PossPron pron = {
s = \\_ => pron.poss ;
sp = pron.poss ;
qt = QPoss pron.a ;
} ;
--2 Common nouns
-- : N -> CN
UseN = useN ;
UseN n = n ;
{-
-- : N2 -> CN ;

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,7 @@ concrete PhraseGla of Phrase = CatGla ** open Prelude, ResGla in {
PhrUtt pconj utt voc = {s = pconj.s ++ utt.s ++ voc.s} ;
UttS s = s ;
{-
UttQS qs = qs ;
UttIAdv iadv = iadv ;
@@ -16,8 +17,8 @@ concrete PhraseGla of Phrase = CatGla ** open Prelude, ResGla in {
UttAP ap = { s = ap.s } ;
UttAdv adv = {s = } ;
UttCN n = {s = } ;
UttCard n = {s = } ;
UttInterj i = i ; -}
UttCard n = {s = } ; -}
UttInterj i = i ;
NoPConj = {s = []} ;
-- PConjConj conj = {s = conj.s1 ++ conj.s2 ! …} ;

View File

@@ -1,5 +1,6 @@
resource ResGla = open Prelude, Predef in {
--------------------------------------------------------------------------------
-- General notes
@@ -29,82 +30,65 @@ https://inariksit.github.io/gf/2018/08/28/gf-gotchas.html#my-naming-scheme-for-l
param
Gender = Masc | Fem ;
CoreCase = Nom Mutation | Gen | Dat Mutation ;
Case = CC CoreCase | Voc ;
-- NPCase = NPC CoreCase | NPVoc ;
Case = Nom Mutation | Dat Mutation | Gen ;
Mutation = Lenited | NoMutation ;
Number = Sg
| Pl
;
Person = P1 | P2 | P3 ;
Definiteness = Definite | Indefinite ; -- Some prepositions govern different case when definite vs. indefinite
Species = Indef | Def ; -- Some prepositions govern different case when definite vs. indefinite
oper
NOM : CoreCase = Nom NoMutation ; -- shorthand
npc2cc : Case -> CoreCase = \npc -> case npc of {
CC c => c ;
_ => NOM
} ;
param
NForm =
Indef Number CoreCase
| Def Number Case
| Dual -- only after number 2, only for a handful of nouns. TODO: does it have different cases?
;
NOM : Case = Nom NoMutation ; -- shorthand
oper
getNForm : DType -> Case -> NForm = \d,c ->
case <d,c> of {
<DDef n Indefinite,Voc> => Def n Voc ;
<DDef n Indefinite,CC c> => Indef n c ;
<DDef n Definite,c> => Def n c ;
<DPoss n _,Voc> => Indef n NOM ; -- as per Michal on Discord https://discord.com/channels/865093807343140874/865094084683366400/1409838154550087711 . TODO: Def or Indef nom ????
<DPoss n _,c> => Def n c -- ????????????????
} ;
LinN : Type = {s: Case => Species => Number => Str; voc: Number => Str; g: Gender} ;
LinN : Type = {
base, -- tunnag fuil loch fear litir bròg
dat, -- -"- bròig (1B)
gen, -- tunnaige fala locha fir litreach ("de-palatalised") bròige
pl, -- tunnagan lochan fir litrichean brògan
-- pldat, -- Krasimir's and Katya's automatic extraction suggests there's a difference, but I don't see it
-- add this form if we turn out to need it
-- TODO: for nouns that only use suffixes, should these just show theoretical forms?
lenited, -- thunnag fhuil loch fhear
palatalised, -- tunnaig fuil loch fir
lenited_palatalised, -- thunnaig fhuil loch fhir
lenited_plural
: Str ;
g : Gender
} ;
mk5N : (nom,gen,dat,pl : Str) -> Gender -> LinN = \brog,broige,broig,brogan,g -> {
base = brog ;
gen = broige ;
dat = broig ;
pl = brogan ;
lenited_plural = lenite brogan ;
lenited = bhrog ;
palatalised = broig ;
lenited_palatalised = bhroig ;
g = g
} where {
bhrog : Str = lenite brog ;
bhroig : Str = lenite broig } ;
smartN = overload {
smartN : (nom,gen,pl : Str) -> Gender -> LinN = \loch,locha,lochan,g ->
mk5N loch locha loch lochan g ;
smartN : (base : Str) -> Gender -> LinN = \tunnag,g ->
let fm : Str -> Str -> Str = \fem,masc -> case g of {
Fem => fem ; Masc => masc } ;
tunnaig : Str = palatalise tunnag ;
tunnaige : Str = fm (tunnaig + "e") tunnaig ;
tunnagan : Str = fm (tunnag + "an") tunnaig ;
in mk5N tunnag tunnaige tunnag tunnagan g
} ;
mk5N nom dat gen pl pal g =
{ s = table {
Nom _ => table {
Indef => table {
Sg => nom ;
Pl => pl
} ;
Def => table {
Sg => nom ;
Pl => fm pl pal
}
} ;
Dat _ => table {
Indef => table {
Sg => dat ;
Pl => pl
} ;
Def => table {
Sg => fm pal (lenite nom) ;
Pl => pl
}
} ;
Gen => table {
Indef => table {
Sg => gen ;
Pl => lenite nom
} ;
Def => table {
Sg => fm pal (lenite pal) ;
Pl => nom
}
}
} ;
voc = table {
Sg => fm (lenite nom) (lenite pal) ;
Pl => lenite nom+"a"
} ;
g = g
}
where {
fm : Str -> Str -> Str = \fem,masc -> case g of {
Fem => fem ;
Masc => masc
}
};
vowel : pattern Str = #("a"|"à"|"e"|"i"|"ì"|"o"|"u") ; -- more accents?
diphthong : pattern Str = #("ea"|"oi") ;
@@ -112,12 +96,8 @@ oper
labial : pattern Str = #("b"|"f"|"m"|"p") ;
palatalise : Str -> Str = \lamh -> case lamh of {
f@? + "ea" + r => f + "i" + r ; -- TODO is this irregular?
boireann@(_ + (#vowel|#diphthong) + ? + _ + (#vowel|#diphthong) + ? + _)
+ a@#vowel + ch => boireann + a + "i" + ch ;
tunn@(_ + (#vowel|#diphthong) + ? + _)
+ a@#vowel + g => tunn + a + "i" + g ;
l + a@#vowel + mh => l + a + "i" + mh ;
gr+"ea"+nn@("c"|"d"|"l"|"n"|"p"|"r"|"s"|"m"|"ch"|"dh"|"ll"|"mh"|"nn"|"sg") => gr+"i"+nn ;
boireann + a@#vowel + ch@("b"|"c"|"d"|"g"|"l"|"p"|"r"|"s"|"t"|"m"|"n"|"bh"|"ch"|"cs"|"dh"|"gh"|"ll"|"lm"|"lt"|"mh"|"nc"|"ng"|"nn"|"nt"|"nnd"|"rc"|"rd"|"rm"|"rn"|"rs"|"rt"|"sg"|"th"|"ths"|"rbh") => boireann + a + "i" + ch ;
_ => lamh } ;
lenite : Str -> Str = \tunnag -> case tunnag of {
@@ -127,88 +107,6 @@ oper
_ => tunnag } ;
-- For inflection paradigms, see http://www.grammaticalframework.org/doc/tutorial/gf-tutorial.html#toc56
mkNoun : (b,g,d,pl,l,p,lp,lpl : Str) -> Gender -> LinN = \b,gen,dat,pl,l,p,lp,lpl,g -> {
base = b ; -- tunnag fuil loch fear litir
gen = gen ; -- tunnaige fala locha fir litreach
dat = dat ; -- tunnaige fala locha fir litreach
pl = pl ; -- tunnagan lochan fir litrichean
lenited = l ; -- thunnag fhuil loch fhear litir ?
palatalised = p ; -- tunnaig fuil loch fir litir ?
lenited_palatalised = lp ; -- thunnaig fhuil loch fhir litir ?
lenited_plural = lpl ; -- thunnagan lochan fhir litrichean ?
g = g ;
} ;
-- TODO: no idea if this is even remotely correct
-- can always replace morphology with Katya's automated tool
useN : LinN -> LinCN = \n -> n ** {
s = table {
Indef Sg (Nom NoMutation) => n.base ;
Indef Sg (Nom Lenited) => n.lenited ;
Indef Sg Gen => n.gen ;
Indef Sg (Dat NoMutation) => n.dat ;
Indef Sg (Dat Lenited) => fm n.lenited_palatalised n.lenited ; ------- FIXME later
Def Sg (CC (Nom NoMutation)) => n.base ;
Def Sg (CC (Nom Lenited)) => n.lenited ;
Def Sg (CC Gen) => fm n.gen n.lenited_palatalised ;
Def Sg (CC (Dat NoMutation)) => fm n.palatalised n.lenited ;
Def Sg (CC (Dat Lenited)) => fm n.lenited_palatalised n.lenited ;
Def Sg Voc => fm n.lenited n.lenited_palatalised ;
Indef Pl (Nom NoMutation) => fm n.pl n.palatalised ;
Indef Pl (Nom Lenited) => fm n.lenited_plural n.lenited_palatalised ;
Indef Pl Gen => n.lenited ;
Indef Pl (Dat NoMutation) => fm n.pl n.palatalised ; -- TODO: is this overfitting based on the 5 nouns i know? probably!
Indef Pl (Dat Lenited) => fm n.lenited_plural n.lenited_palatalised ; -- TODO: see above
Def Pl (CC (Nom NoMutation)) => n.pl ;
Def Pl (CC (Nom Lenited)) => n.lenited_plural ;
Def Pl (CC Gen) => n.base ;
Def Pl (CC (Dat NoMutation)) => n.pl ;
Def Pl (CC (Dat Lenited)) => n.lenited_plural ;
Def Pl Voc => glue n.lenited "a" ;
Dual => fm n.palatalised n.base -- TODO: is this correct? only for 1-syllable feminine nouns?
}
} where {
fm : Str -> Str -> Str = \fem,masc -> case n.g of {
Fem => fem ;
Masc => masc
}
};
LinCN : Type = {
s : NForm =>
Str ;
g : Gender ;
-- ** postmod/premod/… : Str -- if needed? determiners can put stuff after head but it only comes at NP
} ;
linCN : LinCN -> Str = \cn -> cn.s ! Indef Sg NOM
-- ++ cn.postmod -- If there is another field, use here
;
-- some test nouns — TODO: do smart paradigms
tunnag_N : LinN = {
base,dat = "tunnag" ;
gen = "tunnaige" ;
pl = "tunnagan" ;
lenited_plural = "thunnagan" ;
lenited = "thunnag" ;
palatalised = "tunnaig" ;
lenited_palatalised = "thunnaig" ;
g = Fem ;
} ;
boireannach_N : LinN = {
base,dat = "boireannach" ;
pl,gen = "boireannaich" ;
lenited = "bhoireannach" ;
palatalised = "boireannaich" ;
lenited_palatalised,
lenited_plural = "bhoireannaich" ;
g = Masc ;
} ;
---------------------------------------------
-- Proper noun
@@ -243,24 +141,12 @@ oper
oper
LinPron : Type = {
s : CoreCase => Str ;
s : Case => Str ;
a : PronAgr ;
poss : Str ; -- if a case is needed, it comes from the Prep! TODO verify this (do we ever need a dative for poss pron without a prep present? some preps merge, others not, but the pronoun is present in all the preps. why this way—I counted on there being fewer pronouns than prepositions.)
empty : Str ; -- to prevent metavariables
} ;
-- TODO: nicer API where you can give Person, Number, Gender etc.
-- not this weird unintuitive Agr param
mkPron : (subj,poss : Str) -> PronAgr -> LinPron = \subj,poss,agr -> {
s = table {
Nom _ => subj ;
_ => "gam" -- TODO fix this
} ;
poss = poss ;
a = agr ;
empty = []
} ;
---------------------------------------------
-- NP
@@ -286,11 +172,11 @@ oper
a : Agr ; -- includes whether it's pron and whether it's definite. TODO: probably can make even leaner (wasn't a prio so far).
} ;
linNP : LinNP -> Str = \np -> np.art ! CC NOM ++ np.s ! CC NOM ;
linNP : LinNP -> Str = \np -> np.art ! NOM ++ np.s ! NOM ;
emptyNP : LinNP = {
s,art = \\_ => [] ;
a = NotPron (DDef Sg Indefinite) ; -- we assume pronouns are definite by default. also it just matters for PrepNP.
a = NotPron (DDef Sg Indef) ; -- we assume pronouns are definite by default. also it just matters for PrepNP.
empty = [] ;
} ;
@@ -298,9 +184,9 @@ oper
-- Det, Quant, Card, Ord
param
QuantForm = QSg Gender CoreCase | QPl CoreCase ;
QType = QDef Definiteness | QPoss PronAgr ;
DType = DDef Number Definiteness | DPoss Number PronAgr ;
QuantForm = QSg Gender Case | QPl Case ;
QType = QDef Species | QPoss PronAgr ;
DType = DDef Number Species | DPoss Number PronAgr ;
-- The minimum forms that preposition merges with
PrepAgr = PrepBase | PrepDefiniteArticle Number | PrepObjectPron PronAgr | PrepPossPron PronAgr ;
@@ -314,16 +200,12 @@ oper
} ;
getQuantForm : Number -> Gender -> Case -> QuantForm = \n,g,c -> case <n,c> of {
<Sg,CC c> => QSg g c ;
<Sg,_> => QSg g NOM ; --- ??????
<Pl,CC c> => QPl c ;
<Pl,_> => QPl NOM --- ??????
<Sg,c> => QSg g c ;
<Pl,c> => QPl c
} ;
getArt : LinQuant -> Number -> Gender -> Case -> Str = \quant,n,g,c -> case c of {
Voc => "" ; -- TODO: add empty field to article to not get metavariables
_ => quant.s ! getQuantForm n g c
} ;
getArt : LinQuant -> Number -> Gender -> Case -> Str = \quant,n,g,c ->
quant.s ! getQuantForm n g c ;
LinQuant : Type = {
s -- quantifier in a context, e.g. 'this (cat) (is nice)'
@@ -343,14 +225,7 @@ oper
n : Number ;
} ;
-- Can you reuse your mkNoun? Do nouns and quantifiers inflect the same way?
mkQuant : Str -> QType -> LinQuant = \this,qt -> {
s = \\_ => this ;
sp = this ;
qt = qt ;
} ;
mkDet : (seven, teen : Str) -> Definiteness -> Number -> LinDet = \aon, deug, defi, num -> {
mkDet : (seven, teen : Str) -> Species -> Number -> LinDet = \aon, deug, defi, num -> {
s = \\_,_ => aon ;
s2 = \\_,_ => deug ;
sp = aon ;
@@ -390,7 +265,7 @@ oper
QPl _ => NA
} ;
sp = "an" ; --- meaningless for DefArt
qt = QDef Definite ;
qt = QDef Def ;
} ;
--------------------------------------------------------------------------------
-- Adpositions
@@ -416,14 +291,14 @@ param
Agr = NotPron DType | IsPron PronAgr ;
oper
getDefi : Agr -> Definiteness = \a -> case a of {
getDefi : Agr -> Species = \a -> case a of {
NotPron (DDef n d) => d ;
_ => Definite
_ => Def
} ;
LinPrep : Type = {
s : PrepAgr => Str ; -- bare: aig 'on', inflected: agam 'on me', agad 'on you', …
c2 : Definiteness => CoreCase ; -- most often dative
c2 : Species => Case ; -- most often dative
replacesObjPron : Bool ; -- NP has to keep track of if it comes from a Pron
-- If your language has both pre- and postpositions, you need an inherent parameter in Prep to record which one a given Prep is.
@@ -434,18 +309,18 @@ oper
PrepForms : Type = {base, sg1, sg2, sg3M, sg3F, pl1, pl2, pl3 : Str} ;
H, N, LENITION_DEBUG : Str ;
H = pre {#vowel => "h" ++ BIND ; _ => []} ;
N = pre {#vowel => "n-" ++ BIND ; _ => []} ;
h, n, LENITION_DEBUG : Str ;
h = pre {#vowel => "h" ++ BIND ; _ => []} ;
n = pre {#vowel => "n-" ++ BIND ; _ => []} ;
LENITION_DEBUG = "^L" ; -- Only for debugging purposes—replace with empty string for production
invarPrepForms : Str -> PrepForms = \str ->
{base=str ; sg1=str++"mo" + LENITION_DEBUG; sg2=str++"do" + LENITION_DEBUG; sg3M=str++"a" + LENITION_DEBUG;
sg3F=str++"a"++H; pl1=str++"àr"++N; pl2=str++"ùr"++N; pl3=str++AN} ; -- AN is defined as an allomorph to def art, TODO does the possessive add t- before vowel?
sg3F=str++"a"++h; pl1=str++"àr"++n; pl2=str++"ùr"++n; pl3=str++AN} ; -- AN is defined as an allomorph to def art, TODO does the possessive add t- before vowel?
mkLinPrep : (replacesObjPron : Bool)
-> (indef,defi : CoreCase)
-> (indef,defi : Case)
-> (objForms, possForms : PrepForms)
-> LinPrep =
\replaces,casIndef,casDef,objForms,possForms -> {
@@ -485,13 +360,12 @@ oper
mkPrep : (objForms, possForms : PrepForms) -> LinPrep = smartPrep ;
mkPrep : (objForms, possForms : PrepForms) -> Mutation -> LinPrep =
\obj,poss,mutation -> mkLinPrep True (Dat mutation) (Dat mutation) obj poss ;
mkPrep : (replacesObjPron : Bool) -> (indef,defi : CoreCase)
mkPrep : (replacesObjPron : Bool) -> (indef,defi : Case)
-> (objForms, possForms : PrepForms) -> LinPrep = mkLinPrep
} ;
emptyPrep : LinPrep = {
s = \\_ => [] ;
poss = \\_ => [] ;
c2 = \\_ => Dat Lenited ;
replacesObjPron = False
} ;
@@ -499,7 +373,7 @@ oper
aigPrep : LinPrep =
mkPrep
{base="aig"; sg1="agam"; sg2="agad"; sg3M="aige"; sg3F="aice"; pl1="againn"; pl2="agaibh"; pl3="aca"}
{base="aig"; sg1="'gam" + LENITION_DEBUG; sg2="'gad" + LENITION_DEBUG; sg3M="'ga" + LENITION_DEBUG; sg3F="'ga"++H; pl1="'gar"++N; pl2="'gur"++N; pl3="'gan"}
{base="aig"; sg1="'gam" + LENITION_DEBUG; sg2="'gad" + LENITION_DEBUG; sg3M="'ga" + LENITION_DEBUG; sg3F="'ga"++h; pl1="'gar"++n; pl2="'gur"++n; pl3="'gan"}
NoMutation ;
airPrep : LinPrep =
@@ -511,7 +385,7 @@ oper
annPrep : LinPrep =
mkPrep
{base="ann"; sg1="annam"; sg2="annad"; sg3M="ann"; sg3F="innte"; pl1="annainn"; pl2="annaibh"; pl3="annta"}
{base="ann"; sg1="'nam" + LENITION_DEBUG; sg2="'nad" + LENITION_DEBUG; sg3M="'na" + LENITION_DEBUG; sg3F="'na"++H; pl1="'nar"++N; pl2="'nur"++N; pl3="'nan"}
{base="ann"; sg1="'nam" + LENITION_DEBUG; sg2="'nad" + LENITION_DEBUG; sg3M="'na" + LENITION_DEBUG; sg3F="'na"++h; pl1="'nar"++n; pl2="'nur"++n; pl3="'nan"}
NoMutation ;
àsPrep : LinPrep =
@@ -523,14 +397,14 @@ oper
bhoPrep : LinPrep =
mkPrep
{base="bho"; sg1="bhuam"; sg2="bhuat"; sg3M="bhuaithe"; sg3F="bhuaipe"; pl1="bhuainn"; pl2="buaibh"; pl3="bhuapa"}
{base="bho"; sg1="bhom" + LENITION_DEBUG; sg2="bhod" + LENITION_DEBUG; sg3M="bho a" + LENITION_DEBUG; sg3F="bho a"++H; pl1="bhor"++N; pl2="bhu"++N; pl3="bhon"}
{base="bho"; sg1="bhom" + LENITION_DEBUG; sg2="bhod" + LENITION_DEBUG; sg3M="bho a" + LENITION_DEBUG; sg3F="bho a"++h; pl1="bhor"++n; pl2="bhu"++n; pl3="bhon"}
Lenited ;
{- dePrep : LinPrep = …-}
doPrep : LinPrep =
mkPrep
{base="do"; sg1="dhomh"; sg2="dhut"; sg3M="dha"; sg3F="dhi"; pl1="dhuinn"; pl2="dhuibh"; pl3="dhiubh"}
{base="bho"; sg1="dom" + LENITION_DEBUG; sg2="dod" + LENITION_DEBUG; sg3M="dha" + LENITION_DEBUG; sg3F="dha"++H; pl1="dor"++N; pl2="dhur"++N; pl3="don"}
{base="bho"; sg1="dom" + LENITION_DEBUG; sg2="dod" + LENITION_DEBUG; sg3M="dha" + LENITION_DEBUG; sg3F="dha"++h; pl1="dor"++n; pl2="dhur"++n; pl3="don"}
Lenited ;
{- eadarPrep : LinPrep = …-}
@@ -541,7 +415,7 @@ oper
(Dat NoMutation) {-governs dative when indefinite, no mutation-}
Gen {-governs genitive when definite-}
{base="gu"; sg1="ugam"; sg2="ugad"; sg3M="uige"; sg3F="uice"; pl1="ugainn"; pl2="ugaibh"; pl3="uca"}
{base="gu"; sg1="gum" + LENITION_DEBUG; sg2="gud" + LENITION_DEBUG; sg3M="gu a" + LENITION_DEBUG; sg3F="gu a"++H; pl1="gar"++N; pl2="gur"++N; pl3="gun"}
{base="gu"; sg1="gum" + LENITION_DEBUG; sg2="gud" + LENITION_DEBUG; sg3M="gu a" + LENITION_DEBUG; sg3F="gu a"++h; pl1="gar"++n; pl2="gur"++n; pl3="gun"}
;
--------------------------------------------------------------------------------
@@ -549,68 +423,89 @@ oper
-- Lamb p. 220 basic morphology, degree
-- Lamb p. 246: predicative adjectives
LinA : Type = SS ;
param
AForm = ASg Case Gender | APl ;
oper
LinA : Type = {s: AForm => Str; voc: Gender => Str; compar: Str} ; -- 686
oper mkAdj : (_,_,_,_,_,_,_,_,_,_ : Str) -> LinA =
\f1,f2,f3,f4,f5,f6,f7,f8,f9,f10 ->
{ s = table {
ASg (Nom _) Masc => f1 ;
ASg (Nom _) Fem => f2 ;
ASg (Dat _) Masc => f3 ;
ASg (Dat _) Fem => f4 ;
ASg Gen Masc => f5 ;
ASg Gen Fem => f6 ;
APl => f7
} ;
voc = table {
Masc => f8 ;
Fem => f9
} ;
compar = f10 ;
} ;
LinA2 : Type = LinA ;
mkAdj : Str -> LinA = \str -> {s = str} ;
AdjPhrase : Type = LinA ; -- ** {compar : Str} ;
LinAP : Type = LinA ; -- ** {compar : Str} ;
--------------------------------------------------------------------------------
-- Verbs
param
VAgr = VSg1 | VSg2 | VSg3 | VPl1 | VPl2 | VPl3 ;
VForm = VInf | VPres VAgr | VPast VAgr ; -- TODO
VForm = Indep | Dep ;
oper
nagr2vagr : Agr -> VAgr = \a -> case a of {
NotPron (DDef Sg _) => VSg3 ;
NotPron (DDef Pl _) => VPl3 ;
-- this is the number of the possessee—number of possessor only matters for PrepNP!
NotPron (DPoss Sg _) => VSg3 ;
NotPron (DPoss Pl _) => VPl3 ;
-- this is subject pronoun, which agrees with verb
IsPron Sg1 => VSg1 ;
IsPron Sg2 => VSg2 ;
IsPron (Sg3 _) => VSg3 ;
IsPron Pl1 => VPl1 ;
IsPron Pl2 => VPl2 ;
IsPron Pl3 => VPl3
} ;
LinV : Type = {
s : VForm => Str
} ;
LinV = {s: Str; conditional: Number => Str; imperative: Person => Number => Str; future, past : VForm => Str; noun, participle: Str} ;
LinV2 : Type = LinV ** {
c2 : LinPrep ;
} ;
mkVerb : Str -> LinV = \str -> {
s = table {
_ => str
}
} ;
copula : LinV = {s = \\_ => "TODO: copula"} ; -- often useful
mkVerb : (_,_,_,_,_,_,_,_,_,_,_,_,_,_,_ : Str) -> LinV =
\f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15 ->
{ s = f1 ;
conditional = table {
Sg => f2 ;
Pl => f3
} ;
imperative = table {
P1 => table {
Sg => f4 ;
Pl => f5
} ;
P2 => table {
Sg => f6 ;
Pl => f7
} ;
P3 => table {
Sg => f8 ;
Pl => f9
}
} ;
future = table {
Indep => f10 ;
Dep => f11
} ;
past = table {
Indep => f12 ;
Dep => f13
} ;
noun = f14 ;
participle = f15
} ;
------------------
-- VP
-- Lamb p. 229
-- "tense, aspect, modality, voice, person and number. There are contrasts to be seen, as above, between inflected and periphrastic forms and, as a whole, periphrasis is more productive."
LinVP : Type = {
s : VForm => Str ;
} ;
LinVP : Type = LinV ;
LinVPSlash : Type = LinVP ** {
c2 : LinPrep ;
} ;
linVP : LinVP -> Str = \vp -> vp.s ! VInf ;
--------------------------------------------------------------------------------
-- Cl, S
@@ -622,4 +517,46 @@ oper
linCl : LinCl -> Str = \cl -> cl.subj ++ cl.pred ;
oper mkNoun : (_,_,_,_,_,_,_,_,_,_,_,_,_,_ : Str) -> Gender -> LinN =
\f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,g ->
{ s = table {
Nom _ => table {
Indef => table {
Sg => f1 ;
Pl => f2
} ;
Def => table {
Sg => f3 ;
Pl => f4
}
} ;
Dat _ => table {
Indef => table {
Sg => f5 ;
Pl => f6
} ;
Def => table {
Sg => f7 ;
Pl => f8
}
} ;
Gen => table {
Indef => table {
Sg => f9 ;
Pl => f10
} ;
Def => table {
Sg => f11 ;
Pl => f12
}
}
} ;
voc = table {
Sg => f13 ;
Pl => f14
} ;
g = g
} ;
}

View File

@@ -13,7 +13,7 @@ lin
subj = linNP np ; -- article and CN are discontinuous in NP! linNP just picks nominative unmutated.
pred =
-- table {something with tense+polarity =>
vp.s ! VPres (nagr2vagr np.a)
vp.s
-- TODO: all of the VP's tense and polarity should be open here!
-- PredVP only decides the subject.
-- }