-
Notifications
You must be signed in to change notification settings - Fork 0
/
verbs.rs
153 lines (133 loc) · 4.48 KB
/
verbs.rs
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// //! # This module includes code specific to learning verbforms.
// use crate::*;
// use colored::Colorize;
// use std::io::Write;
// #[derive(Debug, Clone)]
// /// Structure the store each Verb's data
// pub struct Verb {
// inf: String,
// dri: String,
// pra: String,
// per: String,
// trm: String,
// lok: Lok,
// }
// impl Verb {
// pub fn new(inf: &str, dri: &str, pra: &str, per: &str, trm: &str, lok: Option<&str>) -> Self {
// Verb {
// inf: inf.to_owned(),
// dri: dri.to_owned(),
// pra: pra.to_owned(),
// per: per.to_owned(),
// trm: trm.to_owned(),
// lok: Lok::new(lok.unwrap_or_default()),
// }
// }
// fn print_em_colored(&self) -> String {
// format!(
// "{}, {}, {}, {}",
// self.inf.yellow().underline(),
// self.dri.bright_blue().underline(),
// self.pra.cyan().underline(),
// self.per.bright_magenta().underline()
// )
// }
// }
// impl Verb {
// fn question(&self) -> Msg {
// Msg::Quest(self.trm.clone())
// }
// fn correct(&self) -> String {
// format!("{}, {}, {}, {}", &self.inf, &self.dri, &self.pra, &self.per)
// }
// fn skip(&self) -> Msg {
// Msg::Skip(self.ser(" = "))
// }
// fn wrong(&self) -> Msg {
// Msg::Wrong(self.print_em_colored())
// }
// fn hint(&self) -> Msg {
// Msg::Hint(crate::hint(&self.inf))
// }
// fn flashcard(&self) -> Msg {
// Msg::Flash(format!(
// "{}, {}, {}, {}",
// &self.inf, &self.dri, &self.pra, &self.per
// ))
// }
// fn deser(line: &str, delim: char) -> Result<Box<Self>, Box<dyn Error>> {
// let mut words = line.split(delim);
// let inf = words.next().unwrap_or("").trim();
// let dri = words.next().unwrap_or("").trim();
// let pra = words.next().unwrap_or("").trim();
// let per = words.next().unwrap_or("").trim();
// let trm = words.next().unwrap_or("").trim();
// let lok = words.next();
// if inf.is_empty() || dri.is_empty() || pra.is_empty() || per.is_empty() || trm.is_empty() {
// Err(format!(
// "A line should look like this: \n\t\"{}{}{}{}{}{}{}{}{}\".\nInstead looks like this: \n\t\"{}\".",
// "<infinitive>".yellow().italic(),
// delim.to_string().red().bold(),
// "<3rd person>".red().bold(),
// delim.to_string().red().bold(),
// "<simple past>".green().bold(),
// delim.to_string().red().bold(),
// "<present perfect>".red().bold(),
// delim.to_string().red().bold(),
// "<term>".blue().italic(),
// line,
// ).into())
// } else {
// // making a Verbs of the values
// Ok(Box::new(Verb::new(inf, dri, pra, per, trm, lok)))
// }
// }
// fn ser(&self, delim: &str) -> String {
// format!(
// "{}{delim}{}{delim}{}{delim}{}{delim}{}{delim}{}",
// self.inf,
// self.dri,
// self.pra,
// self.per,
// self.trm,
// self.lok().display()
// )
// }
// fn incr(&mut self) {
// self.lok.incr();
// }
// fn decr(&mut self) {
// self.lok.decr();
// }
// fn lok(&self) -> Lok {
// self.lok()
// }
// }
// /// Function to convert a Deck from Verbs to Cards
// ///
// /// # Errors
// ///
// /// - `fs::create()`
// /// - `writeln!()`
// ///
// /// # Panics
// ///
// /// - `PathBuf::file_stem()`
// pub fn deser_to_card(verbs: &[Verb], conf: &config::Config) -> Result<(), Box<dyn Error>> {
// let pb = PathBuf::from(&conf.file_path_orig());
// let outf_name = format!("{}_as_cards.csv", pb.file_stem().unwrap().to_str().unwrap());
// println!(
// "\n\nConverting verbs to cards, from file: {:?} to file: {}",
// conf.file_path_orig(),
// outf_name.bright_blue()
// );
// let mut out_f = File::create(outf_name)?;
// writeln!(out_f, "# [crablit]")?;
// writeln!(out_f, "# mode = \"cards\"")?;
// writeln!(out_f, "# delim = \'{}\'\n\n", conf.delim())?;
// for line in verbs {
// writeln!(out_f, "{}{}{}", line.trm, conf.delim(), line.inf)?;
// }
// println!("Converting from verbs to cards done");
// Ok(())
// }