/moby

Ruby interface for Moby wordlists

Primary LanguageRubyMIT LicenseMIT

Moby

Build Status

Ruby interface for Moby Project word lists. The goal is to provide interfaces for most of the Moby Project texts and/or wordlists.

Interfaces currently provided are listed below. More to come!

Install

gem install moby

Parts of Speech

Usage

pos = Moby::PartsOfSpeech.new

List

Get word lists by part of speech

pos.nouns 
pos.plurals
pos.noun_phrases
pos.adjectives
pos.adverbs
pos.conjunctions
pos.prepositions
pos.interjections
pos.pronouns
pos.definite_articles
pos.indefinite_articles
pos.nominatives

#verbs takes an optional :type parameter since there's three types

pos.verbs
pos.verbs(:type => :all) # default
pos.verbs(:type => :usu)
pos.verbs(:type => :transitive)
pos.verbs(:type => :intransitive)  

Find

Find parts of speech info for a word

pos.find("word") 
#=> {
#=>   :word => "word", 
#=>   :code => "Nt", 
#=>   :pos => [:noun, :vert_transitive]
#=> }
  
pos.find("walk") 
#=> {
#=>   :word => "walk", 
#=>   :code => "iNt", 
#=>   :pos => [:noun, :verb_transitive, :verb_intransitive]
#=> }

Query

Check a word by part of speech

pos.noun?("animal")             #=> true
pos.verb?("run")                #=> true
pos.intransitive_verb?("walk")  #=> true
pos.adjective?("sky")           #=> false

#verb? takes an optional :type parameter (like #verbs)

pos.verb?("abandon", :type => :transitive)          #=> true
pos.verb?("overurbanized", :type => :intransitive)  #=> false
pos.verb?("overurbanized")                          #=> true

Hyphenator

Usage

hyph = Moby::Hyphenator.new

Hyphenate words

hyph.hyphenate("bardish") #=> "bard-ish"
hyph.hyphenate("hastelessness") #=> "haste-less-ness"
hyph.hyphenate("interpollinating") #=> #"in-ter-pol-li-nat-ing"

Returns the word unchanged if not found or if it shouldn't be hyphenated

hyph.hyphenate("Mordor") #=> "Mordor" (not found)
hyph.hyphenate("jest") #=> "jest" (shouldn't be hyphenated)

Thesaurus

Usage

thes = Moby::Thesaurus.new

Get related words (#syns and #related are aliases of #synonyms)

thes.synonyms("apercu") 
#=> ["a priori knowledge", "abbreviation", "abbreviature", "abrege", ... ]

thes.syns("buoyant")
#=> ["adaptable", "adaptive", "afloat", "airy", "animated", ... ]

thes.related("infiltration")
#=> ["absorbency", "absorbent", "absorption", "access", "admission", ... ]

Returns an empty array if word isn't found

thes.syns("Chewbacca") #=> []

Copyright

Copyright © 2012 Dan Richert. See LICENSE for details