制作者的介绍仅有上面的一句话。 更多详情请阅读仓库 README。 仓库 README ↗
正在加载完整 README。
查看完整 README ↗A modern TypeScript port of Whitaker's Words, a comprehensive Latin dictionary and morphological analyzer originally written in Ada by William Whitaker.
Given any Latin word form, the engine strips inflectional endings, matches stems against a 39,000-entry dictionary, and returns every possible parse: part of speech, declension/conjugation, case, number, gender, tense, voice, mood, and English meaning. It also supports English-to-Latin reverse lookup, enclitic/prefix/suffix stripping, spelling tricks for medieval and variant orthography, and unique irregular forms.
npm install whitakers-words
The whitakers-words/node entry point loads the bundled data files from disk automatically:
import { createEngine, formatWordAnalysis } from "whitakers-words/node";
const engine = createEngine();
// Parse a Latin word
const analysis = engine.parseWord("amare");
console.log(formatWordAnalysis(analysis));
// am.are V 1 1 PRES ACTIVE INF 0 X
// amo, amare, amavi, amatus V (1st) [XXXAO]
// love, like; fall in love with; be fond of; have a tendency to;
// ...
// English-to-Latin reverse lookup
const results = engine.searchEnglish("water");
// => [{ de: { stems: ["aqu", ...], mean: "water; sea, lake; ..." }, rank: 6 }, ...]
The main whitakers-words entry point is platform-agnostic (no fs or path imports). You provide the data file contents yourself: typically via fetch:
import { WordsEngine, formatWordAnalysis } from "whitakers-words";
const load = (url: string) => fetch(url).then((r) => r.text());
const [dictGen, dictSup, inflects, addons, uniques] = await Promise.all([
load("/data/DICTLINE.GEN"),
load("/data/DICTLINE.SUP"),
load("/data/INFLECTS.LAT"),
load("/data/ADDONS.LAT"),
load("/data/UNIQUES.LAT"),
]);
const dictline = `${dictGen}\n${dictSup}`;
const engine = WordsEngine.create({ dictline, inflects, addons, uniques });
console.log(engine.formatWord("aquam"));
The five data files are included in the npm package under data/. Concatenate DICTLINE.GEN and DICTLINE.SUP into a single dictline string (the Node entry point does this automatically). How you serve them is up to your setup (static assets, CDN, bundler plugin, etc.).
The package includes a whitakers command:
# Parse Latin words directly
npx whitakers "rem acu tetigisti"
# Interactive mode
npx whitakers
=> aquam
aqu.am N 1 1 ACC S C
aqua, aquae N (1st) F [XXXAO]
water; sea, lake; river, stream; rain, rainfall (pl.), rainwater; spa; urine;
# English-to-Latin mode
=> ~E
=> water
aqua, aquae N (1st) F [XXXAO]
water; sea, lake; river, stream; ...
# Switch back to Latin mode
=> ~L
Pipe-friendly: reads from stdin when not a TTY:
echo "saucia cura" | npx whitakers
WordsEngineThe main class. Created via WordsEngine.create(data) or the convenience createEngine() from whitakers-words/node.
| Method / Property | Description |
|---|---|
static create(data: WordsEngineData) | Create an engine from raw data file contents |
parseWord(word: string, nextWord?: string): WordAnalysis | Analyze a Latin word with optional lookahead for compound verbs |
searchEnglish(word: string, maxResults?: number): EnglishSearchResult[] | English-to-Latin reverse lookup |
parseLine(line: string): WordAnalysis[] | Parse a full line of Latin, detecting compound verbs across words |
formatLine(line: string): string | Parse and format a full line as human-readable text |
formatWord(word: string): string | Parse and format a single word as human-readable text |
dictionarySize: number | Number of dictionary entries (expect ~39,000) |
inflectionCount: number | Number of inflection rules (expect ~1,800) |
uniqueCount: number | Number of unique/irregular entries (expect ~76) |
addons: AddonsData | The parsed addons (prefixes, suffixes, tackons) |
trimOutput: boolean | Ada's Trim_Output (default true); false keeps archaic and uncommon inflections |
WordAnalysisReturned by parseWord(). Contains all possible interpretations of a word:
以上为 README 的开头部分。其余内容请阅读原文。 查看完整 README ↗