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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Verb(pub bool, pub String);
impl Verb {
pub fn gen(&self, he_she_it: bool) -> String {
let string = if he_she_it {
self.1
.replace("[is/are]", "is")
.replace("[has/have]", "has")
.replace("[was/were]", "was")
.replace("(s)", "s")
.replace("(es)", "es")
} else {
self.1
.replace("[is/are]", "are")
.replace("[has/have]", "have")
.replace("[was/were]", "were")
.replace("(s)", "")
.replace("(es)", "")
};
string
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Word {
Noun(bool, String),
Ending(String),
Verb(Verb),
And,
Unfinished
}
impl Word {
pub fn is_noun(&self) -> bool {
if let Word::Noun(..) = *self {
return true;
}
false
}
pub fn is_ending(&self) -> bool {
if let Word::Ending(_) = *self {
return true;
}
false
}
pub fn is_verb(&self) -> bool {
if let Word::Verb(_) = *self {
return true;
}
false
}
pub fn is_and(&self) -> bool {
if let Word::And = *self {
return true;
}
false
}
pub fn is_unfinished(&self) -> bool {
if let Word::Unfinished = *self {
return true;
}
false
}
}