{"id":18387928,"url":"https://github.com/dhowe/ritajs-v2","last_synced_at":"2025-05-12T13:43:51.278Z","repository":{"id":38453691,"uuid":"194439532","full_name":"dhowe/ritajs-v2","owner":"dhowe","description":"RiTa: generative language tools","archived":false,"fork":false,"pushed_at":"2024-08-26T12:27:27.000Z","size":13053,"stargazers_count":103,"open_issues_count":21,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T22:41:23.534Z","etag":null,"topics":["generative-text","natural-language","rita","text-analysis"],"latest_commit_sha":null,"homepage":"https://rednoise.org/rita","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":".github/FUNDING.yml","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},"funding":{"open_collective":"rita"}},"created_at":"2019-06-29T19:01:35.000Z","updated_at":"2024-08-18T15:23:19.000Z","dependencies_parsed_at":"2024-12-23T20:11:57.773Z","dependency_job_id":"6d2e0828-44b7-4395-9083-8b3ad7a0e988","html_url":"https://github.com/dhowe/ritajs-v2","commit_stats":{"total_commits":1381,"total_committers":9,"mean_commits":"153.44444444444446","dds":"0.20926864590876182","last_synced_commit":"76b9c541f0bdaa7facba143c14e28c8d9f8e985a"},"previous_names":["dhowe/ritajs-v2"],"tags_count":148,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhowe%2Fritajs-v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhowe%2Fritajs-v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhowe%2Fritajs-v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhowe%2Fritajs-v2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhowe","download_url":"https://codeload.github.com/dhowe/ritajs-v2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253749635,"owners_count":21958157,"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":["generative-text","natural-language","rita","text-analysis"],"created_at":"2024-11-06T01:29:22.117Z","updated_at":"2025-05-12T13:43:51.130Z","avatar_url":"https://github.com/dhowe.png","language":"JavaScript","funding_links":["https://opencollective.com/rita","https://opencollective.com/rita/donate"],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"http://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 \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 \u003c!--[![](https://data.jsdelivr.com/v1/package/npm/rita/badge)](https://www.jsdelivr.com/package/npm/rita)--\u003e [![CDNJS](https://img.shields.io/cdnjs/v/rita.svg)](https://cdnjs.com/libraries/rita/) \n\n\n## RiTa: tools for generative natural language\n\nRiTa 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.\n\n### Features in v2.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\n* New options for generation via grammars and Markov chains\n\nNote: version 2.0 contains breaking changes -- please check the [release notes](https://rednoise.org/rita/#whats-new-wrapper)\n\n### Installation\n\n* For node: `npm install rita`\n* For [browsers](#a-simple-sketch): ```\u003cscript src=\"https://unpkg.com/rita\"\u003e\u003c/script\u003e```\n* For [developers](#developing)\n\n### Example (node)\n\n```javascript\nlet RiTa = require('rita');\n\n// to find rhymes\nlet rhymes = RiTa.rhymes('sweet');\nconsole.log(rhymes);\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(jsonRules);\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      \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/addRules/index.html\"\u003eaddRules()\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/toJSON/index.html\"\u003etoJSON()\u003c/a\u003e\u003cbr/\u003e\n      \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\nRiScript 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).\n\n\u003cbr\u003e\n\n\u003chr\u003e\n\n\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 run 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\nDuring development it is faster to run tests directly on the source, rather then the built library:\n```sh\n$ npm run test.src\n```\n\nYou can also watch the source code and build automatically on any change:\n```sh\n$ npm run watch.src\n```\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, you might also try [VSCode](https://code.visualstudio.com/).\n\nSome of the following extensions may also be useful:\n\n* hbenl.vscode-mocha-test-adapter\n* hbenl.vscode-test-explorer\n* ms-vscode.test-adapter-converter\n\nHere you can see the tests in the VSCode _Testing_ view\n\n\u003cimg width=\"800\" alt=\"vscode-tests\" src=\"https://user-images.githubusercontent.com/737638/166626482-bd28d9fa-b300-4b26-b2d7-7ecb6cf31866.png\"\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\n\u0026nbsp;\n\n## Quick Start \n\n#### A simple 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://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js\"\u003e\u003c/script\u003e\n  \u003cscript src=\"https://unpkg.com/rita\"\u003e\u003c/script\u003e\n  \u003cscript\u003e\n    window.onload = function() {\n      let words = RiTa.tokenize(\"The elephant took a bite!\");\n      $('#content').text(words);\n    };\n  \u003c/script\u003e\n  \u003cdiv id=\"content\" width=200 height=200\u003e\u003c/div\u003e\n\u003chtml\u003e\n```\n\n#### With [p5.js](http://p5js.org/)\n \nCreate 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:\n\n```html\n\u003chtml\u003e\n  \u003cscript src=\"https://unpkg.com/p5\"\u003e\u003c/script\u003e\n  \u003cscript src=\"https://unpkg.com/rita\"\u003e\u003c/script\u003e\n  \u003cscript\u003e\n  function setup() {\n\n    createCanvas(200,200);\n    background(50);\n    textSize(20);\n    noStroke();\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], 50, 50 + i*20);\n    }\n  }\n  \u003c/script\u003e\n\u003c/html\u003e\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-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhowe%2Fritajs-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhowe%2Fritajs-v2/lists"}