A simple Node.js module that makes the agreement of French adjectives with gender and number. For instance beau becomes belles in feminine plural, and beaux in masculine plural.
It is based on rules and exceptions, not on an extensive list.
In French, the adjective can also vary depending on its position, if it is before or after the noun, and the kind of noun: un homme vieux / un vieil homme, un homme fou / un fol homme, un mol ectoplasme / un ectoplasme mou, un hamac vieux / un vieux hamac. This is also managed by this lib.
It exposes a single function,
agree, that takes up to 5 arguments:
- adjective (string, mandatory): the adjective not yet agreed
- gender (string, mandatory):
- number (string, mandatory):
- noun (string, optional): a string containing the noun; used only when the adjective is before the noun
- adjective is before noun (boolean, optional): set this last parameter to
trueif the noun is before the adjective; defaults to
false, as in French the adjective is most often after the noun
- contraction exceptions (optional): contracted words are managed automatically, like in un vieil homme, but you can provide exceptions or override default; provide a map where the noun is the key and where the value is an object having a boolean
npm install french-adjectives
var adjectives = require('french-adjectives'); // "belles" console.log( adjectives.agree('beau', 'F', 'P') ); // "vieil" console.log( adjectives.agree('vieux', 'M', 'S', 'homme', true) );
test.js for examples.
dependencies and licences
french-contractions: Checks how French words should be contracted (Apache 2.0)