Nouns now fully handled

parent e6acba95
Pipeline #229 passed with stage
in 1 minute and 17 seconds
......@@ -104,6 +104,7 @@ fobror,n
fogel,n
fon,pron.q.gen
foþtyr,n
frég,vt
freði,n
fri,adj
frie,nbr
......
Em meþ Gunnarac annéðant þynea. An ænant caupage, ar annéð caupe. Fe en eppelant etano Éþtrið fent etano? Þror eppelant feþ geffo? Du feċ gei? Hint fec fém gér? Fon landytoċ beþt bƿand? Feren Mattérant frégei? Ferve Mattérant frégei? Eppeleþant eða curþabérant, fertið y caupei? Ferden urbyþ gon? Fertið bryðdegynant haþt? Fertiðoċ Mattérant frégei? Fertiðac y ċilde?
Em meþ Gunnarac annéðant þynea. An ænant caupage, ar annéð caupe. Fe en eppelant etano Éþtrið fent etano? Þror eppelant feþ geffo? Du feċ gei? Hint fec fém gér? Fon landytoċ beþt bƿand? Feren Mattérant frégei? Ferve Mattérant frégei? Eppeleþant eða cirþabérant, fertið y caupei? Ferden urbyþ gon? Fertið bryðdegdynant haþt? Fertiðoċ Mattérant frégei? Fertiðac y ċilde?
......@@ -41,6 +41,15 @@ fn read_text(filename: &str) -> Vec<String> {
sentences
}
fn process_noun_suffixes(word: &mut Word) {
if !word.check_affix(Word::numbers()) ||
!word.check_affix(Word::possessives()) ||
!word.check_affix(Word::gram_cases())
{
return;
}
}
fn process_suffixes(word: &mut Word) {
word.make_affixes();
if word.get_affixes() == "" {
......@@ -48,16 +57,20 @@ fn process_suffixes(word: &mut Word) {
}
println!("Original:\t{}-{}", word.get_morpheme(), word.get_affixes());
// Check number suffix
if !word.check_paucal() {
word.check_plural();
}
println!("Number:\t\t{}-{}", word.get_morpheme(), word.get_affixes());
if word.get_affixes() == "" {
return;
match word
.get_gloss()
.clone()
.split('.')
.collect::<Vec<_>>()
.get(0)
.unwrap()
{
&"np" => process_noun_suffixes(word),
&"n" => process_noun_suffixes(word),
&"adj" => process_noun_suffixes(word),
&"nbr" => process_noun_suffixes(word),
wclass => println!("{}: Not Yet Handled", wclass),
}
// Check possessive suffix
}
fn process_word<W: Write>(
......
use xml::writer::XmlEvent;
use std::collections::HashMap;
use xml::writer::XmlEvent;
pub struct Word {
word: String,
......@@ -98,31 +98,54 @@ impl Word {
self.ends_vowel = self.make_end_with_vowel();
}
pub fn check_plural(&mut self) -> bool {
if self.ends_vowel && self.affixes.starts_with("þ") {
self.affixes = self.affixes.trim_start_matches("þ").to_string();
self.gloss.push_str(".pl");
true
} else if self.affixes.starts_with("eþ") {
self.affixes = self.affixes.trim_start_matches("eþ").to_string();
self.gloss.push_str(".pl");
true
} else {
false
}
#[inline]
pub fn numbers() -> Vec<(&'static str, &'static str)> {
vec![("et", "-pau"), ("t", "-pau"), ("eþ", "-pl"), ("þ", "-pl")]
}
#[inline]
pub fn possessives() -> Vec<(&'static str, &'static str)> {
vec![
("yċ", "-POSS.1sg"),
("yþ", "-POSS.1pau"),
("yn", "-POSS.1pl"),
("dyn", "-POSS.2sg"),
("m", "-POSS.2pau"),
("im", "-POSS.2pau"),
("enu", "-POSS.2pl"),
("nu", "-POSS.2pl"),
("én", "-POSS.3sg"),
("ean", "-POSS.3pau"),
("eaþ", "-POSS.3pl"),
]
}
#[inline]
pub fn gram_cases() -> Vec<(&'static str, &'static str)> {
vec![
("ant", "-ACC"),
("iþ", "-DAT"),
("ċ", "-LOC"),
("oċ", "-LOC"),
("ac", "-ABL"),
("rac", "-ABL"),
("ém", "-LIMIT"),
("un", "-GEN"),
("y", "-VOC"),
]
}
pub fn check_paucal(&mut self) -> bool {
if self.ends_vowel && self.affixes.starts_with("t") {
self.affixes = self.affixes.trim_start_matches("t").to_string();
self.gloss.push_str(".pau");
true
} else if self.affixes.starts_with("et") {
self.affixes = self.affixes.trim_start_matches("et").to_string();
self.gloss.push_str(".pau");
true
} else {
false
pub fn check_affix(
&mut self,
affixes_vec: Vec<(&'static str, &'static str)>,
) -> bool {
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);
}
}
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