mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-05-27 08:58:55 -06:00
Merge pull request #469 from lauma/latvian-new
New implementation of Latvian nouns form Tēzaurs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
--# -path=.:abstract:common:prelude
|
||||
|
||||
concrete CatLav of Cat = CommonX - [Adv, CAdv] ** open ResLav, Prelude in {
|
||||
concrete CatLav of Cat = CommonX - [Adv, CAdv, Voc] ** open ResLav, Prelude in {
|
||||
|
||||
flags
|
||||
|
||||
@@ -110,7 +110,18 @@ lincat
|
||||
|
||||
N3 = Noun ** {prep1, prep2 : Preposition ; isPre1, isPre2 : Bool} ;
|
||||
|
||||
PN,LN = ProperNoun ;
|
||||
-- TODO Make most proper nouns more similar to nouns:
|
||||
-- (1) given names GN should have both numbers (to fit with Tēzaurs and to be
|
||||
-- able to express that there are multiple people in the room with the
|
||||
-- same name)
|
||||
-- (2) family names SN being inflected on gender doesn't fit neither with
|
||||
-- Tēzaurs, nor with the fact that for some masc surnames there are
|
||||
-- multiple legaly valid fem variants
|
||||
-- (3) if PN is meant to be generic proper noun, it might also be inflected
|
||||
-- in number
|
||||
-- In general Latvian tends to make every noun inflectable in all cases/numbers,
|
||||
-- the plural-only placenames like "Cēsis" is the one very stable exception.
|
||||
PN,LN = ProperNoun ;
|
||||
GN = {s : Case => Str ; gend : Gender} ;
|
||||
SN = {s : Gender => Case => Str; pl : Case => Str} ;
|
||||
|
||||
|
||||
@@ -80,7 +80,8 @@ oper
|
||||
mkNounByDeclPal : Str -> Declension -> Bool -> Noun = \lemma,decl,pal ->
|
||||
case decl of {
|
||||
D0|D1|D2|D3 => mkNounByGendDeclPal lemma Masc decl pal ;
|
||||
D4|D5|D6|DR => mkNounByGendDeclPal lemma Fem decl pal
|
||||
D4|D5|D6|DR => mkNounByGendDeclPal lemma Fem decl pal ;
|
||||
DG => mkNounByGendDeclPal nonExist Fem decl pal -- FIX ME REMAKE
|
||||
} ;
|
||||
|
||||
-- Specified gender and declension; default palatalization
|
||||
@@ -97,7 +98,8 @@ oper
|
||||
D4 => mkNoun_D4 lemma gend ;
|
||||
D5 => mkNoun_D5 lemma gend pal ;
|
||||
D6 => mkNoun_D6 lemma gend pal ;
|
||||
DR => mkNoun_DR lemma
|
||||
DR => mkNoun_DR lemma ;
|
||||
DG => mkNoun_DR nonExist -- FIX ME REMAKE
|
||||
} ;
|
||||
|
||||
-- Indeclinable noun
|
||||
|
||||
@@ -43,13 +43,15 @@ oper
|
||||
mkRegVerb : Str -> Conjugation -> Verb_TMP = \lemma,conj ->
|
||||
case conj of {
|
||||
C2 => mkVerb_C2 lemma ;
|
||||
C3 => mkVerb_C3 lemma
|
||||
C3 => mkVerb_C3 lemma ;
|
||||
C1|CI => mkVerb_C3 nonExist -- FIX ME REMAKE
|
||||
} ;
|
||||
|
||||
mkReflVerb : Str -> Conjugation -> Verb_TMP = \lemma,conj ->
|
||||
case conj of {
|
||||
C2 => mkVerb_C2_Refl lemma ;
|
||||
C3 => mkVerb_C3_Refl lemma
|
||||
C3 => mkVerb_C3_Refl lemma ;
|
||||
C1|CI => mkVerb_C3_Refl nonExist -- FIX ME REMAKE
|
||||
} ;
|
||||
|
||||
filter_Neg : Verb_TMP -> Verb_TMP = \full -> {
|
||||
|
||||
574
src/latvian/PortedMorphoParadigmsLav.gf
Normal file
574
src/latvian/PortedMorphoParadigmsLav.gf
Normal file
@@ -0,0 +1,574 @@
|
||||
--# -path=.:abstract:common:prelude
|
||||
|
||||
-- Contents of this file are automatically ported paradigms from
|
||||
-- https://github.com/LUMII-AILab/Morphology/blob/master/src/main/resources/Lexicon_v2.xml
|
||||
-- NB: Do NOT edit this without consulting lauma@ailab.lv or normundsg@ailab.lv
|
||||
-- Otherwise your changes might get accidentally revoked!
|
||||
|
||||
resource PortedMorphoParadigmsLav = open PortedMorphoStemchangesLav, ResLav in {
|
||||
|
||||
flags coding = utf8 ;
|
||||
|
||||
oper
|
||||
|
||||
noun_1a_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "us" ;
|
||||
Dat => stem + "iem" ;
|
||||
Loc => stem + "os" ;
|
||||
Nom => stem + "i" ;
|
||||
Voc => stem + "i" ;
|
||||
Gen => stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "u" ;
|
||||
Dat => stem + "am" ;
|
||||
Loc => stem + "ā" ;
|
||||
Nom => stem + "s" ;
|
||||
Voc => variants { stem + "s" ; stem + "" } ;
|
||||
Gen => stem + "a"
|
||||
}
|
||||
} ;
|
||||
gend = Masc
|
||||
} ;
|
||||
|
||||
noun_1a_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "s" => noun_1a_fromStems stem ;
|
||||
_ => Predef.error ("noun_1a_fromLemma is only applicable for words that end in -s, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_1a_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "i" => noun_1a_fromStems stem ;
|
||||
_ => Predef.error ("noun_1a_fromNomPl is only applicable for words that end in -i, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_1b_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "us" ;
|
||||
Dat => stem + "iem" ;
|
||||
Loc => stem + "os" ;
|
||||
Nom => stem + "i" ;
|
||||
Voc => stem + "i" ;
|
||||
Gen => stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "u" ;
|
||||
Dat => stem + "am" ;
|
||||
Loc => stem + "ā" ;
|
||||
Nom => stem + "š" ;
|
||||
Voc => variants { stem + "š" ; stem + "" } ;
|
||||
Gen => stem + "a"
|
||||
}
|
||||
} ;
|
||||
gend = Masc
|
||||
} ;
|
||||
|
||||
noun_1b_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "š" => noun_1b_fromStems stem ;
|
||||
_ => Predef.error ("noun_1b_fromLemma is only applicable for words that end in -š, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_1b_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "i" => noun_1b_fromStems stem ;
|
||||
_ => Predef.error ("noun_1b_fromNomPl is only applicable for words that end in -i, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_2a_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stemchangeSimple 1 stem + "us" ;
|
||||
Dat => stemchangeSimple 1 stem + "iem" ;
|
||||
Loc => stemchangeSimple 1 stem + "os" ;
|
||||
Nom => stemchangeSimple 1 stem + "i" ;
|
||||
Voc => stemchangeSimple 1 stem + "i" ;
|
||||
Gen => stemchangeSimple 1 stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "i" ;
|
||||
Dat => stem + "im" ;
|
||||
Loc => stem + "ī" ;
|
||||
Nom => stem + "is" ;
|
||||
Voc => stem + "i" ;
|
||||
Gen => stemchangeSimple 1 stem + "a"
|
||||
}
|
||||
} ;
|
||||
gend = Masc
|
||||
} ;
|
||||
|
||||
noun_2a_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "is" => noun_2a_fromStems stem ;
|
||||
_ => Predef.error ("noun_2a_fromLemma is only applicable for words that end in -is, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_2a_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "i" => noun_2a_fromStems stem ;
|
||||
_ => Predef.error ("noun_2a_fromNomPl is only applicable for words that end in -i, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_2c_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stemchangeSimple 1 stem + "us" ;
|
||||
Dat => stemchangeSimple 1 stem + "iem" ;
|
||||
Loc => stemchangeSimple 1 stem + "os" ;
|
||||
Nom => stemchangeSimple 1 stem + "i" ;
|
||||
Voc => stemchangeSimple 1 stem + "i" ;
|
||||
Gen => stemchangeSimple 1 stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "i" ;
|
||||
Dat => stem + "im" ;
|
||||
Loc => stem + "ī" ;
|
||||
Nom => stem + "s" ;
|
||||
Voc => variants { stem + "" ; stem + "s" } ;
|
||||
Gen => stem + "s"
|
||||
}
|
||||
} ;
|
||||
gend = Masc
|
||||
} ;
|
||||
|
||||
noun_2c_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "s" => noun_2c_fromStems stem ;
|
||||
_ => Predef.error ("noun_2c_fromLemma is only applicable for words that end in -s, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_2c_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "i" => noun_2c_fromStems stem ;
|
||||
_ => Predef.error ("noun_2c_fromNomPl is only applicable for words that end in -i, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_2d_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stemchangeSimple 1 stem + "us" ;
|
||||
Dat => stemchangeSimple 1 stem + "iem" ;
|
||||
Loc => stemchangeSimple 1 stem + "os" ;
|
||||
Nom => stemchangeSimple 1 stem + "i" ;
|
||||
Voc => stemchangeSimple 1 stem + "i" ;
|
||||
Gen => stemchangeSimple 1 stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "i" ;
|
||||
Dat => stem + "im" ;
|
||||
Loc => stem + "ī" ;
|
||||
Nom => stem + "s" ;
|
||||
Voc => stem + "i" ;
|
||||
Gen => stemchangeSimple 1 stem + "a"
|
||||
}
|
||||
} ;
|
||||
gend = Masc
|
||||
} ;
|
||||
|
||||
noun_2d_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "s" => noun_2d_fromStems stem ;
|
||||
_ => Predef.error ("noun_2d_fromLemma is only applicable for words that end in -s, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_2d_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "i" => noun_2d_fromStems stem ;
|
||||
_ => Predef.error ("noun_2d_fromNomPl is only applicable for words that end in -i, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_3m_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "us" ;
|
||||
Dat => stem + "iem" ;
|
||||
Loc => stem + "os" ;
|
||||
Nom => stem + "i" ;
|
||||
Voc => stem + "i" ;
|
||||
Gen => stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "u" ;
|
||||
Dat => stem + "um" ;
|
||||
Loc => stem + "ū" ;
|
||||
Nom => stem + "us" ;
|
||||
Voc => variants { stem + "us" ; stem + "u" } ;
|
||||
Gen => stem + "us"
|
||||
}
|
||||
} ;
|
||||
gend = Masc
|
||||
} ;
|
||||
|
||||
noun_3m_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "us" => noun_3m_fromStems stem ;
|
||||
_ => Predef.error ("noun_3m_fromLemma is only applicable for words that end in -us, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_3m_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "i" => noun_3m_fromStems stem ;
|
||||
_ => Predef.error ("noun_3m_fromNomPl is only applicable for words that end in -i, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_4f_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "as" ;
|
||||
Dat => stem + "ām" ;
|
||||
Loc => stem + "ās" ;
|
||||
Nom => stem + "as" ;
|
||||
Voc => stem + "as" ;
|
||||
Gen => stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "u" ;
|
||||
Dat => stem + "ai" ;
|
||||
Loc => stem + "ā" ;
|
||||
Nom => stem + "a" ;
|
||||
Voc => variants { stem + "a" ; stemchangeSimple 17 stem + "" } ;
|
||||
Gen => stem + "as"
|
||||
}
|
||||
} ;
|
||||
gend = Fem
|
||||
} ;
|
||||
|
||||
noun_4f_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "a" => noun_4f_fromStems stem ;
|
||||
_ => Predef.error ("noun_4f_fromLemma is only applicable for words that end in -a, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_4f_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "as" => noun_4f_fromStems stem ;
|
||||
_ => Predef.error ("noun_4f_fromNomPl is only applicable for words that end in -as, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_4m_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "as" ;
|
||||
Dat => stem + "ām" ;
|
||||
Loc => stem + "ās" ;
|
||||
Nom => stem + "as" ;
|
||||
Voc => stem + "as" ;
|
||||
Gen => stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "u" ;
|
||||
Dat => stem + "am" ;
|
||||
Loc => stem + "ā" ;
|
||||
Nom => stem + "a" ;
|
||||
Voc => stem + "a" ;
|
||||
Gen => stem + "as"
|
||||
}
|
||||
} ;
|
||||
gend = Masc
|
||||
} ;
|
||||
|
||||
noun_4m_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "a" => noun_4m_fromStems stem ;
|
||||
_ => Predef.error ("noun_4m_fromLemma is only applicable for words that end in -a, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_4m_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "as" => noun_4m_fromStems stem ;
|
||||
_ => Predef.error ("noun_4m_fromNomPl is only applicable for words that end in -as, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_5fa_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "es" ;
|
||||
Dat => stem + "ēm" ;
|
||||
Loc => stem + "ēs" ;
|
||||
Nom => stem + "es" ;
|
||||
Voc => stem + "es" ;
|
||||
Gen => stemchangeSimple 1 stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "i" ;
|
||||
Dat => stem + "ei" ;
|
||||
Loc => stem + "ē" ;
|
||||
Nom => stem + "e" ;
|
||||
Voc => variants { stem + "e" ; stemchangeSimple 17 stem + "" } ;
|
||||
Gen => stem + "es"
|
||||
}
|
||||
} ;
|
||||
gend = Fem
|
||||
} ;
|
||||
|
||||
noun_5fa_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "e" => noun_5fa_fromStems stem ;
|
||||
_ => Predef.error ("noun_5fa_fromLemma is only applicable for words that end in -e, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_5fa_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "es" => noun_5fa_fromStems stem ;
|
||||
_ => Predef.error ("noun_5fa_fromNomPl is only applicable for words that end in -es, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_5ma_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "es" ;
|
||||
Dat => stem + "ēm" ;
|
||||
Loc => stem + "ēs" ;
|
||||
Nom => stem + "es" ;
|
||||
Voc => stem + "es" ;
|
||||
Gen => stemchangeSimple 1 stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "i" ;
|
||||
Dat => stem + "em" ;
|
||||
Loc => stem + "ē" ;
|
||||
Nom => stem + "e" ;
|
||||
Voc => stem + "e" ;
|
||||
Gen => stem + "es"
|
||||
}
|
||||
} ;
|
||||
gend = Masc
|
||||
} ;
|
||||
|
||||
noun_5ma_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "e" => noun_5ma_fromStems stem ;
|
||||
_ => Predef.error ("noun_5ma_fromLemma is only applicable for words that end in -e, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_5ma_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "es" => noun_5ma_fromStems stem ;
|
||||
_ => Predef.error ("noun_5ma_fromNomPl is only applicable for words that end in -es, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_6a_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "is" ;
|
||||
Dat => stem + "īm" ;
|
||||
Loc => stem + "īs" ;
|
||||
Nom => stem + "is" ;
|
||||
Voc => stem + "is" ;
|
||||
Gen => stemchangeSimple 1 stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "i" ;
|
||||
Dat => stem + "ij" ;
|
||||
Loc => stem + "ī" ;
|
||||
Nom => stem + "s" ;
|
||||
Voc => stem + "s" ;
|
||||
Gen => stem + "s"
|
||||
}
|
||||
} ;
|
||||
gend = Fem
|
||||
} ;
|
||||
|
||||
noun_6a_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "s" => noun_6a_fromStems stem ;
|
||||
_ => Predef.error ("noun_6a_fromLemma is only applicable for words that end in -s, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_6a_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "is" => noun_6a_fromStems stem ;
|
||||
_ => Predef.error ("noun_6a_fromNomPl is only applicable for words that end in -is, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_3f_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "us" ;
|
||||
Dat => stem + "ūm" ;
|
||||
Loc => stem + "ūs" ;
|
||||
Nom => stem + "us" ;
|
||||
Voc => stem + "us" ;
|
||||
Gen => stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "u" ;
|
||||
Dat => stem + "ui" ;
|
||||
Loc => stem + "ū" ;
|
||||
Nom => stem + "us" ;
|
||||
Voc => variants { stem + "us" ; stem + "u" } ;
|
||||
Gen => stem + "us"
|
||||
}
|
||||
} ;
|
||||
gend = Fem
|
||||
} ;
|
||||
|
||||
noun_3f_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "us" => noun_3f_fromStems stem ;
|
||||
_ => Predef.error ("noun_3f_fromLemma is only applicable for words that end in -us, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_3f_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "us" => noun_3f_fromStems stem ;
|
||||
_ => Predef.error ("noun_3f_fromNomPl is only applicable for words that end in -us, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_6b_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "is" ;
|
||||
Dat => stem + "īm" ;
|
||||
Loc => stem + "īs" ;
|
||||
Nom => stem + "is" ;
|
||||
Voc => stem + "is" ;
|
||||
Gen => stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "i" ;
|
||||
Dat => stem + "ij" ;
|
||||
Loc => stem + "ī" ;
|
||||
Nom => stem + "s" ;
|
||||
Voc => stem + "s" ;
|
||||
Gen => stem + "s"
|
||||
}
|
||||
} ;
|
||||
gend = Fem
|
||||
} ;
|
||||
|
||||
noun_6b_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "s" => noun_6b_fromStems stem ;
|
||||
_ => Predef.error ("noun_6b_fromLemma is only applicable for words that end in -s, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_6b_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "is" => noun_6b_fromStems stem ;
|
||||
_ => Predef.error ("noun_6b_fromNomPl is only applicable for words that end in -is, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_5fb_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "es" ;
|
||||
Dat => stem + "ēm" ;
|
||||
Loc => stem + "ēs" ;
|
||||
Nom => stem + "es" ;
|
||||
Voc => stem + "es" ;
|
||||
Gen => stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "i" ;
|
||||
Dat => stem + "ei" ;
|
||||
Loc => stem + "ē" ;
|
||||
Nom => stem + "e" ;
|
||||
Voc => variants { stem + "e" ; stemchangeSimple 17 stem + "" } ;
|
||||
Gen => stem + "es"
|
||||
}
|
||||
} ;
|
||||
gend = Fem
|
||||
} ;
|
||||
|
||||
noun_5fb_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "e" => noun_5fb_fromStems stem ;
|
||||
_ => Predef.error ("noun_5fb_fromLemma is only applicable for words that end in -e, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_5fb_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "es" => noun_5fb_fromStems stem ;
|
||||
_ => Predef.error ("noun_5fb_fromNomPl is only applicable for words that end in -es, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_5mb_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "es" ;
|
||||
Dat => stem + "ēm" ;
|
||||
Loc => stem + "ēs" ;
|
||||
Nom => stem + "es" ;
|
||||
Voc => stem + "es" ;
|
||||
Gen => stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "i" ;
|
||||
Dat => stem + "em" ;
|
||||
Loc => stem + "ē" ;
|
||||
Nom => stem + "e" ;
|
||||
Voc => stem + "e" ;
|
||||
Gen => stem + "es"
|
||||
}
|
||||
} ;
|
||||
gend = Masc
|
||||
} ;
|
||||
|
||||
noun_5mb_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "e" => noun_5mb_fromStems stem ;
|
||||
_ => Predef.error ("noun_5mb_fromLemma is only applicable for words that end in -e, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_5mb_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "es" => noun_5mb_fromStems stem ;
|
||||
_ => Predef.error ("noun_5mb_fromNomPl is only applicable for words that end in -es, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_2b_fromStems : Str -> Noun = \stem ->
|
||||
{
|
||||
s = table {
|
||||
Pl => table {
|
||||
Acc => stem + "us" ;
|
||||
Dat => stem + "iem" ;
|
||||
Loc => stem + "os" ;
|
||||
Nom => stem + "i" ;
|
||||
Voc => stem + "i" ;
|
||||
Gen => stem + "u"
|
||||
} ;
|
||||
Sg => table {
|
||||
Acc => stem + "i" ;
|
||||
Dat => stem + "im" ;
|
||||
Loc => stem + "ī" ;
|
||||
Nom => stem + "is" ;
|
||||
Voc => stem + "i" ;
|
||||
Gen => variants { stem + "a" ; stemchangeSimple 1 stem + "a" }
|
||||
}
|
||||
} ;
|
||||
gend = Masc
|
||||
} ;
|
||||
|
||||
noun_2b_fromLemma : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "is" => noun_2b_fromStems stem ;
|
||||
_ => Predef.error ("noun_2b_fromLemma is only applicable for words that end in -is, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
|
||||
noun_2b_fromNomPl : Str -> Noun = \lemma ->
|
||||
case lemma of {
|
||||
stem + "i" => noun_2b_fromStems stem ;
|
||||
_ => Predef.error ("noun_2b_fromNomPl is only applicable for words that end in -i, tried to apply to" ++ lemma)
|
||||
} ;
|
||||
}
|
||||
|
||||
105
src/latvian/PortedMorphoStemchangesLav.gf
Normal file
105
src/latvian/PortedMorphoStemchangesLav.gf
Normal file
@@ -0,0 +1,105 @@
|
||||
--# -path=.:abstract:common:prelude
|
||||
|
||||
-- Here goes manually ported stemchanges from
|
||||
-- https://github.com/LUMII-AILab/Morphology/blob/master/src/main/java/lv/semti/morphology/analyzer/Mijas.java
|
||||
|
||||
resource PortedMorphoStemchangesLav = open Prelude, Predef, ResLav in {
|
||||
|
||||
flags coding = utf8 ;
|
||||
|
||||
oper
|
||||
|
||||
stemchangeSimple : Int -> Str -> Str = \parId,stem ->
|
||||
case parId of {
|
||||
0 => stem ;
|
||||
|
||||
-- For nouns we need changes 0, 1, 17
|
||||
1 => case stem of { -- nouns
|
||||
s + ("kst") => s + "kš" ;
|
||||
s + ("nst") => s + "nš" ;
|
||||
s + ("ll") => s + "ļļ" ;
|
||||
s + ("sl") => s + "šļ" ;
|
||||
s + ("zl") => s + "žļ" ;
|
||||
s + ("ln") => s + "ļņ" ;
|
||||
s + ("nn") => s + "ņņ" ;
|
||||
s + ("sn") => s + "šņ" ;
|
||||
s + ("zn") => s + "žņ" ;
|
||||
s + ("īt") => s + "īš" ;
|
||||
s + ("d") => s + "ž" ;
|
||||
s + ("t") => s + "š" ;
|
||||
s + ("n") => s + "ņ" ;
|
||||
s + ("s") => s + "š" ;
|
||||
s + ("z") => s + "ž" ;
|
||||
s + ("b"|"f"|"m"|"p"|"v") => stem + "j" ;
|
||||
|
||||
_ => stem
|
||||
} ;
|
||||
|
||||
17 => case <stem, countSyllables stem > of { -- shortened vocative for fem nouns
|
||||
<s + ("īt"|"iņ"), _ > => stem ;
|
||||
--<_, 0|1> => variants {} ;
|
||||
<_, 0|1> => nonExist ; -- Exception
|
||||
<_, _> => stem
|
||||
} ;
|
||||
|
||||
-- For full adjectives we need changes 0, 3, 34, 13
|
||||
|
||||
_ => error ("Unsupported stemchange")
|
||||
};
|
||||
|
||||
stemchangeForAdjAdv : Int -> Str -> Definiteness -> Degree -> Str = \parId,stem,defi,deg ->
|
||||
case parId of {
|
||||
3 => case stem of {
|
||||
s + "āk" => case deg of {
|
||||
Posit => stem ;
|
||||
_ => nonExist -- TODO what should go there for nonexisting forms?
|
||||
};
|
||||
_ => case deg of {
|
||||
Posit => stem ;
|
||||
Compar => stem + "āk" ;
|
||||
Superl => case defi of {
|
||||
Def => "vis" + stem + "āk" ;
|
||||
Indef => nonExist
|
||||
}
|
||||
}
|
||||
} ;
|
||||
34 => case deg of { -- pēdēj-ais -> pēdē-jam, zaļ-š -> zaļa-jam
|
||||
Posit => case stem of {
|
||||
s + "ēj" => s + "ē" ;
|
||||
_ => stem + "a"
|
||||
} ;
|
||||
Compar => stem + "āka" ;
|
||||
Superl => case defi of {
|
||||
Def => "vis" + stem + "āka" ;
|
||||
Indef => nonExist
|
||||
}
|
||||
} ;
|
||||
|
||||
_ => case deg of { _ => stemchangeSimple parId stem }
|
||||
} ;
|
||||
|
||||
-- Inari's trick for counting syllables https://inariksit.github.io/gf/2018/08/28/gf-gotchas.html#cute-way-to-count-syllables
|
||||
-- pattern macro for vowels
|
||||
v : pattern Str = #("a"|"ā"|"e"|"ē"|"i"|"ī"|"o"|"u"|"ū") ;
|
||||
|
||||
-- type alias for the helper function
|
||||
SylCnt : Type = Bool -> Str -> Ints 10 ;
|
||||
|
||||
countSyllables : Str -> Ints 10 = go count False
|
||||
where { -- synonym of let
|
||||
go : SylCnt -> SylCnt = \f,wasVowel,word -> -- These three arguments come from the fact that SylCnt is the abovedefined 3rd order function.
|
||||
case <word,wasVowel> of {
|
||||
<#v + s, False> => Predef.plus (f True s) 1 ;
|
||||
<#v + s, True> => f True s ;
|
||||
<? + s, _> => f False s ;
|
||||
_ => 0
|
||||
} ;
|
||||
|
||||
-- end of recursion
|
||||
scBase : SylCnt = \_,_ -> 0 ;
|
||||
|
||||
-- the function given to countSyllables
|
||||
count : SylCnt = go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go (go scBase)))))))))))))))))))))))))))))))))))))))
|
||||
} ;
|
||||
|
||||
}
|
||||
53
src/latvian/PortedMorphoUtilsLav.gf
Normal file
53
src/latvian/PortedMorphoUtilsLav.gf
Normal file
@@ -0,0 +1,53 @@
|
||||
--# -path=.:abstract:common:prelude
|
||||
|
||||
-- Here goes manually made utils used for automaticaly exported Tēzaurs lexicon.
|
||||
|
||||
resource PortedMorphoUtilsLav = open Prelude, Predef, ResLav in {
|
||||
|
||||
flags coding = utf8 ;
|
||||
|
||||
oper
|
||||
|
||||
changeNounForm : Number -> Case -> Str -> Noun -> Noun =
|
||||
\N,C,form,noun -> noun ** {
|
||||
s = \\n,c => case <n,N,c,C> of {
|
||||
<Sg, Sg, Nom, Nom> |
|
||||
<Sg, Sg, Gen, Gen> |
|
||||
<Sg, Sg, Dat, Dat> |
|
||||
<Sg, Sg, Voc, Voc> |
|
||||
<Pl, Pl, Nom, Nom> |
|
||||
<Pl, Pl, Gen, Gen> |
|
||||
<Pl, Pl, Dat, Dat> |
|
||||
<Pl, Pl, Voc, Voc> => form ;
|
||||
_ => noun.s ! n ! c }
|
||||
} ;
|
||||
|
||||
addNounForm : Number -> Case -> Str -> Noun -> Noun =
|
||||
\N,C,form,noun -> noun ** {
|
||||
s = \\n,c => case <n,N,c,C> of {
|
||||
<Sg, Sg, Nom, Nom> |
|
||||
<Sg, Sg, Gen, Gen> |
|
||||
<Sg, Sg, Dat, Dat> |
|
||||
<Sg, Sg, Voc, Voc> |
|
||||
<Pl, Pl, Nom, Nom> |
|
||||
<Pl, Pl, Gen, Gen> |
|
||||
<Pl, Pl, Dat, Dat> |
|
||||
<Pl, Pl, Voc, Voc> => variants {form ; noun.s ! n ! c} ;
|
||||
_ => noun.s ! n ! c }
|
||||
} ;
|
||||
|
||||
{- A note about GF restrictions as of 2025-08-27:
|
||||
Following thing does not work, compiler asumes that N an C are free variables.
|
||||
changeForm_ideal : Number -> Case -> Str -> Noun -> Noun ;
|
||||
changeForm_ideal N C str noun = noun ** {NF N C => str} ;
|
||||
Meanwhile this should work
|
||||
changeForm_fixed : Str -> Noun -> Noun ;
|
||||
changeForm_fixed str noun = noun ** {NF Sg Nom => str} ;
|
||||
Related: https://github.com/GrammaticalFramework/gf-core/issues/198
|
||||
Also Inari suggested to avoid using a function and write this thing inline:
|
||||
Noun : Type = {s : NForm => Str} ;
|
||||
myRegularNoun = {- … some noun …- } ;
|
||||
mySpecialNoun = {s = myRegularNoun.s ** {NF Sg Acc => "special form"}} ;
|
||||
-}
|
||||
|
||||
}
|
||||
68316
src/latvian/PortedTezaursDictLav.gf
Normal file
68316
src/latvian/PortedTezaursDictLav.gf
Normal file
File diff suppressed because it is too large
Load Diff
68305
src/latvian/PortedTezaursDictLavAbs.gf
Normal file
68305
src/latvian/PortedTezaursDictLavAbs.gf
Normal file
File diff suppressed because it is too large
Load Diff
@@ -13,12 +13,12 @@ param
|
||||
|
||||
Case = Nom | Gen | Dat | Acc | Loc | Voc ;
|
||||
Gender = Masc | Fem ;
|
||||
Declension = D0 | D1 | D2 | D3 | D4 | D5 | D6 | DR ;
|
||||
Declension = D0 | D1 | D2 | D3 | D4 | D5 | D6 | DR | DG; -- ammended for Tēzaurs.
|
||||
|
||||
-- Adjectives
|
||||
|
||||
Definiteness = Indef | Def ;
|
||||
AType = AQual | ARel | AIndecl ;
|
||||
AType = AQual | ARel | AIndecl ; -- Doesn't exactly fit with Tēzaurs system - AIndecl is not needed.
|
||||
|
||||
AForm =
|
||||
AAdj Degree Definiteness Gender Number Case
|
||||
@@ -27,7 +27,7 @@ param
|
||||
-- Verbs
|
||||
|
||||
Voice = Act | Pass ;
|
||||
Conjugation = C2 | C3 ; -- C1 - "irregular" verbs
|
||||
Conjugation = C2 | C3 | C1 | CI ; -- C1 - "irregular" verbs ; ammended for Tēzaurs.
|
||||
|
||||
-- Verb moods:
|
||||
-- Ind - indicative
|
||||
|
||||
@@ -185,15 +185,14 @@ lin
|
||||
ComplSlash vpslash np =
|
||||
let agr : Agreement = np.agr in {
|
||||
v = vpslash.v ;
|
||||
{-
|
||||
compl = \\agr => case vpslash.voice of {
|
||||
Act => vpslash.rightVal.s ++ np.s ! (vpslash.rightVal.c ! (fromAgr agr).num) ;
|
||||
Pass => case vpslash.rightVal.c ! (fromAgr agr).num of {
|
||||
Nom => np.s ! (vpslash.rightVal.c ! Sg) ;
|
||||
_ => vpslash.rightVal.s ++ np.s ! (vpslash.rightVal.c ! (fromAgr agr).num)
|
||||
}
|
||||
} ++ vpslash.compl ! agr ;
|
||||
-}
|
||||
-- compl = \\agr => case vpslash.voice of {
|
||||
-- Act => vpslash.rightVal.s ++ np.s ! (vpslash.rightVal.c ! (fromAgr agr).num) ;
|
||||
-- Pass => case vpslash.rightVal.c ! (fromAgr agr).num of {
|
||||
-- Nom => np.s ! (vpslash.rightVal.c ! Sg) ;
|
||||
-- _ => vpslash.rightVal.s ++ np.s ! (vpslash.rightVal.c ! (fromAgr agr).num)
|
||||
-- }
|
||||
-- } ++ vpslash.compl ! agr ;
|
||||
|
||||
compl = \\agr => vpslash.rightVal.s ++
|
||||
np.s ! (vpslash.rightVal.c ! (fromAgr agr).num) ++
|
||||
vpslash.compl ! agr ;
|
||||
|
||||
Reference in New Issue
Block a user