{"id":18387816,"url":"https://github.com/dhowe/ritajs","last_synced_at":"2025-04-13T05:28:54.067Z","repository":{"id":204094747,"uuid":"711100673","full_name":"dhowe/ritajs","owner":"dhowe","description":"RiTa for JavaScript","archived":false,"fork":false,"pushed_at":"2025-03-20T15:00:48.000Z","size":5285,"stargazers_count":33,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-20T15:44:55.616Z","etag":null,"topics":["creative-coding","creative-writing","generative-art","natural-language","natural-language-generation","p5js-library","writing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dhowe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-28T08:05:38.000Z","updated_at":"2025-03-20T15:00:53.000Z","dependencies_parsed_at":"2023-11-02T06:27:45.779Z","dependency_job_id":"2b138561-ae1e-487d-b279-9c80a2cf36a6","html_url":"https://github.com/dhowe/ritajs","commit_stats":{"total_commits":279,"total_committers":2,"mean_commits":139.5,"dds":0.1577060931899642,"last_synced_commit":"a76d7aa90b963af650a2ae6dfc92bca377385eda"},"previous_names":["dhowe/rjs3"],"tags_count":110,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhowe%2Fritajs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhowe%2Fritajs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhowe%2Fritajs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhowe%2Fritajs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhowe","download_url":"https://codeload.github.com/dhowe/ritajs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248668794,"owners_count":21142741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["creative-coding","creative-writing","generative-art","natural-language","natural-language-generation","p5js-library","writing"],"created_at":"2024-11-06T01:28:06.555Z","updated_at":"2025-04-13T05:28:54.044Z","avatar_url":"https://github.com/dhowe.png","language":"JavaScript","funding_links":["https://opencollective.com/rita/donate"],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003c!--![ritajs](pen.jpg)--\u003e\n\n\n\u003ca href=\"https://github.com/dhowe/rjs3/actions\"\u003e\u003cimg src=\"https://github.com/dhowe/rjs3/actions/workflows/node.js.yml/badge.svg\" alt=\"ci tests\"\u003e\u003c/a\u003e \u003ca href=\"https://www.npmjs.com/package/rita\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/rita.svg\" alt=\"npm version\"\u003e\u003c/a\u003e \u003ca href=\"https://www.gnu.org/licenses/gpl-3.0.en.html\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-GPL-orange.svg\" alt=\"license\"\u003e\u003c/a\u003e\n\n\n## RiTa: tools for computational writing\n\nRiTa is implemented in JavaScript and Java, with a common [API](https://github.com/dhowe/rita4j/blob/master/README.md#api) for both, and is free/libre/open-source.\n\n### Features in v3.0\n\n* Smart lexicon search for words matching part-of-speech, syllable, stress and rhyme patterns\n* Fast, heuristic algorithms for inflection, conjugation, stemming, tokenization, and more\n* Letter-to-sound engine for feature analysis of arbitrary words (with/without lexicon)\n* Integration of the [RiScript](https://observablehq.com/@dhowe/riscript) scripting language, designed for writers, now built with the blazing fast [Chevrotain](https://chevrotain.io/) parser\n* New options for generation via grammars and Markov chains\n* Published in ESM, CommonJS and as an IIFE\n\nNote: version 3.0 contains breaking changes -- please check the [release notes](https://rednoise.org/rita/#whats-new)\n\n### Installation\n\n* For [esm](#an-esm-browser-sketch): ```import { RiTa } from \"https://esm.sh/rita\";```\n* For [node](#with-nodejs-and-npm): `$ npm install rita`  \n   ```let { RiTa }  = require('rita');```\n* For [browsers](#a-simple-browser-sketch): ```\u003cscript src=\"https://cdn.jsdelivr.net/npm/rita\"\u003e\u003c/script\u003e```\n* For [p5.js](#with-p5js): ```\u003cscript src=\"https://cdn.jsdelivr.net/npm/rita\"\u003e\u003c/script\u003e```\n* For [developers](#developing)\n\n\n### Example\n\n```javascript\nimport { RiTa } from \"https://esm.sh/rita\";\n\n// to analyze a sentence\nlet data = RiTa.analyze(\"The elephant took a bite!\");\nconsole.log(data);\n\n// to load a grammar\nlet grammar = RiTa.grammar(rulesObjectOrJSON);\nconsole.log(grammar.expand());\n```\n\n## API\n\n  \u003ctable cellspacing=\"0\" cellpadding=\"0\" style=\"vertical-align: top;\"\u003e\n   \u003ctr\u003e\n    \u003cth colspan=2 style=\"vertical-align: top;text-align: left; padding-left: 12px\"\u003eRiTa\n    \u003c/th\u003e\n    \u003cth colspan=1 style=\"vertical-align: top;text-align: left;\"\u003eRiMarkov\u003c/th\u003e\n    \u003cth colspan=1 style=\"vertical-align: top;text-align: left;\"\u003eRiGrammar\u003c/th\u003e\n   \u003c/tr\u003e\n   \u003ctr\u003e\n    \u003ctd style=\"vertical-align: top; padding-top: 15px\"\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/addTransform/index.html\"\u003eRiTa.addTransform()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/alliterations/index.html\"\u003eRiTa.alliterations()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/analyze/index.html\"\u003eRiTa.analyze()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/concordance/index.html\"\u003eRiTa.concordance()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/conjugate/index.html\"\u003eRiTa.conjugate()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/evaluate/index.html\"\u003eRiTa.evaluate()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/grammar/index.html\"\u003eRiTa.grammar()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/hasWord/index.html\"\u003eRiTa.hasWord()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/isAbbrev/index.html\"\u003eRiTa.isAbbrev()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/isAdjective/index.html\"\u003eRiTa.isAdjective()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/isAdverb/index.html\"\u003eRiTa.isAdverb()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/isAlliteration/index.html\"\u003eRiTa.isAlliteration()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/isNoun/index.html\"\u003eRiTa.isNoun()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/isPunct/index.html\"\u003eRiTa.isPunct()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/isQuestion/index.html\"\u003eRiTa.isQuestion()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/isStopWord/index.html\"\u003eRiTa.isStopWord()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/isRhyme/index.html\"\u003eRiTa.isRhyme()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/isVerb/index.html\"\u003eRiTa.isVerb()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/kwic/index.html\"\u003eRiTa.kwic()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/markov/index.html\"\u003eRiTa.markov()\u003c/a\u003e\u003cbr/\u003e\n    \u003c/td\u003e\n    \u003ctd style=\"vertical-align: top; padding-top: 15px\"\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/pastPart/index.html\"\u003eRiTa.pastPart()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/phones/index.html\"\u003eRiTa.phones()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/pos/index.html\"\u003eRiTa.pos()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/posInline/index.html\"\u003eRiTa.posInline()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/presentPart/index.html\"\u003eRiTa.presentPart()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/pluralize/index.html\"\u003eRiTa.pluralize()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/randomOrdering/index.html\"\u003eRiTa.randomOrdering()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/randomSeed/index.html\"\u003eRiTa.randomSeed()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/randomWord/index.html\"\u003eRiTa.randomWord()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/rhymes/index.html\"\u003eRiTa.rhymes()\u003c/a\u003e\u003cbr/\u003e\n      \u003c!--a href=\"./RiTa/scripting/index.html\"\u003eRiTa.scripting()\u003c/a\u003e\u003cbr/--\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/search/index.html\"\u003eRiTa.search()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/sentences/index.html\"\u003eRiTa.sentences()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/singularize/index.html\"\u003eRiTa.singularize()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/soundsLike/index.html\"\u003eRiTa.soundsLike()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/spellsLike/index.html\"\u003eRiTa.spellsLike()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/stem/index.html\"\u003eRiTa.stem()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/stresses/index.html\"\u003eRiTa.stresses()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/syllables/index.html\"\u003eRiTa.syllables()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/tokenize/index.html\"\u003eRiTa.tokenize()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiTa/untokenize/index.html\"\u003eRiTa.untokenize()\u003c/a\u003e\u003cbr/\u003e\n      \u003c!--a href=\"./RiTa/VERSION/index.html\"\u003eRiTa.VERSION\u003c/a\u003e\u003cbr/--\u003e\n    \u003c/td\u003e\n    \u003ctd style=\"vertical-align: top !important; padding-top: 15px; min-width: 125px\"\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiMarkov/addText/index.html\"\u003eaddText()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiMarkov/completions/index.html\"\u003ecompletions()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiMarkov/generate/index.html\"\u003egenerate()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiMarkov/probability/index.html\"\u003eprobability()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiMarkov/probabilities/index.html\"\u003eprobabilities()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiMarkov/size/index.html\"\u003esize()\u003c/a\u003e\u003cbr/\u003e\n\u003c!--       \u003ca href=\"https://rednoise.org/rita/reference/RiMarkov/toString/index.html\"\u003etoString()\u003c/a\u003e\u003cbr/--\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiMarkov/toJSON/index.html\"\u003etoJSON()\u003c/a\u003e\u003cbr/\u003e \n      \u003ca href=\"https://rednoise.org/rita/reference/RiMarkov/fromJSON/index.html\"\u003efromJSON()\u003c/a\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\n    \u003c/td\u003e\n    \u003ctd style=\"vertical-align: top !important; padding-top: 15px; min-width: 125px\"\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiGrammar/addRule/index.html\"\u003eaddRule()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiGrammar/expand/index.html\"\u003eexpand()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiGrammar/removeRule/index.html\"\u003eremoveRule()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiGrammar/addRules/index.html\"\u003esetRules()\u003c/a\u003e\u003cbr/\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiGrammar/toJSON/index.html\"\u003etoJSON()\u003c/a\u003e\u003cbr/\u003e\n\u003c!--       \u003ca href=\"https://rednoise.org/rita/reference/RiGrammar/toString/index.html\"\u003etoString()\u003c/a\u003e\u003cbr/--\u003e\n      \u003ca href=\"https://rednoise.org/rita/reference/RiGrammar/fromJSON/index.html\"\u003efromJSON()\u003c/a\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e \n    \u003c/td\u003e\n \u003c/tr\u003e\n\u003c/table\u003e\n\n## RiScript\n\n[RiScript](https://github.com/dhowe/riscript) (the minor language that powers RiTa) was designed specifically for writers working with code. RiScript primitives (choices, symbols, gates, transforms, etc) 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) on observable.\n\n\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n\n## Developing\nTo install/build the library and run tests (with npm/mocha and node v14.x):\n```sh\n\n$ git clone https://github.com/dhowe/ritajs.git\n$ cd ritajs \n$ npm install\n$ npm run build \n$ npm test\n\n```\nIf all goes well, you should see a list of successful tests and find the library built in 'dist'\n\n\u003cbr\u003e\n\nPlease make contributions via [fork-and-pull](https://reflectoring.io/github-fork-and-pull/) - thanks!\n\n---------------\n\n\u0026nbsp;\n\n### Visual Studio Code\n\nOnce you have things running with npm/mocha/tsup, you might also try [VSCode](https://code.visualstudio.com/).\n\nHere you can see the tests in the VSCode _Testing_ view\n\n\u003cimg width=\"800\" alt=\"vscode-tests\" src=\"https://github.com/dhowe/ritajs/assets/737638/103665fb-3dc8-448b-9ed3-d706be6797fc\"\u003e\n\n\u0026nbsp;\n\n## About\n\n* Author:   [Daniel C. Howe](http://rednoise.org/daniel)\n* Web Site:          [https://rednoise.org/rita](http://rednoise.org/rita)\n* Github Repo:       [https://github.com/dhowe/rita](https://github.com/dhowe/rita)\n* Issues:       [https://github.com/dhowe/rita/issues](https://github.com/dhowe/rita/issues)\n* Reference:    [https://rednoise.org/rita/reference](http://rednoise.org/rita/reference)\n* RiScript:    [https://github.com/dhowe/riscript](https://github.com/dhowe/riscript)\n\n\u0026nbsp;\n\n## Quick Start \n\n#### A simple browser sketch\n \nCreate a new file on your desktop called 'test.html' with the following lines, save and drag it into a browser:\n\n```html\n\u003chtml\u003e\n  \u003cscript src=\"https://cdn.jsdelivr.net/npm/rita\"\u003e\u003c/script\u003e\n  \u003cscript\u003e\n    window.onload = function() {\n      let words = RiTa.tokenize(\"The elephant took a bite!\");\n      document.getElementById(\"content\").innerHTML = words;\n    };\n  \u003c/script\u003e\n  \u003cdiv id=\"content\" width=200 height=200\u003e\u003c/div\u003e\n\u003chtml\u003e\n```\n\n#### An ESM browser sketch\n \nCreate a new file on your desktop called 'test.html' with the following lines, save and drag it into a browser:\n\n```html\n\u003chtml\u003e\n\u003cbody\u003e\n  \u003cdiv id=\"content\" width=200 height=200\u003e\u003c/div\u003e\n  \u003cscript type=\"module\"\u003e\n    import { RiTa } from \"https://esm.sh/rita\";\n    let words = RiTa.tokenize(\"The elephant took a bite!\");\n    document.getElementById(\"content\").innerHTML = words;\n  \u003c/script\u003e\n\u003c/body\u003e\n\u003chtml\u003e\n```\n\n#### With [p5.js](http://p5js.org/)\n \nCreate a new file on your desktop called 'test.html' with the following lines, save and drag it into a browser:\n\n```html\n\u003chtml\u003e\n  \u003cscript src=\"https://cdn.jsdelivr.net/npm/p5\"\u003e\u003c/script\u003e\n  \u003cscript src=\"https://cdn.jsdelivr.net/npm/rita\"\u003e\u003c/script\u003e\n  \u003cscript\u003e\n  function setup() {\n\n    createCanvas(200,200);\n    background(245);\n    textAlign(CENTER);\n    textSize(20);\n\n    let words = RiTa.tokenize(\"The elephant took a bite!\")\n    for (let i=0; i \u003c words.length; i++) {\n        text(words[i], 100, 50 + i*20);\n    }\n  }\n  \u003c/script\u003e\n\u003c/html\u003e\n```\nIf you already have a sketch, simply add `\u003cscript src=\"https://cdn.jsdelivr.net/npm/rita\"\u003e\u003c/script\u003e` to your index.html to include RiTa.\n\n\n#### With [node.js](http://nodejs.org/) and [npm](https://www.npmjs.com/)\n \nTo install: `$ npm install rita`\n\n```javascript\nlet RiTa = require('rita');\nlet data = RiTa.analyze(\"The elephant took a bite!\");\nconsole.log(data);\n```\n\n\u0026nbsp;\n\n## Contributors\n\n### Code Contributors\n\nThis project exists only because of the people who contribute. Thank you!\n\u003ca href=\"https://github.com/dhowe/RiTa/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/RiTa/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\n\n### Financial Contributors\n\u003ca href=\"https://opencollective.com/rita/donate\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://opencollective.com/rita/contribute/button@2x.png?color=blue\" width=300 /\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhowe%2Fritajs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhowe%2Fritajs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhowe%2Fritajs/lists"}