{"id":18484205,"url":"https://github.com/nathankleyn/ruby-nlp","last_synced_at":"2025-04-08T18:33:12.152Z","repository":{"id":56893590,"uuid":"12833114","full_name":"nathankleyn/ruby-nlp","owner":"nathankleyn","description":"Various NLP tools for Ruby","archived":false,"fork":false,"pushed_at":"2013-09-14T20:13:41.000Z","size":76,"stargazers_count":33,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-03T15:51:02.935Z","etag":null,"topics":["nlp","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/nathankleyn.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}},"created_at":"2013-09-14T17:27:10.000Z","updated_at":"2019-05-04T07:02:58.000Z","dependencies_parsed_at":"2022-08-20T16:10:39.836Z","dependency_job_id":null,"html_url":"https://github.com/nathankleyn/ruby-nlp","commit_stats":null,"previous_names":["nathankleyn/ruby_nlp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathankleyn%2Fruby-nlp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathankleyn%2Fruby-nlp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathankleyn%2Fruby-nlp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathankleyn%2Fruby-nlp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathankleyn","download_url":"https://codeload.github.com/nathankleyn/ruby-nlp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247902761,"owners_count":21015509,"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":["nlp","ruby"],"created_at":"2024-11-06T12:38:52.930Z","updated_at":"2025-04-08T18:33:07.143Z","avatar_url":"https://github.com/nathankleyn.png","language":"Ruby","funding_links":[],"categories":["Articles, Posts, Talks, and Presentations"],"sub_categories":["Text-to-Speech-to-Text"],"readme":"# Ruby NLP\n\nThis repository is a pure Ruby toolkit for NLP. It's the examples part of an ongoing series I'm writing on [SitePoint.com](http://sitepoint.com), so watch this repository for updates!\n\n## Installing\n\nSimply install the gem:\n\n```sh\ngem install ruby_nlp\n```\n\n## What's In This Project?\n\n### *n*-grams\n\nA simple class to generate *n*-grams from an input string, either per word, per character, or on some custom splitter.\n\n```ruby\nrequire 'ruby_nlp/ngram'\nngram = Ngram.new(\"foo bar lux win\")\n\nngram.unigrams # =\u003e [[\"foo\"], [\"bar\"], [\"lux\"], [\"win\"]]\nngram.bigrams # =\u003e [[\"foo\", \"bar\"], [\"bar\", \"lux\"], [\"lux\", \"win\"]]\nngram.trigrams # =\u003e [[\"foo\", \"bar\", \"lux\"], [\"bar\", \"lux\", \"win\"]]\nngram.ngrams(4) # =\u003e [[\"foo\", \"bar\", \"lux\", \"win\"]]\n\nngram = Ngram.new(\"abcde\", regex: //)\nngram.unigrams # =\u003e [[\"a\"], [\"b\"], [\"c\"], [\"d\"], [\"e\"]]\n```\n\n### Corpus Extractor\n\nThere is a basic corpus loader. It takes a glob for the files that are part of the corpus, and a class to delegate the sentence extraction to.\n\nCurrently, support for the following corpus types are included:\n\n* Brown Corpus, in the `BrownCorpusFile` class at `ruby_nlp/corpus_files/brown`. This corpus currently strips the tagging to reveal only the raw sentences in the corpus.\n\nAn example of this in action:\n\n```ruby\nrequire 'ruby_nlp/corpus'\nrequire 'ruby_nlp/corpus_files/brown'\n\ncorpus = Corpus.new('brown/c*', BrownCorpusFile)\ncorpus.trigrams # =\u003e One *really* big array of trigrams!\n\ncorpus.files # =\u003e `Array` of `BrownCorpusFile` instances, one for each file found.\ncorpus.sentences # =\u003e Flattened `Array` of sentences.\n```\n\n## Examples\n\nSome examples are in the `examples` directory, one per article from [SitePoint.com](http://sitepoint.com) in this series.\n\n## Future Work\n\n* Support for other corpora.\n* Preservation, filtering and searching of tags in corpora.\n* Markov modelling and chaining.\n* Text generation using Markov modelling.\n* Part of speech tagging.\n* Classification.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Nathan Kleyn\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathankleyn%2Fruby-nlp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathankleyn%2Fruby-nlp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathankleyn%2Fruby-nlp/lists"}