https://github.com/doches/rwordnet
A pure Ruby interface to the WordNet database
https://github.com/doches/rwordnet
nlp-library ruby wordnet wordnet-tags
Last synced: about 2 months ago
JSON representation
A pure Ruby interface to the WordNet database
- Host: GitHub
- URL: https://github.com/doches/rwordnet
- Owner: doches
- Created: 2008-11-10T19:21:37.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2019-08-22T08:42:11.000Z (almost 6 years ago)
- Last Synced: 2024-04-24T20:03:58.748Z (about 1 year ago)
- Topics: nlp-library, ruby, wordnet, wordnet-tags
- Language: Ruby
- Homepage: http://www.texasexpat.net/
- Size: 8.06 MB
- Stars: 88
- Watchers: 7
- Forks: 25
- Open Issues: 5
-
Metadata Files:
- Readme: README.markdown
- Changelog: History.txt
Awesome Lists containing this project
README
# A pure Ruby interface to WordNet #
[](http://badge.fury.io/rb/rwordnet)
[](https://travis-ci.org/doches/rwordnet)
[](https://inch-ci.org/github/doches/rwordnet)
[](https://codeclimate.com/github/doches/rwordnet)
[](https://codeclimate.com/github/doches/rwordnet/coverage)## Summary ##
+ Works directly on the database that comes with WordNet
+ No gem or native dependencies
+ *Very* easy to install
+ Small footprint (8.1M vs 24M for Ruby-Wordnet+DB)
+ Can use a custom, existing WordNet installation## About ##
This library implements a pure Ruby interface to the WordNet lexical/semantic
database. Unlike existing ruby bindings, this one doesn't require you to convert
the original WordNet database into a new database format; instead it can work directly
on the database that comes with WordNet.If you're doing something data-intensive you will achieve much better performance
with Michael Granger's [Ruby-WordNet](http://www.deveiate.org/projects/Ruby-WordNet/),
since it converts the WordNet database into a BerkelyDB file for quicker access. rwordnet has a much smaller footprint, with no gem or native dependencies, and requires about a third of the space on disk as Ruby-Wordnet + DB. In
writing rwordnet, I've focused more on usability and ease of installation ( *gem install
rwordnet* ) at the expense of some performance. Use at your own risk, etc.| Note |
| --- |
| `2.0.0` changed how you require rwordnet from `require 'wordnet'` to `require 'rwordnet'` (note the extra `r`!). |## Installation ##
One of the chief benefits of rwordnet over Ruby-WordNet is how easy it is to install:
gem install rwordnet
That's it! rwordnet comes bundled with the WordNet database which it uses by default,
so there's absolutely nothing else to download, install, or configure.
Of course, if you want to use your own WordNet installation, that's easy too -- just
set the path to WordNet's database files before using the library (see examples below).## Usage ##
The other benefit of rwordnet over Ruby-WordNet is that it's so much easier (IMHO) to
use.As an example, consider finding all of the noun glosses for a given word:
```Ruby
require 'rwordnet'lemma = WordNet::Lemma.find("fruit", :noun)
lemma.synsets.each { |synset| puts synset.gloss }
```...or all of the glosses, period:
```Ruby
lemmas = WordNet::Lemma.find_all("fruit")
synsets = lemmas.map { |lemma| lemma.synsets }
words = synsets.flatten
words.each { |word| puts word.gloss }
```Have your own WordNet database that you've marked up with extra attributes and whatnot?
No problem:```Ruby
require 'rwordnet'WordNet::DB.path = "/path/to/WordNet-3.0"
lemmas = WordNet::Lemma.find_all("fruit")
```