Skip to content

Decline and conjugate Latin nouns, verbs, adjectives, and adverbs

License

Notifications You must be signed in to change notification settings

hugo-t-b/scriptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

✏️ scriptor

JSR version JSR score Release workflow status MIT license GitHub issues TypeScript Bun Zod

Decline and conjugate Latin nouns, verbs, adjectives, and adverbs

πŸ“¦ Installation

Install scriptor from JSR using one of the following commands.

Bun

bunx jsr add @hugo-t-b/scriptor

Deno

deno add @hugo-t-b/scriptor

Node

npx jsr add @hugo-t-b/scriptor
yarn dlx jsr add @hugo-t-b/scriptor
pnpm dlx jsr add @hugo-t-b/scriptor

πŸš€ Usage

Basic usage

Pass the principal parts of a word to scriptor as a string or array. It will automatically detect the word's part of speech.

import scriptor from "@hugo-t-b/scriptor";

const fromString = scriptor("scriptor, scriptoris, m"); // Principal parts string
const fromArray = scriptor([ "scriptor", "scriptoris", "m" ]); // Principal parts array

scriptor will return an object with every (supported) form of the word, which can be traversed to obtain individual forms.

{
  nominative: {
    singular: "scriptor",
    plural: "scriptores"
  },
  vocative: {
    singular: "scriptor",
    plural: "scriptores"
  },
  accusative: {
    singular: "scriptorem",
    plural: "scriptores"
  },
  ...
}

Tip

The full list of supported forms and principal parts can be found in the support section.

Return types

The expected return type can be passed to scriptor as a generic for better intellisense.

import scriptor, { type Noun } from "@hugo-t-b/scriptor";
const declined = scriptor<Noun>("scriptor, scriptoris, m");

I-stems and irregular forms

An optional options argument can be used to specify whether a third declension noun is i-stem (scriptor can only automatically detect some neuter i-stems).

import scriptor from "@hugo-t-b/scriptor";

const declined = scriptor("ars, artis, f", {
  iStem: true
});

console.log(declined.genitive.plural); //=> "artium"

To correctly decline/conjugate words that are generally regular with some irregular forms, the overrides option can be used. Forms that are not specified in overrides will not change.

import scriptor from "@hugo-t-b/scriptor";

const conjugated = scriptor("duco, ducere, duxi, ductus", {
  overrides: { imperative: { active: { present: { singular: { second: "duc" } } } } }
});

console.log(conjugated.imperative.active.present.singular.second); //=> "duc"
console.log(conjugated.imperative.active.present.plural.second); //=> "ducite"

For words with irregular principle parts, use the creator function for the specific part of speech. The principal parts must be passed as an array without macrons. Many of the returned forms will be incorrect, however the overrides option can be used to increase their accuracy.

import createVerb from "@hugo-t-b/scriptor/verbs";
const conjugated = createVerb([ "sum", "esse", "fui" ]);

Recursive usage

Some of the forms that scriptor returns are the principal parts of a distinct derived word (e.g., participles, comparative and superlative adjectives, etc.). To access specific forms of these words, they must be passed back to scriptor.

import scriptor from "@hugo-t-b/scriptor";

const conjugated = scriptor("scribo, scribere, scripsi, scriptus");
const ppp = conjugated.participle.passive.perfect;

console.log(ppp); //=> "scriptus, scripta, scriptum"

const declinedPPP = scriptor(ppp);
const nomMascSg = declinedPPP.nominative.masculine.singular;

console.log(nomMascSg); //=> "scriptus"

πŸ”₯ Examples

Latin greetings

import scriptor, { type Noun } from "@hugo-t-b/scriptor";

const greet = (name: string) => {
  const declinedName = scriptor<Noun>(name);
  const vocative = declinedName.vocative?.singular;
  return `salve, ${vocative}!`;
}

console.log(greet("Gaius, Gaii, m")); //=> "salve, Gai!"
console.log(greet("Metella, Metellae, f")); //=> "salve, Metella!"
console.log(greet("Marcus, Marci, m")); //=> "salve, Marce!"

Creating a motto

import scriptor, { type Adjective } from "@hugo-t-b/scriptor";

const makeMotto = (...qualities: string[]) => {
  return qualities
    .map(principalParts => scriptor<Adjective>(principalParts).comparative!)
    .map(comparative => scriptor<Adjective>(comparative).nominative?.neuter?.singular!)
    .join(", ");
};

console.log(makeMotto("citus, cita, citum", "altus, alta, altum", "fortis, forte"));
  //=> "citius, altius, fortius" (faster, higher, stronger)

console.log(makeMotto("callidus, callida, callidum", "sapiens, sapientis", "prudens, prudentis"));
  //=> "callidius, sapientius, prudentius" (smarter, wiser, more prudent)

πŸ“ƒ Support

Nouns

Principal parts

  1. Nominative singular
  2. Genitive singular
  3. Gender (m, f or n)

Declensions

1st 2nd 3rd 4th 5th
Masc./fem. βœ… βœ… βœ… ❌ ❌
Neuter 🚫 βœ… βœ… ❌ 🚫

Cases

Nominative Vocative Accusative Genitive Dative Ablative
βœ… βœ… βœ… βœ… βœ… βœ…

Verbs

Principal parts

  1. Present active indicative first person singular
  2. Present active infinitive
  3. Perfect active indicative first person singular
  4. Perfect passive participle nominative masculine singular (optional)

Warning

A verb's supine is not supported as the 4th principal part. Always use its perfect passive participle instead.

Conjugations

1st 2nd 3rd 3rd (-io) 4th
βœ… βœ… βœ… βœ… βœ…

Indicatives

Present Imperfect Future Perfect Pluperfect Future perfect
Active βœ… βœ… ❌ βœ… βœ… ❌
Passive ❌ ❌ ❌ ❌ ❌ ❌

Subjunctives

Present Imperfect Perfect Pluperfect
Active ❌ βœ… ❌ βœ…
Passive ❌ ❌ ❌ ❌

Imperatives

Present Future
Active βœ… ❌
Passive ❌ ❌

Infinitives

Present Perfect Future
Active βœ… βœ… ❌
Passive ❌ ❌ ❌

Participles

Present Perfect Future
Active βœ… 🚫 ❌
Passive 🚫 βœ… βœ…

Adjectives

Principal parts

The principal parts of an adjective vary based on the pattern it follows. The following examples are all valid:

  • bonus, bona, bonum
  • fortis, forte
  • ingens, ingentis
  • celer, celeris, celere

Supported forms

Nominative Vocative Accusative Genitive Dative Ablative
Masculine βœ… βœ… βœ… βœ… βœ… βœ…
Feminine βœ… βœ… βœ… βœ… βœ… βœ…
Neuter βœ… βœ… βœ… βœ… βœ… βœ…
Positive Comparative Superlative Adverb
βœ… βœ… βœ… βœ…

Adverbs

The only principal part for an adverb is its positive (normal) form.

Supported forms

Positive Comparative Superlative
βœ… βœ… βœ…

About

Decline and conjugate Latin nouns, verbs, adjectives, and adverbs

Resources

License

Stars

Watchers

Forks