german-words

Gender and case of German words

Usage no npm install needed!

<script type="module">
  import germanWords from 'https://cdn.skypack.dev/german-words';
</script>

README

German Words

Provides information on German words:

  • Gender of German words, : Korpus is neutral, Friede is masculine, etc.
  • Case declination of words: the genitive of Herr is Herren.

Use german-words-dict as the linguistic resource.

Installation

npm install german-words

Usage

const GermanWords = require('german-words');
const GermanWordsList = require('german-words-dict/dist/words.json');

// F
console.log(GermanWords.getGenderGermanWord(null, GermanWordsList, 'Gurke'));

// Herren
console.log(GermanWords.getCaseGermanWord(null, GermanWordsList, 'Herr', 'GENITIVE', 'S'));

// Gurken
console.log(GermanWords.getCaseGermanWord(null, GermanWordsList, 'Gurke', 'NOMINATIVE', 'P'));

getGenderGermanWord returns the gender M F or N, based on:

  • a exception linguistic resource (put null in general, only use it to override standard linguistic resource)
  • a linguistic resource (see german-words-dict)
  • the word at its root form

getCaseGermanWord returns the declined word based on:

  • a linguistic resource (see german-words-dict)
  • first string param which is the word at its root form
  • second string param which is the case (NOMINATIVE ACCUSATIVE DATIVE GENITIVE)
  • third string param which is the number (S or P)

Both throw an error when the word is not found.