Dynamic Template

The Dynamic Template algorithm is a text generation algorithm that is used to automatically imitate the global style of given input texts. Most notably, it is used in the TorfsBot twitterbot and the Dutch Humor Detection by Generating Negative Examples project.

The algorithm replaces low frequency words of a base text with other words from one or more other context texts having the same grammatical form. This effectively turns any text of the corpus into a template, which is dynamically determined based on the available context words from another line of the input corpus.

This implementation works with the Dutch package of LanguageTool for labeling the part-of-speech tags.

You can read more about the algorithm on our TorfsBot paper or Dutch humor detection paper.

How to use

Dependencies

The following repositories need to be cloned in folders next to this repository, as they are dependencies of this project:

Running the generator

  1. Clone this repository, and also the dependencies listed above.
  2. Open the project in an IDE that supports Gradle, e.g. IntelliJ.
  3. Build the Gradle project from build.gradle.
  4. Run DynamicTemplateExecutor.java, which accepts file paths for the "base text" corpus and the "context words" corpus as its first and second arguments. The file should contain a JSON string array, e.g. ["this is a text", "this is another"]