aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/cli/src/words.rs20
-rw-r--r--lib/mihi/src/lib.rs33
2 files changed, 51 insertions, 2 deletions
diff --git a/crates/cli/src/words.rs b/crates/cli/src/words.rs
index 953760a..cd0f1a0 100644
--- a/crates/cli/src/words.rs
+++ b/crates/cli/src/words.rs
@@ -250,6 +250,7 @@ fn prompt_conjugation(conjugation: Conjugation) -> Result<Conjugation, String> {
Conjugation::Third,
Conjugation::ThirdIo,
Conjugation::Fourth,
+ Conjugation::Other,
];
let idx = conjugation as usize - 1;
@@ -376,7 +377,20 @@ fn ask_for_word_based_on(enunciated: String, word: Word) -> Result<Word, String>
Err(_) => return Err("abort!".to_string()),
}
}
- Category::Verb => String::from("verb"),
+ Category::Verb => {
+ if matches!(conjugation, Some(Conjugation::Other)) {
+ let options = vec![
+ "sum", "possum", "eo", "volo", "nolo", "malo", "fero", "facio", "do", "inquam",
+ "aio",
+ ];
+ match Select::new("Kind:", options).prompt() {
+ Ok(kind) => kind.to_string(),
+ Err(_) => return Err("abort!".to_string()),
+ }
+ } else {
+ "verb".to_string()
+ }
+ }
_ => String::from("-"),
};
@@ -968,7 +982,9 @@ fn show_info(word: Word) -> Result<(), String> {
// Conjugation, declension + kind.
match word.conjugation {
- Some(ref conjugation) => println!("Conjugation: {}", conjugation),
+ Some(ref conjugation) => {
+ println!("Conjugation: {}", conjugation.display_with_kind(&word.kind))
+ }
None => {
if let Some(ref d) = word.declension {
if matches!(d, Declension::Other) {
diff --git a/lib/mihi/src/lib.rs b/lib/mihi/src/lib.rs
index e965fdf..f944b82 100644
--- a/lib/mihi/src/lib.rs
+++ b/lib/mihi/src/lib.rs
@@ -247,6 +247,12 @@ pub enum Conjugation {
Third,
ThirdIo,
Fourth,
+
+ // The 'Other' conjugation is a container for a bunch of verbs like 'sum',
+ // 'volō', etc. That is, we expect the user to realize this is an irregular
+ // verb, and then we rely on the 'kind' column to determine which kind of
+ // irregular verb that is. This is better than enlarging a list of kinds of
+ // irregular verbs as it was done in the past.
Other,
}
@@ -284,6 +290,33 @@ impl std::fmt::Display for Conjugation {
}
}
+impl Conjugation {
+ /// Returns a String containing how a conjugation would be displayed by also
+ /// considering the given 'kind' identifier. This way we can display 'other'
+ /// conjugations in a more natural way.
+ pub fn display_with_kind(&self, kind: &str) -> String {
+ if !matches!(self, Conjugation::Other) {
+ return format!("{}", self);
+ }
+
+ match kind {
+ "sum" => "irregular; like 'sum, esse, fuī, futūrus'",
+ "possum" => "irregular; like 'possum, posse, potuī'",
+ "eo" => "irregular; like 'eō, īre, iī, itum'",
+ "volo" => "irregular; like 'volō, velle, voluī'",
+ "nolo" => "irregular; like 'nōlō, nōlle, nōluī'",
+ "malo" => "irregular; like 'mālō, mālle, māluī'",
+ "fero" => "irregular; like 'ferō, ferre, tulī, lātum'",
+ "facio" => "3rd (-iō variants) and suppletive; like 'faciō, facere, fēcī, factum'",
+ "do" => "1st; irregular short ă in most forms",
+ "inquam" => "irregular, highly defective",
+ "aio" => "3rd (-iō variants); highly defective",
+ _ => "other",
+ }
+ .to_string()
+ }
+}
+
#[derive(Clone, Debug, Default)]
pub enum Language {
#[default]