]>
git.r.bdr.sh - rbdr/generador-de-insultos/blob - src/lib/grammar.js
1 import { Conjugator
} from '@jirimracek/conjugate-esp';
4 kVowels: ['a', 'e', 'i', 'o', 'u'],
7 export const pluralize = function (noun
) {
9 const lastLetter
= noun
[noun
.length
- 1];
11 if (lastLetter
=== 's') {
15 if (internals
.kVowels
.indexOf(lastLetter
) >= 0) {
22 export const conjugate
= async
function(verb
) {
24 const conjugator
= new Conjugator();
26 const conjugation
= await conjugator
.conjugate(verb
);
28 if (!conjugation
|| conjugation
.length
=== 0) {
29 console
.error('Could not conjugate: ', verb
);
30 throw new Error(`Could not conjugate: ${verb}`)
33 const presentIndicative
= conjugation
[0]
38 return presentIndicative
;
41 return verb
.replace(/r$/, '');