jpreprocess_jpcommon/label/
word.rs1use jpreprocess_core::pronunciation::Pronunciation;
2
3use jpreprocess_njd::NJDNode;
4
5use crate::word_attr::*;
6
7#[derive(Clone, Debug)]
8pub struct Word {
9 pos: Option<u8>,
10 ctype: Option<u8>,
11 cform: Option<u8>,
12 pub moras: Pronunciation,
13}
14
15impl Word {
16 pub fn count_mora(&self) -> usize {
17 self.moras.mora_size()
18 }
19}
20
21impl From<&NJDNode> for Word {
22 fn from(njdnode: &NJDNode) -> Self {
23 Self {
24 pos: pos_to_id(njdnode.get_pos()),
25 ctype: ctype_to_id(njdnode.get_ctype()),
26 cform: cform_to_id(njdnode.get_cform()),
27 moras: njdnode.get_pron().clone(),
28 }
29 }
30}
31
32impl From<&Word> for jlabel::Word {
33 fn from(val: &Word) -> Self {
34 jlabel::Word {
35 pos: val.pos,
36 ctype: val.ctype,
37 cform: val.cform,
38 }
39 }
40}