{"id":19489401,"url":"https://github.com/1j01/nonsensical","last_synced_at":"2025-10-26T21:09:21.422Z","repository":{"id":67696344,"uuid":"110214233","full_name":"1j01/nonsensical","owner":"1j01","description":"Generate grammatical sentences https://1j01.itch.io/nonsensical","archived":false,"fork":false,"pushed_at":"2018-10-23T16:37:54.000Z","size":112,"stargazers_count":14,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-21T10:04:39.337Z","etag":null,"topics":["dummy-data","dummy-text","english","english-grammar","lorem-ipsum","placeholder-text","sentence","sentence-generator","sentences"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/nonsensical","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1j01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-11-10T07:02:11.000Z","updated_at":"2024-05-23T21:29:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"f76157a3-004d-4ebe-b949-2b14ec1e6ad9","html_url":"https://github.com/1j01/nonsensical","commit_stats":{"total_commits":28,"total_committers":1,"mean_commits":28.0,"dds":0.0,"last_synced_commit":"f20ac47cdd6c043cf77bbf3bee2d6000b06f54ac"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1j01%2Fnonsensical","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1j01%2Fnonsensical/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1j01%2Fnonsensical/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1j01%2Fnonsensical/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1j01","download_url":"https://codeload.github.com/1j01/nonsensical/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250882388,"owners_count":21502300,"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":["dummy-data","dummy-text","english","english-grammar","lorem-ipsum","placeholder-text","sentence","sentence-generator","sentences"],"created_at":"2024-11-10T21:08:25.653Z","updated_at":"2025-10-26T21:09:21.293Z","avatar_url":"https://github.com/1j01.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Nonsensical\n\nGenerates English sentences that are somewhat grammatically correct, or at least grammatically structured.\n\n[Try it out on itch.io!](https://1j01.itch.io/nonsensical)\n\nThere are lots of lorem ipsum libraries, and [\"thematic dummy text\" generators](http://mashable.com/2013/07/11/lorem-ipsum/#VAftGtFa0iq9); there are Markov chain text generators.\nBut they're all lacking in structure, usually entirely.\nThere's [RNNs](https://en.wikipedia.org/wiki/Recurrent_neural_network), which [are cool](http://karpathy.github.io/2015/05/21/rnn-effectiveness/) and model structure, but they're much less accessible currently.\nI haven't found any webpages where you can train one, for instance.\n\nNonsensical gives you structure, you know, something to hold on to, a banister,\nand a banner, a banner with weird text written on it, that you can wave in the air.\n\n### Better than Markov chain text generators: it can be\n\n**Nonsensical** models the structure of a sentence,\ninspired by [Google's Natural Language Syntax API](https://cloud.google.com/natural-language/).\n\nThis way it can do subject–verb agreement,\nfor example \"The birds chirp\" vs \"The bird chirps\",\nand make articles and other determiners match up,\nfor example \"a/the bird\" vs \"some/those/the birds\",\nand follow other rules of English.\n\nAlthough with the random words it chooses acting as context,\nthe apparent structure might end up different than intended.\n\n### Sample Output\n\n\u003e A secret plot in the charming saddle block anesthesias slammed those lacrimal sacs.  \n\u003e An enlisted woman on the adductive pitch blackness navigated an animatism.  \n\u003e Some spatula-shaped floricultures on the trap destressed the bad park.  \n\u003e A fight in a Malaysian straightenned some rosy-colored flags.  \n\u003e The imbricated throat in an alarming fire brigade queried a Circassian.  \n\u003e Some affixal icicles in a wintertime erred some white yams.  \n\u003e The virtuous sweetener in the ambulatory vase glorifies a downmarket graveyard.  \n\u003e Those cherries in a flying iron boot pursue some Plautuses.  \n\u003e Some stingy snows in those scriptural contraptions construct a Lygodium palmatum.  \n\nIn [the app](https://1j01.itch.io/nonsensical) you can mess around with giving it seed/suggestion/topic words.\n\n\n## Install\n\n`npm i nonsensical --save`\n\n\n## API\n\n**Note: UNSTABLE and not following semver until 1.0 is released**\n\nNonsensical first needs to load WordNet data, so the API isn't immediately available,\nbut once the data is loaded (asynchronously), the rest of the API is synchronous.\n\nYou need to copy the data JSON files and specify paths to load them from.\n\nidk if something like this is a good idea or not:\n\n    \"postinstall\": \"cp -r node_modules/wordnetjs/data/ data/\"\n\nsome things to consider:\ncross-platform-ness of the copy command,\nlocation of the module that has the data (might be in a sub node_modules folder? depending on npm version?),\nwhen postinstall runs\n\nmaybe this package could provide a bin script to copy the wordnet data to a directory..\n\nIn Node it should really use the [version of wordnet.js](https://github.com/nlp-compromise/wordnet.js)\nnot [forked and ported for browser usage](https://github.com/wassname/wordnet.js).\nCurrently the API works using webpack (and should work with browserify or other bundlers),\nrun in the browser, but in Node there's no `window.fetch`.\nIt's hacked it to work in [`npm-start.js`](./src/npm-start.js)\n\n```js\nvar Nonsensical = require(\"nonsensical\");\nvar nonsensical = new Nonsensical();\nvar dataFilePaths = {\n\tnoun: './data/noun.json',\n\tadverb: './data/adverb.json',\n\tadjective: './data/adjective.json',\n\tverb: './data/verb.json',\n};\nnonsensical.load(dataFilePaths, function () {\n\t// generate a sentence!\n\tconsole.log(nonsensical.generateSentence());\n\t// generate a sentence related to felines!\n\tconsole.log(nonsensical.generateSentence({\n\t\twordSuggestions: {\n\t\t\tnouns: [\"cat\", \"kitty\", \"mouse\", \"fur\", \"bird\", \"house\"],\n\t\t\tverbs: [\"purr\", \"pet\", \"hiss\", \"catch\", \"chase\", \"sleep\"],\n\t\t\tadjectives: [\"soft\", \"warm\"]\n\t\t},\n\t\tuseSuggestionRelatedWordChance: 1/2,\n\t\tmaxSemanticStepsRemovedFromSuggestions: 3\n\t}));\n});\n```\n\n\n### nonsensical.load(dataFilePaths, callback)\n\nLoads WordNet data from the given file paths.\n\nYou wait for the callback before calling `generateSentence`.\n\n### nonsensical.generateSentence(options)\n\nAll options are optional, including the options argument itself.\n\n#### options.wordSuggestions\n\n*Default: a built in map of word lists*\n\nSuggestions for words to be incorporated into the output,\nsort of like \"topics\" when semantic removal steps are enabled.\nShould be an object with keys `nouns`, `verbs`, `adjectives`, `adverbs`, or a subset,\nwith arrays of words as values.\n\n#### options.useSuggestionRelatedWordChance\n\n*Default: 1*\n\nA chance between 0 and 1 of using a one of your suggested words,\nversus a word from the default word lists.\n\n#### options.maxSemanticStepsRemovedFromSuggestions\n\n*Default: 0*\n\nIf this is 1 or higher, Nonsensical will traverse WordNet synonym to synonym,\ntaking *up to this number of steps* away from the original word.\n\nIt *won't* take a *linearly* random number of steps away from the original word though, currently.\n\n\n## To-Do\n\n- Different types of sentences! Different structures!\n\n- Make the API work reasonably for Node again\n\n- Make a standalone build for browsers so you don't have to use a bundler\n\n- Stuff mentioned in source code (TODO, FIXME)\n\n- Poems would be fun; get some rhymes up in here~~?\n\n- Constraints on sentences such as length\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1j01%2Fnonsensical","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1j01%2Fnonsensical","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1j01%2Fnonsensical/lists"}