https://github.com/dhowe/rita4j
RiTa for Java
https://github.com/dhowe/rita4j
generative-art generative-text natural-language natural-language-generation natural-language-processing text-analysis
Last synced: 12 months ago
JSON representation
RiTa for Java
- Host: GitHub
- URL: https://github.com/dhowe/rita4j
- Owner: dhowe
- License: gpl-3.0
- Created: 2019-10-20T05:46:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-05T11:55:47.000Z (over 2 years ago)
- Last Synced: 2025-04-07T01:34:47.752Z (about 1 year ago)
- Topics: generative-art, generative-text, natural-language, natural-language-generation, natural-language-processing, text-analysis
- Language: Java
- Homepage: https://rednoise.org/rita
- Size: 7.51 MB
- Stars: 8
- Watchers: 4
- Forks: 7
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
 
## RiTa: tools for generative natural language
RiTa is implemented in Java and JavaScript, with a common [API](https://github.com/dhowe/rita4j/blob/master/README.md#api) for both, and is free/libre/open-source via the GPL license.
### Features in v2.0
* Smart lexicon search for words matching part-of-speech, syllable, stress and rhyme patterns
* Fast, heuristic algorithms for inflection, conjugation, stemming, tokenization, and more
* Letter-to-sound engine for feature analysis of arbitrary words (with/without lexicon)
* Integration of the [RiScript](https://observablehq.com/@dhowe/riscript) scripting language, designed for writers
* Powerful new options for generation via grammars and Markov chains
###
* For JavaScript, see [this repo](https://github.com/dhowe/ritajs) or use it with [npm](https://www.npmjs.com/package/rita) or [unpkg](https://unpkg.com/browse/rita/dist/)
* A simple [Processing example](#in-processing)
* A simple [Java example](#a-simple-example-java)
* For [Developers](#developing)
Note: Version 2.0 contains breaking changes! Please check the [release notes](https://rednoise.org/rita/#whats-new-wrapper)
### Installation
* Via [github packages](https://github.com/dhowe/rita4j/packages/)
* Via [maven central](https://search.maven.org/artifact/org.rednoise/rita)
* Or directly in maven:
```xml
org.rednoise
rita
2.4
```
## API
RiTa
RiMarkov
RiGrammar
RiTa.addTransform()
RiTa.alliterations()
RiTa.analyze()
RiTa.concordance()
RiTa.conjugate()
RiTa.evaluate()
RiTa.grammar()
RiTa.hasWord()
RiTa.isAbbrev()
RiTa.isAdjective()
RiTa.isAdverb()
RiTa.isAlliteration()
RiTa.isNoun()
RiTa.isPunct()
RiTa.isQuestion()
RiTa.isStopWord()
RiTa.isRhyme()
RiTa.isVerb()
RiTa.kwic()
RiTa.markov()
RiTa.pastPart()
RiTa.phones()
RiTa.pos()
RiTa.posInline()
RiTa.presentPart()
RiTa.pluralize()
RiTa.randomOrdering()
RiTa.randomSeed()
RiTa.randomWord()
RiTa.rhymes()
RiTa.search()
RiTa.sentences()
RiTa.singularize()
RiTa.soundsLike()
RiTa.spellsLike()
RiTa.stem()
RiTa.stresses()
RiTa.syllables()
RiTa.tokenize()
RiTa.untokenize()
addText()
completions()
generate()
probability()
probabilities()
size()
toString()
toJSON()
fromJSON()
addRule()
addRules()
expand()
removeRule()
toJSON()
toString()
fromJSON()
## RiScript
RiScript is a simple, writer-focused scripting language included in RiTa. It enables several generative primitives within plain text for expansion at runtime. RiScript primitives can be used as part of any [RiTa grammar](https://rednoise.org/rita/reference/RiTa/grammar/) or executed directly using [RiTa.evaluate()](https://rednoise.org/rita/reference/RiTa/evaluate/). For documentation, see [this interactive notebook](https://observablehq.com/@dhowe/riscript).
--------------------
### Developing
```sh
$ git clone https://github.com/dhowe/rita4j.git
$ cd rita4j
$ mvn install # when done, you should see "BUILD SUCCESS"
```
The project requires a minimum version of Java 8 and Maven 3.6 to build.
### Eclipse
1. Do steps above under **Developing**
2. In eclipse, File->Import->Maven->Existing Maven Projects and select your 'rita4j' folder
3. Right-click on project, and select 'Run-as' -> 'Maven install' or 'JUnit tests'
Please make contributions via [fork-and-pull](https://reflectoring.io/github-fork-and-pull/) - thanks!
--------------------
## A Simple Example (Java)
For online examples in JavaScript, see [this page](https://rednoise.org/rita/#examples)
1. Create a new Java project in Eclipse (or your IDE of choice)
2. Download [rita.jar](https://github-registry-files.githubusercontent.com/216313864/bd26cf80-1cad-11ec-9175-4bd56458eebc?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220319%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220319T092932Z&X-Amz-Expires=300&X-Amz-Signature=76f6397b84f722b45d62516d547d090047e67250ef398b4fe72b7ee2f455d9c1&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=216313864&response-content-disposition=filename%3Drita-2.4.501.jar&response-content-type=application%2Foctet-stream) and add it to the build path for the project. In eclipse: 'Project' > 'Properties' > 'Java Build Path' > 'Libraries' > 'Add External JARs...'
3. Create and run a new class, SimpleExample.java, with the following code:
```Java
import rita.*;
public class SimpleExample {
public static void main(String[] args) {
System.out.println(RiTa.analyze("The elephant took a bite!"));
}
}
```
## In Processing
To install:
1. Open Processing and select 'Sketch' menu > 'Import Library...' > 'Add Library...'
2. Search for 'RiTa' and then install it
Create an example sketch as follows (and/or see the included examples):
```java
import rita.*;
import java.util.*;
void setup() {
size(600, 200);
background(50);
textSize(20);
noStroke();
Map data = RiTa.analyze("The elephant took a bite!");
float y = 15;
for (Iterator it = data.keySet().iterator(); it.hasNext();) {
String key = (String) it.next();
text(key + ": " + data.get(key), 25, y += 26);
}
}
```
## Contributors
### Code Contributors
This project exists only because of the people who contribute. Thank you!
