Verbs partially handled

Regular verbs now handled, which excludes <o ber>, <o hab> and <o gier>
parent 68fee997
Pipeline #231 canceled with stage
in 1 minute and 10 seconds
......@@ -50,6 +50,10 @@ fn process_noun_suffixes(word: &mut Word) {
}
}
fn process_verb_suffixes(word: &mut Word) {
word.check_affix(Word::verb_conj());
}
fn process_suffixes(word: &mut Word) {
word.make_affixes();
if word.get_affixes() == "" {
......@@ -68,6 +72,8 @@ fn process_suffixes(word: &mut Word) {
&"n" => process_noun_suffixes(word),
&"adj" => process_noun_suffixes(word),
&"nbr" => process_noun_suffixes(word),
&"vi" => process_verb_suffixes(word),
&"vt" => process_verb_suffixes(word),
wclass => println!("{}: Not Yet Handled", wclass),
}
}
......
use std::collections::HashMap;
use xml::writer::XmlEvent;
pub type Affixes = Vec<(&'static str, &'static str)>;
pub struct Word {
word: String,
......@@ -66,12 +67,12 @@ impl Word {
}
#[inline]
pub fn numbers() -> Vec<(&'static str, &'static str)> {
pub fn numbers() -> Affixes {
vec![("et", "-pau"), ("t", "-pau"), ("eþ", "-pl"), ("þ", "-pl")]
}
#[inline]
pub fn possessives() -> Vec<(&'static str, &'static str)> {
pub fn possessives() -> Affixes {
vec![
("yċ", "-POSS.1sg"),
("yþ", "-POSS.1pau"),
......@@ -88,7 +89,7 @@ impl Word {
}
#[inline]
pub fn gram_cases() -> Vec<(&'static str, &'static str)> {
pub fn gram_cases() -> Affixes {
vec![
("ant", "-ACC"),
("iþ", "-DAT"),
......@@ -102,17 +103,64 @@ impl Word {
]
}
pub fn check_affix(
&mut self,
affixes_vec: Vec<(&'static str, &'static str)>,
) -> bool {
#[inline]
pub fn verb_conj() -> Affixes {
vec![
("age", "-sg.IMPER"),
("agi", "-pl.IMPER"),
("agér", "-pau.IMPER"),
("and", "-part.prog"),
("ar", "-2pl.imperf"),
("e", "-1sg.imperf"),
("ea", "-3sg.imperf"),
("egeat", "-pl.JUS"),
("egent", "-pau.JUS"),
("eget", "-sg.JUS"),
("ei", "-2sg.imperf"),
("en", "-1+3pl.pst.imperf"),
("ent", "-2pl.pst.imperf"),
("er", "-1sg.pst.imperf"),
("er", "-3sg.pst.imperf"),
("ern", "-1pl.imperf"),
("erð", "-3pau.pst.imperf"),
("et", "-1pau.imperf"),
("eð", "-1pau.pst.imperf"),
("eþ", "-2pau.pst.imperf"),
("ge", "-sg.IMPER"),
("geat", "-pl.JUS"),
("gent", "-pau.JUS"),
("get", "-sg.JUS"),
("gi", "-pl.IMPER"),
("gér", "-pau.IMPER"),
("o", "-1+3sg.perf"),
("on", "-3pl.perf"),
("ota", "-part.pres"),
("ou", "-2sg.perf"),
("ta", "-part.pres"),
("tér", "-part.fut"),
("u", "-1+2pl.perf"),
("un", "-2pau.perf"),
("ur", "-1+3pau.perf"),
("æt", "-2+3pau.imperf"),
("ér", "-3pl.imperf"),
("ét", "-2sg.pst.imperf"),
("étér", "-part.fut"),
("ðet", "-part.pst"),
]
}
pub fn check_affix(&mut self, affixes_vec: Affixes) -> bool {
let mut cur_suffix = "";
let mut cur_gloss = "";
for (suffix, gloss) in affixes_vec {
if self.affixes.starts_with(suffix) {
self.affixes =
self.affixes.trim_start_matches(suffix).to_string();
self.gloss.push_str(gloss);
if self.affixes.starts_with(suffix) && suffix.len() > cur_suffix.len() {
cur_suffix = suffix;
cur_gloss = gloss;
}
}
self.affixes =
self.affixes.trim_start_matches(cur_suffix).to_string();
self.gloss.push_str(cur_gloss);
self.affixes != ""
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment