GithubHelp home page GithubHelp logo

text_gen's Introduction

TextGen

Dart codecov

Generates text variations based on simple rules.

Quick Start

final textGenerator = GeneratedParser.parse('(The weather is {very really} nice today)');
final text = textGenerator!.buildVariant();

Getting Started

The use is as simple as it is easy. All you need to start with is a sentence or a phrase.

Let's take for example: The weather is very nice today

This sentence could actually be used like this now, even though the variation in it is rather small so far.
To be exact, there is exactly one variation yet: The weather is very nice today

Variation

To bring variation into the text, curly brackets are used in the text.
In this example, the word very could be varied quite well.

The weather is {very really} nice today

Parse

This string can now be understood by the parser in such a way that there is one sentence with very and one with really at the corresponding position.
In the code this could look like this:

final textGenerator = GeneratedParser.parse('The weather is {very really} nice today');

Generate

With this, these variants can now be generated lazily.
The variants are completely reproducible. I.e. with the same index you always get the same text.

String variant1 = textGenerator.buildVariant(0);    // The weather is very nice today
String variant2 = textGenerator.buildVariant(1);    // The weather is really nice today

Generate Randomly

This method can also randomly generate one of all possible variants on its own.
To do this, simply omit the index.

String randomVariant = textGenerator.buildVariant();    // The weather is really nice today
String randomVariant = textGenerator.buildVariant();    // The weather is very nice today
String randomVariant = textGenerator.buildVariant();    // The weather is very nice today
//...

Linked text

If the variation should consist of more than a single word, the text can be linked with round brackets, so that this is seen as a contiguous text.

(The weather is {(very nice) (so lovely)} today)

Summary

There are no limits to creativity and complexity. These three simple building blocks (text, variation, link) can be nested arbitrarily and used to build large text models.
So there can be a variation in a variation, which is part of a link, which in turn is part of a variation. And so on...

text_gen's People

Contributors

marc-r2 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.