past_tense

Function past_tense 

Source
pub fn past_tense(verb: &VerbEntry) -> String
Expand description

Computes the past tense form of a verb.

Returns the irregular form if one is defined in the verb’s forms map under the "past" key. Otherwise, applies English past tense rules:

  • Ends in -e → append -d (“love” → “loved”)
  • Consonant + y → replace y with -ied (“carry” → “carried”)
  • Vowel + y (-ay, -ey, -oy, -uy) → append -ed (“play” → “played”)
  • Default → append -ed (“walk” → “walked”)

§Arguments

  • verb - The verb entry containing the lemma and optional irregular forms.

§Examples

use logicaffeine_lexicon::runtime::{VerbEntry, past_tense};
use std::collections::HashMap;

let walk = VerbEntry {
    lemma: "walk".to_string(),
    class: "Activity".to_string(),
    forms: HashMap::new(),
    features: vec![],
};
assert_eq!(past_tense(&walk), "walked");

let run = VerbEntry {
    lemma: "run".to_string(),
    class: "Activity".to_string(),
    forms: [("past".to_string(), "ran".to_string())].into(),
    features: vec![],
};
assert_eq!(past_tense(&run), "ran");