From 3980cc7c38f043c53c9811078101d7a78de3f8d1 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Thu, 29 Jan 2026 22:03:10 +0100 Subject: words: allow the creation of irregular words MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- lib/mihi/src/lib.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'lib') 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] -- cgit v1.2.3