Skip to content

Commit

Permalink
šŸ› fix(verbs): do not output perfect passive participle if 4th principā€¦
Browse files Browse the repository at this point in the history
ā€¦al part not provided
  • Loading branch information
hugo-t-b committed Jul 20, 2024
1 parent c8ee9fb commit d3ebf30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions tests/verbs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,5 +250,6 @@ describe("Participle", () => {
expect(find(traho)).toBe("tractus, tracta, tractum");
expect(find(fugio)).toBe("fugitus, fugita, fugitum");
expect(find(invenio)).toBe("inventus, inventa, inventum");
expect(saevio.participle?.passive).not.toHaveProperty("perfect");
});
});
6 changes: 4 additions & 2 deletions verbs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import deepMapValues from "just-deep-map-values";
import extend from "just-extend";
import formatStringTemplate from "string-template";
import { getConjugation, PrincipalParts, type Shape as VerbShape } from "./utils";
import verbTemplate from "./template";
import * as templates from "./template";
import { z } from "zod";

const Overrides: z.ZodType<VerbShape, z.ZodTypeDef, VerbShape | undefined> = z.record(z.string(), z.unknown()).default({});
Expand Down Expand Up @@ -30,6 +30,8 @@ export default (principalParts: z.infer<typeof PrincipalParts>, optionsInput?: V
const presentStemB = conjugation >= 3 ? `${presentActiveIndicative.slice(0, -1)}u` : presentStem;
const presentStemC = conjugation > 3 ? `${presentActiveIndicative.slice(0, -1)}e` : presentStem;

const verbTemplate = perfectPassiveStem ? templates.withPerfectPassiveStem : templates.withoutPerfectPassiveStem;

const verb = deepMapValues(verbTemplate, template => {
return formatStringTemplate(template, {
presentActiveIndicative,
Expand All @@ -43,4 +45,4 @@ export default (principalParts: z.infer<typeof PrincipalParts>, optionsInput?: V
});

return extend(true, verb, options.overrides) as VerbShape;
}
};
13 changes: 11 additions & 2 deletions verbs/template.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Shape as VerbShape } from "./utils";

export default {
export const withoutPerfectPassiveStem = {
indicative: {
active: {
present: {
Expand Down Expand Up @@ -106,7 +106,16 @@ export default {
participle: {
active: {
present: "{presentStemC}ns, {presentStemC}ntis"
},
}
}
} satisfies VerbShape;

export const withPerfectPassiveStem = {
...withoutPerfectPassiveStem,

participle: {
...withoutPerfectPassiveStem.participle,

passive: {
perfect: "{perfectPassiveStem}us, {perfectPassiveStem}a, {perfectPassiveStem}um"
}
Expand Down

0 comments on commit d3ebf30

Please sign in to comment.