Noun stemchanges for the Lav remake.

This commit is contained in:
lauma
2025-08-25 17:17:51 +03:00
parent 04df53a17a
commit 943f387a23
8 changed files with 107 additions and 21 deletions

View File

@@ -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

View File

@@ -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 -> {

View File

@@ -0,0 +1,5 @@
--# -path=.:abstract:common:prelude
-- Here goes authomatically exported lexicon from tezaurs.lv
resource PortedMorphoDictLav = open Prelude, Predef in {}

View File

@@ -0,0 +1,6 @@
--# -path=.:abstract:common:prelude
-- Here goes authomatically ported paradigms from
-- https://github.com/PeterisP/morphology/blob/master/src/main/resources/Lexicon_v2.xml
resource PortedMorphoParadigmsLav = open Prelude, Predef in {}

View File

@@ -0,0 +1,71 @@
--# -path=.:abstract:common:prelude
-- Here goes manually ported stemchanges from
-- https://github.com/PeterisP/morphology/blob/master/src/main/java/lv/semti/morphology/analyzer/Mijas.java
resource PortedMorphoStemchangesLav = open Prelude, Predef in {
flags coding = utf8 ;
oper
stemchange : Int -> Str -> Str = \parId,stem ->
case parId of {
0 => stem;
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
};
_ => error ("Unsupported stemchange")
};
-- 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 {
go : SylCnt -> SylCnt = \f,wasVowel,word ->
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)))))))))))))))))))))))))))))))))))))))
} ;
}

View File

@@ -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

View File

@@ -18,7 +18,8 @@ lin
ImpVP vp = { s = \\pol,num => vp.v.s ! pol ! (VImp num) ++ vp.compl ! (AgrP2 num Masc) } ;
SlashVP np vp = mkClause np vp ** { prep = vp.rightVal } ;
-- SlashVP np vp = mkClause np vp ** { prep = vp.rightVal } ;
-- FIX ME tmp comment
AdvSlash slash adv = {
s = \\m,p => slash.s ! m ! p ++ adv.s ;

View File

@@ -182,18 +182,17 @@ lin
-- VPSlash -> NP -> VP
-- e.g. 'love it'
ComplSlash vpslash np =
{- 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 ;
@@ -203,7 +202,7 @@ lin
rightPol = np.pol ;
objPron = np.isPron ;
rightVal = vpslash.rightVal
} ;
} ; -} -- FIX ME tmp comment
-- VV -> VPSlash -> VPSlash
-- e.g. 'want to buy'
@@ -220,7 +219,7 @@ lin
-- V2V -> NP -> VPSlash -> VPSlash
-- e.g. '-- beg me to buy'
SlashV2VNP v2v np vpslash = insertObjSlash
{- SlashV2VNP v2v np vpslash = insertObjSlash
(\\_ => v2v.rightVal.s ++ np.s ! (v2v.rightVal.c ! (fromAgr np.agr).num))
{
v = v2v ;
@@ -231,7 +230,7 @@ lin
rightPol = np.pol ;
objPron = np.isPron ;
rightVal = v2v.rightVal
} ;
} ; -} -- FIX ME tmp comment
-- Other ways of forming verb phrases