This package has been deprecated

Author message:

WARNING: This project has been renamed to satzbau. Install using satzbau instead.

nlg-german
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

nlg-german

simple natural language generator (german)

License: MIT

· Report Bug / Request Feature ·

Table of Contents

About

A simple tool to generate german texts.

It allows you to:

  • decline words (including articles)
  • automatically pick synonyms for words
  • automatically render lists as text
  • a handy template string syntax to format sentences
  • create template functions to render advances sentences

It's pretty small and does not need a dictionary.

However, it can't (yet):

  • automatically detect cases
  • decline anything other than articles and nouns (e.g. adjectives)
  • conjugate verbs

Install

NPM:

yarn install nlg-german

Usage

Define words

import { noun } from 'nlg-german';

// provide the noun function with a string, containing:
// 1. an article
// 2. the word in nominative singular, plural and genitive singular
const phone = noun('das telefon, die telefone, des telefons');

// or if you're lazy:
const phone = noun('das telefon,-e,-s');

Example

import { noun, sentence, synonyms } from 'nlg-german';

cconst car = synonyms(
	noun('das auto, die autos, des autos'),
	noun('der PKW, die PKWs, des PKWs'),
	noun('der wagen, die wagen, des wagens'),
	noun('die karre, die karren, der karre')
).specific();

const animals = [
	noun('der elefant,-en,-en'),
	noun('die maus,mäuse,-'),
	noun('der kakadu,-s,-s'),
];

const door = noun('die tür,-en,-').specific();

const move = variants('eilte', 'rannte', 'lief');

const heEntersCar = variants(
	sentence`er stieg in ${car.accusative()}`,
	sentence`eilig betrat er ${car.accusative()}`,
	sentence`er öffnete ${door.accusative()} ${car.genitive()}`,
	sentence`er ${move} zu ${car.dative()}`
);

console.log(heEntersCar.write());
console.log(heEntersCar.write());
console.log(heEntersCar.write());
console.log(heEntersCar.write());
console.log(heEntersCar.write());

console.log(sentence`${animals} erwarteten ihn bereits...`.write());

/*
	Output:
	Eilig betrat er den Wagen.
	Er stieg in die Karre.
	Er öffnete die Tür des PKWs.
	Er rannte zu dem Auto.
	Er öffnete die Tür des Wagens.
	Ein Elefant, eine Maus und ein Kakadu erwarteten ihn bereits...
*/

Run tests

yarn run test

Contact

👤 Timo Bechtel

🤝 Contributing

Contributions, issues and feature requests are welcome!

  1. Check issues
  2. Fork the Project
  3. Create your Feature Branch (git checkout -b feat/AmazingFeature)
  4. Test your changes yarn run test
  5. Commit your Changes (git commit -m 'feat: add amazingFeature')
  6. Push to the Branch (git push origin feat/AmazingFeature)
  7. Open a Pull Request

Commit messages

This project uses semantic-release for automated release versions. So commits in this project follow the Conventional Commits guidelines. I recommend using commitizen for automated commit messages.

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

/nlg-german/

    Package Sidebar

    Install

    npm i nlg-german

    Weekly Downloads

    0

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    118 kB

    Total Files

    18

    Last publish

    Collaborators

    • timobechtel