1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use jpreprocess_core::pronunciation::Pronunciation;

use jpreprocess_njd::NJDNode;

use crate::word_attr::*;

#[derive(Clone, Debug)]
pub struct Word {
    pos: Option<u8>,
    ctype: Option<u8>,
    cform: Option<u8>,
    pub moras: Pronunciation,
}

impl Word {
    pub fn count_mora(&self) -> usize {
        self.moras.mora_size()
    }
}

impl From<&NJDNode> for Word {
    fn from(njdnode: &NJDNode) -> Self {
        Self {
            pos: pos_to_id(njdnode.get_pos()),
            ctype: ctype_to_id(njdnode.get_ctype()),
            cform: cform_to_id(njdnode.get_cform()),
            moras: njdnode.get_pron().clone(),
        }
    }
}

impl From<&Word> for jlabel::Word {
    fn from(val: &Word) -> Self {
        jlabel::Word {
            pos: val.pos,
            ctype: val.ctype,
            cform: val.cform,
        }
    }
}