diff --git a/src/analyzer/units/by_hyphen/ha.rs b/src/analyzer/units/by_hyphen/ha.rs index 43661e5..03764de 100644 --- a/src/analyzer/units/by_hyphen/ha.rs +++ b/src/analyzer/units/by_hyphen/ha.rs @@ -3,7 +3,7 @@ use analyzer::MorphAnalyzer; use container::abc::*; use container::stack::StackSource; use container::{HyphenAdverb, Lex, ParseResult, Parsed, Score, SeenSet, WordStruct}; -use opencorpora::kind::{Case, Number, PartOfSpeach}; +use opencorpora::kind::{Case, Number, PartOfSpeech}; use opencorpora::OpencorporaTagReg; const HA_PREFIX: &str = "по-"; @@ -48,7 +48,7 @@ impl AnalyzerUnit for HyphenAdverbAnalyzer { .filter(|parsed| { let tag = parsed.lex.get_tag(morph); match (tag.pos, tag.number, tag.case) { - (Some(PartOfSpeach::Adjf), Some(Number::Sing), Some(Case::Datv)) => true, + (Some(PartOfSpeech::AdjectiveFull), Some(Number::Sing), Some(Case::Datv)) => true, _ => false, } }) diff --git a/src/opencorpora/kind/mod.rs b/src/opencorpora/kind/mod.rs index 5bc270e..9b570bf 100644 --- a/src/opencorpora/kind/mod.rs +++ b/src/opencorpora/kind/mod.rs @@ -19,7 +19,7 @@ pub use self::involvement::Involvement; pub use self::mood::Mood; pub use self::number::Number; pub use self::person::Person; -pub use self::pos::PartOfSpeach; +pub use self::pos::PartOfSpeech; pub use self::tense::Tense; pub use self::transitivity::Transitivity; pub use self::voice::Voice; diff --git a/src/opencorpora/kind/pos.rs b/src/opencorpora/kind/pos.rs index 0d941f4..2100753 100644 --- a/src/opencorpora/kind/pos.rs +++ b/src/opencorpora/kind/pos.rs @@ -1,39 +1,39 @@ #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum PartOfSpeach { +pub enum PartOfSpeech { /// имя существительное Noun, /// имя прилагательное (полное) - Adjf, + AdjectiveFull, /// имя прилагательное (краткое) - Adjs, + AdjectiveShort, /// компаратив - Comp, + Comparative, /// глагол (личная форма) Verb, /// глагол (инфинитив) - Infn, + Infinitive, /// причастие (полное) - Prtf, + ParticipleFull, /// причастие (краткое) - Prts, + ParticipleShort, /// деепричастие - Grnd, + Gerund, /// числительное - Numr, + Number, /// наречие - Advb, + Adverb, /// местоимение-существительное - Npro, + Pronoun, /// предикатив - Pred, + Predicative, /// предлог - Prep, + Preposition, /// союз - Conj, + Conjunction, /// частица - Prcl, + Particle, /// междометие - Intj, + Interjection, } regex!( @@ -61,43 +61,50 @@ regex!( " ); -impl PartOfSpeach { +impl PartOfSpeech { pub fn try_from_str(s: S) -> Option where S: AsRef, { - use self::PartOfSpeach::*; + use self::PartOfSpeech::*; TAG_RE .captures_iter(s.as_ref()) .next() .and_then(|cap| match &cap[1] { "NOUN" => Some(Noun), - "ADJF" => Some(Adjf), - "ADJS" => Some(Adjs), - "COMP" => Some(Comp), + "ADJF" => Some(AdjectiveFull), + "ADJS" => Some(AdjectiveShort), + "COMP" => Some(Comparative), "VERB" => Some(Verb), - "INFN" => Some(Infn), - "PRTF" => Some(Prtf), - "PRTS" => Some(Prts), - "GRND" => Some(Grnd), - "NUMR" => Some(Numr), - "ADVB" => Some(Advb), - "NPRO" => Some(Npro), - "PRED" => Some(Pred), - "PREP" => Some(Prep), - "CONJ" => Some(Conj), - "PRCL" => Some(Prcl), - "INTJ" => Some(Intj), + "INFN" => Some(Infinitive), + "PRTF" => Some(ParticipleFull), + "PRTS" => Some(ParticipleShort), + "GRND" => Some(Gerund), + "NUMR" => Some(Number), + "ADVB" => Some(Adverb), + "NPRO" => Some(Pronoun), + "PRED" => Some(Predicative), + "PREP" => Some(Preposition), + "CONJ" => Some(Conjunction), + "PRCL" => Some(Particle), + "INTJ" => Some(Interjection), _ => None, }) } pub fn is_productive(self) -> bool { - use self::PartOfSpeach::*; + use self::PartOfSpeech::*; match self { - Conj | Numr | Npro | Pred | Prep | Prcl | Intj => false, + | Conjunction + | Number + | Pronoun + | Predicative + | Preposition + | Particle + | Interjection + => false, _ => true, } } @@ -109,11 +116,11 @@ mod tests { #[test] fn try_from_str() { - assert_eq!(Some(PartOfSpeach::Noun), PartOfSpeach::try_from_str("NOUN")); + assert_eq!(Some(PartOfSpeech::Noun), PartOfSpeech::try_from_str("NOUN")); assert_eq!( - Some(PartOfSpeach::Noun), - PartOfSpeach::try_from_str("NOUN,anim,masc,Fixd,Abbr sing,nomn") + Some(PartOfSpeech::Noun), + PartOfSpeech::try_from_str("NOUN,anim,masc,Fixd,Abbr sing,nomn") ); - assert_eq!(None, PartOfSpeach::try_from_str("UNKN")); + assert_eq!(None, PartOfSpeech::try_from_str("UNKN")); } } diff --git a/src/opencorpora/tag/reg.rs b/src/opencorpora/tag/reg.rs index 66309ac..707f786 100644 --- a/src/opencorpora/tag/reg.rs +++ b/src/opencorpora/tag/reg.rs @@ -11,7 +11,7 @@ pub struct OpencorporaTagReg { pub string: String, pub grammemes: GrammemeSet, - pub pos: Option, + pub pos: Option, pub animacy: Option, pub aspect: Option, pub case: Option, @@ -48,7 +48,7 @@ impl OpencorporaTagReg { let grammemes = GrammemeSet::new(&string); - let pos = PartOfSpeach::try_from_str(&string); + let pos = PartOfSpeech::try_from_str(&string); let animacy = Animacy::try_from_str(&string); let aspect = Aspect::try_from_str(&string); let case = Case::try_from_str(&string); @@ -106,9 +106,12 @@ impl OpencorporaTagReg { }; let x = match self.pos { - Some(PartOfSpeach::Noun) | Some(PartOfSpeach::Adjf) | Some(PartOfSpeach::Prtf) => { + | Some(PartOfSpeech::Noun) + | Some(PartOfSpeech::AdjectiveFull) + | Some(PartOfSpeech::ParticipleFull) + => { match self.pos { - Some(PartOfSpeach::Noun) + Some(PartOfSpeech::Noun) if self.case != Some(Case::Nomn) && self.case != Some(Case::Accs) => { match self.case { @@ -122,11 +125,11 @@ impl OpencorporaTagReg { _ => Some((Number::Sing, Some(Case::Accs))), }, - Some(PartOfSpeach::Noun) if index == 1 => { + Some(PartOfSpeech::Noun) if index == 1 => { Some((Number::Sing, Some(Case::Gent))) } - Some(PartOfSpeach::Adjf) | Some(PartOfSpeach::Prtf) + Some(PartOfSpeech::AdjectiveFull) | Some(PartOfSpeech::ParticipleFull) if index == 1 && self.gender == Some(Gender::Femn) => { Some((Number::Plur, Some(Case::Nomn))) @@ -158,7 +161,7 @@ impl OpencorporaTagReg { // let sample = OpencorporaTagReg::from_str("PRTF,impf,tran,past,actv anim,masc,sing,accs,Infr"); // let tag = OpencorporaTagReg { // string: "PRTF,impf,tran,past,actv anim,masc,sing,accs,Infr".into(), -// pos: Some(PartOfSpeach::Prtf), +// pos: Some(PartOfSpeech::Prtf), // animacy: Some(Animacy::Anim), // aspect: Some(Aspect::Impf), // case: Some(Case::Accs),