Skip to content

Commit

Permalink
✨ feat(scriptor): support all forms of an adjective
Browse files Browse the repository at this point in the history
Adds comparative, superlative, and adverb forms
  • Loading branch information
hugo-t-b committed Jun 26, 2024
1 parent b5c0461 commit 4730985
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@
"erunt",
"ibus",
"isse",
"issima",
"issimum",
"issimus",
"isti",
"istis",
"ntis",
"orum"
"orum",
"rima",
"rimum",
"rimus"
]
}
10 changes: 6 additions & 4 deletions scriptor/tests/adjectives.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, test } from "bun:test";
import scriptor from "..";

const acer = "acer, acris, acre";
const aeger = "aeger, aegra, aegrum";
const celer = "celer, celeris, celere";
const felix = "felix, felicis";
Expand Down Expand Up @@ -433,9 +434,10 @@ describe("Neuter plural", () => {
});
});

test.todo("Comparative", () => {
test("Comparative", () => {
const form = "comparative";

expect(scriptor(acer, form)).toBe("acrior, acrius");
expect(scriptor(aeger, form)).toBe("aegrior, aegrius");
expect(scriptor(celer, form)).toBe("celerior, celerius");
expect(scriptor(fortis, form)).toBe("fortior, fortius");
Expand All @@ -444,9 +446,10 @@ test.todo("Comparative", () => {
expect(scriptor(liber, form)).toBe("liberior, liberius");
});

test.todo("Superlative", () => {
test("Superlative", () => {
const form = "superlative";

expect(scriptor(acer, form)).toBe("acerrimus, acerrima, acerrimum");
expect(scriptor(aeger, form)).toBe("aegerrimus, aegerrima, aegerrimum");
expect(scriptor(celer, form)).toBe("celerrimus, celerrima, celerrimum");
expect(scriptor(fortis, form)).toBe("fortissimus, fortissima, fortissimum");
Expand All @@ -455,8 +458,7 @@ test.todo("Superlative", () => {
expect(scriptor(liber, form)).toBe("liberrimus, liberrima, liberrimum");
});


test.todo("Adverb", () => {
test("Adverb", () => {
const form = "adverb";

expect(scriptor(aeger, form)).toBe("aegre");
Expand Down
33 changes: 29 additions & 4 deletions scriptor/utils/adjective.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { z } from "zod";

export const AdjectiveForm = z.tuple([
z.enum([ "nominative", "vocative", "accusative", "genitive", "dative", "ablative" ]),
z.enum([ "feminine", "masculine", "neuter" ]),
z.enum([ "singular", "plural" ])
export const AdjectiveForm = z.union([
z.tuple([
z.enum([ "nominative", "vocative", "accusative", "genitive", "dative", "ablative" ]),
z.enum([ "feminine", "masculine", "neuter" ]),
z.enum([ "singular", "plural" ])
]),

z.tuple([
z.enum([ "comparative", "superlative", "adverb" ])
])
]);

const PatternA = z.tuple([
Expand Down Expand Up @@ -197,4 +203,23 @@ export default class Adjective {
get ablative_neuter_plural() {
return this.ablative_masculine_plural;
}

get comparative() {
return `${this.#stem}ior, ${this.#stem}ius`;
}

get superlative() {
if (this.nominative_masculine_singular.endsWith("er")) {
return `${this.nominative_masculine_singular}rimus, ${this.nominative_masculine_singular}rima, ${this.nominative_masculine_singular}rimum`;
}

return this.#stem.endsWith("er")
? `${this.#stem}rimus, ${this.#stem}rima, ${this.#stem}rimum`
: `${this.#stem}issimus, ${this.#stem}issima, ${this.#stem}issimum`
}

get adverb() {
if (this.#pattern === "A") return `${this.#stem}e`;
return this.#stem.endsWith("nt") ? `${this.#stem}er` : `${this.#stem}iter`;
}
};

0 comments on commit 4730985

Please sign in to comment.