From f13072f2c4a65e5d0e40b3df53bd827b7e5e7b06 Mon Sep 17 00:00:00 2001 From: Daniel Howe Date: Wed, 8 Nov 2023 16:40:16 +0800 Subject: [PATCH] Update README.md --- README.md | 254 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 252 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ff043d6..179d63c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,252 @@ -# rjs3 -rjs3 +[![Build Status](https://travis-ci.org/dhowe/RiTaJS.svg?branch=master)](https://travis-ci.org/dhowe/ritajs)[![Unit Tests](https://github.com/dhowe/ritajs/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/dhowe/ritajs/actions?query=workflow%3A%22unit+tests%22) license npm version [![CDNJS](https://img.shields.io/cdnjs/v/rita.svg)](https://cdnjs.com/libraries/rita/) + + +## 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 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](https://observablehq.com/@dhowe/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](https://rednoise.org/rita/#whats-new-wrapper) + +### Installation + +* For node: `npm install rita` +* For [browsers](#a-simple-sketch): `````` +* For [developers](#developing) + +### Example (node) + +```javascript +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 + + + + + + + + + + + + + +
RiTa + RiMarkovRiGrammar
+ 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 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](https://rednoise.org/rita/reference/RiTa/grammar/) or executed directly using [RiTa.evaluate()](https://rednoise.org/rita/reference/RiTa/evaluate/). For more info, see [this interactive notebook](https://observablehq.com/@dhowe/riscript). + +
+ +
+ +
+ +## Developing +To install/build the library and run tests (with npm/mocha and node v14.x): +```sh + +$ 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' + +
+ +During development it is faster to run tests directly on the source, rather then the built library: +```sh +$ npm run test.src +``` + +You can also watch the source code and build automatically on any change: +```sh +$ npm run watch.src +``` + +Please make contributions via [fork-and-pull](https://reflectoring.io/github-fork-and-pull/) - thanks! + +--------------- + +  + +### Visual Studio Code + +Once you have things running with npm/mocha, you might also try [VSCode](https://code.visualstudio.com/). + +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 + +vscode-tests + +  + +## About + +* Author: [Daniel C. Howe](http://rednoise.org/daniel) +* Web Site: [https://rednoise.org/rita](http://rednoise.org/rita) +* Github Repo: [https://github.com/dhowe/rita](https://github.com/dhowe/rita) +* Issues: [https://github.com/dhowe/rita/issues](https://github.com/dhowe/rita/issues) +* Reference: [https://rednoise.org/rita/reference](http://rednoise.org/rita/reference) + +  + +## 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 + + + + +
+ +``` + +#### With [p5.js](http://p5js.org/) + +Create a new file on your desktop called 'test.html' and download the latest rita.js from [here](http://rednoise.org/rita/download/rita.min.js), add the following lines, save and drag it into a browser: + +```html + + + + + +``` + +#### With [node.js](http://nodejs.org/) and [npm](https://www.npmjs.com/) + +To install: `$ npm install rita` + +```javascript +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 + + +