#latin #classical #dictionary #word #botanical #decliner #conjugator

botanical-latin

古典/植物拉丁语的词尾变化/动词变位/屈折词

7 个版本

0.0.7 2024年7月16日
0.0.6 2024年7月16日

#440文本处理

每月 48 次下载

MIT/Apache

1.5MB
1K SLoC

botanical-latin "古典/植物拉丁语的词尾变化/动词变位/屈折词."

Crates.io Documentation License Downloads

该 crate 提供古典/植物拉丁语的词尾变化/动词变位/屈折词功能。

它使用从维基词典提取的数据创建词典,从中提取单词。如果词典中没有找到单词,它会根据词根(及名词的性别)进行推测,并相应地进行词尾变化。目前名词和形容词几乎已完全实现,而动词仅支持现在时态,需要更多的改进,但应该已适用于许多任务。

示例用法

use botanical_latin::*;
fn main() {
    // Load the Latin conjugator with csv dictionaries, provided in the github repo
    let inflector = Latin::new(
        "nouns.csv".into(),
        "adjectives.csv".into(),
        "verbs.csv".into(),
    );

    // Optionally define a ComplexNoun to decline a Noun phrase that can include multiple adjectives and nouns in apposition
    let complexik = ComplexNoun {
        head_noun: "lorica".into(),
        adjective: vec!["hamatus".into(), "grandis".into()],
        adposition_noun: vec!["manica".into()],
    };

    // Inflect the complex noun as so. Returns a String
    let complex = inflector.complex_noun(&complexik, &Case::Abl, &Number::Singular);
    println!("{:#?}", complex);
    //Output: "lorica manica hamata grandi"

    // To conjugate a noun by itself use the noun() function from the inflector,
    // it outputs a tuple that contains the inflected string as the first(0th) element, and the Gender as the second element
    let noun = inflector.noun("agricola", &Case::Acc, &Number::Plural);
    println!("{:#?}", noun.0);
    //Output: "agricolas"

    //Adjectives are similar to nouns, but require an additional Gender argument. Returns an inflected String
    let adj = inflector.adjective("integer", &Case::Nom, &Number::Singular, &Gender::Feminine);
    println!("{:#?}", adj);
    //Output: "integra"

    //You can guess nouns and adjectives without instantiating the conjugator with dictionaries if you so desire.
    // But instantiating with the csv dictionaries gives a superior result.
    let guessed_adjective = Latin::guess_adjective(
        "schoenoides",
        &Case::Gen,
        &Number::Plural,
        &Gender::Feminine,
    );
    println!("{:#?}", guessed_adjective);
    // Output: "schoenoidum"

    let guessed_noun = Latin::guess_noun("hibiscus", &Case::Gen, &Number::Plural);
    println!("{:#?}", guessed_noun.0);
    //Output: "hibiscorum"

    // Some words can have the same nominative but different declension classes such as "os" can be either mouth or bone.
    // Append a 2 to the word_id to get the second conjugation, consult the csv dictionary for availability.
    let os1 = inflector.noun("os", &Case::Gen, &Number::Singular);
    println!("{:#?}", os1.0);
    //Output: "oris"
    let os2 = inflector.noun("os2", &Case::Gen, &Number::Singular);
    println!("{:#?}", os2.0);
    //Output: "ossis"
}

依赖关系

~1.5–2.3MB
~36K SLoC