3.0.6 • Published 6 months ago

rjs3 v3.0.6

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
6 months ago

!--[![](https://data.jsdelivr.com/v1/package/npm/rita/badge)](https://www.jsdelivr.com/package/npm/rita)-- CDNJS

RiTa: tools for generative natural language

RiTa is implemented in JavaScript and Java, with a common API for both, and is free/libre/open-source via the GPL license.

Features in v3.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 scripting language, designed for writers
  • New options for generation via grammars and Markov chains
  • Published in ESM, CommonJS and as an IIFE

Note: version 3.0 contains breaking changes -- please check the release notes

Installation

  • For node: npm install rita
  • For browsers: <script src="https://unpkg.com/rita"></script>
  • For developers

Example (node)

let RiTa = require('rita');

// to analyze a sentence
let data = RiTa.analyze("The elephant took a bite!");
console.log(data);

// to load a grammar
let grammar = RiTa.grammar(jsonRules);
console.log(grammar.expand());

API

RiScript

RiScript is a writer-focused scripting language integrated with RiTa. It enables simple generative primitives within plain text for dynamic expansion at runtime. RiScript primitives can be used as part of any RiTa grammar or executed directly using RiTa.evaluate(). For more info, see this interactive notebook.

Developing

To install/build the library and run tests (with npm/mocha and node v14.x):

$ git clone https://github.com/dhowe/ritajs.git
$ cd ritajs 
$ npm install
$ npm run build 
$ npm run test

If all goes well, you should see a list of successful tests and find the library built in 'dist'

Please make contributions via fork-and-pull - thanks!


 

Visual Studio Code

Once you have things running with npm/mocha, you might also try VSCode.

Some of the following extensions may also be useful:

  • hbenl.vscode-mocha-test-adapter
  • hbenl.vscode-test-explorer
  • ms-vscode.test-adapter-converter

Here you can see the tests in the VSCode Testing view

 

About

 

Quick Start

A simple sketch

Create a new file on your desktop called 'test.html' with the following lines, save and drag it into a browser:

<html>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://unpkg.com/rita"></script>
  <script>
    window.onload = function() {
      let words = RiTa.tokenize("The elephant took a bite!");
      $('#content').text(words);
    };
  </script>
  <div id="content" width=200 height=200></div>
<html>

With p5.js

Create a new file on your desktop called 'test.html' and download the latest rita.js from here, add the following lines, save and drag it into a browser:

<html>
  <script src="https://unpkg.com/p5"></script>
  <script src="https://unpkg.com/rita"></script>
  <script>
  function setup() {

    createCanvas(200,200);
    background(50);
    textSize(20);
    noStroke();

    let words = RiTa.tokenize("The elephant took a bite!")
    for (let i=0; i < words.length; i++) {
        text(words[i], 50, 50 + i*20);
    }
  }
  </script>
</html>

With node.js and npm

To install: $ npm install rita

let RiTa = require('rita');
let data = RiTa.analyze("The elephant took a bite!");
console.log(data);

 

Contributors

Code Contributors

This project exists only because of the people who contribute. Thank you!

Financial Contributors

3.0.6

6 months ago

3.0.4

6 months ago

1.0.75

6 months ago

1.0.74

6 months ago

1.0.72

6 months ago

1.0.71

6 months ago

1.0.70

6 months ago

1.0.69

6 months ago

1.0.68

6 months ago

1.0.67

6 months ago

1.0.66

6 months ago

1.0.65

6 months ago

1.0.64

6 months ago

1.0.63

6 months ago

1.0.62

6 months ago

1.0.60

6 months ago

1.0.59

6 months ago

1.0.58

6 months ago

1.0.57

6 months ago

1.0.56

6 months ago

1.0.55

6 months ago

1.0.54

6 months ago

1.0.53

6 months ago

1.0.52

6 months ago

1.0.51

6 months ago

1.0.50

6 months ago

1.0.49

6 months ago

1.0.48

6 months ago

1.0.47

6 months ago

1.0.46

6 months ago

1.0.45

6 months ago

1.0.44

6 months ago

1.0.43

6 months ago

1.0.42

6 months ago

1.0.41

6 months ago

1.0.40

6 months ago

1.0.39

6 months ago

1.0.38

6 months ago

1.0.37

6 months ago

1.0.36

6 months ago

1.0.35

6 months ago

1.0.34

6 months ago

1.0.33

6 months ago

1.0.32

6 months ago

1.0.31

6 months ago

1.0.30

6 months ago

1.0.29

6 months ago

1.0.28

6 months ago

1.0.27

6 months ago

1.0.26

6 months ago

1.0.25

6 months ago

1.0.24

6 months ago

1.0.23

6 months ago

1.0.22

6 months ago

1.0.21

6 months ago

1.0.20

6 months ago

1.0.19

6 months ago

1.0.18

6 months ago

1.0.17

6 months ago

1.0.16

6 months ago

1.0.15

6 months ago

1.0.14

6 months ago

1.0.13

6 months ago

1.0.12

6 months ago

1.0.11

6 months ago

1.0.10

6 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

7 months ago