Class: Moby::PartsOfSpeech

Inherits:
Object
  • Object
show all
Defined in:
lib/moby/parts_of_speech.rb

Instance Method Summary collapse

Instance Method Details

#adjective?(word) ⇒ Boolean

Returns:

  • (Boolean)


46
# File 'lib/moby/parts_of_speech.rb', line 46

def adjective?(word); pos?(word, :adjective); end

#adjectivesObject



16
# File 'lib/moby/parts_of_speech.rb', line 16

def adjectives; words(:adjective); end

#adverb?(word) ⇒ Boolean

Returns:

  • (Boolean)


47
# File 'lib/moby/parts_of_speech.rb', line 47

def adverb?(word); pos?(word, :adverb); end

#adverbsObject



17
# File 'lib/moby/parts_of_speech.rb', line 17

def adverbs; words(:adverb); end

#conjunction?(word) ⇒ Boolean

Returns:

  • (Boolean)


48
# File 'lib/moby/parts_of_speech.rb', line 48

def conjunction?(word); pos?(word, :conjunction); end

#conjunctionsObject



18
# File 'lib/moby/parts_of_speech.rb', line 18

def conjunctions; words(:conjunction); end

#definite_article?(word) ⇒ Boolean

Returns:

  • (Boolean)


52
# File 'lib/moby/parts_of_speech.rb', line 52

def definite_article?(word); pos?(word, :definite_article); end

#definite_articlesObject



22
# File 'lib/moby/parts_of_speech.rb', line 22

def definite_articles; words(:definite_article); end

#find(word) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/moby/parts_of_speech.rb', line 3

def find(word)
  { :word  => word,
    :found => pos.has_key?(word),
    :code  => pos_code(word),
    :pos   => pos_breakdown(word)
  }
end

#indefinite_article?(word) ⇒ Boolean

Returns:

  • (Boolean)


53
# File 'lib/moby/parts_of_speech.rb', line 53

def indefinite_article?(word); pos?(word, :indefinite_article); end

#indefinite_articlesObject



23
# File 'lib/moby/parts_of_speech.rb', line 23

def indefinite_articles; words(:indefinite_article); end

#interjection?(word) ⇒ Boolean

Returns:

  • (Boolean)


50
# File 'lib/moby/parts_of_speech.rb', line 50

def interjection?(word); pos?(word, :interjection); end

#interjectionsObject



20
# File 'lib/moby/parts_of_speech.rb', line 20

def interjections; words(:interjection); end

#nominative?(word) ⇒ Boolean

Returns:

  • (Boolean)


54
# File 'lib/moby/parts_of_speech.rb', line 54

def nominative?(word); pos?(word, :nominative); end

#nominativesObject



24
# File 'lib/moby/parts_of_speech.rb', line 24

def nominatives; words(:nominatives); end

#noun?(word) ⇒ Boolean

Query methods

Returns:

  • (Boolean)


43
# File 'lib/moby/parts_of_speech.rb', line 43

def noun?(word); pos?(word, :noun); end

#noun_phrase?(word) ⇒ Boolean

Returns:

  • (Boolean)


45
# File 'lib/moby/parts_of_speech.rb', line 45

def noun_phrase?(word); pos?(word, :noun_phrase); end

#noun_phrasesObject



15
# File 'lib/moby/parts_of_speech.rb', line 15

def noun_phrases; words(:noun_phrase); end

#nounsObject

Word list methods



13
# File 'lib/moby/parts_of_speech.rb', line 13

def nouns; words(:noun); end

#plural?(word) ⇒ Boolean

Returns:

  • (Boolean)


44
# File 'lib/moby/parts_of_speech.rb', line 44

def plural?(word); pos?(word, :plural); end

#pluralsObject



14
# File 'lib/moby/parts_of_speech.rb', line 14

def plurals; words(:plural) end

#preposition?(word) ⇒ Boolean

Returns:

  • (Boolean)


49
# File 'lib/moby/parts_of_speech.rb', line 49

def preposition?(word); pos?(word, :preposition); end

#prepositionsObject



19
# File 'lib/moby/parts_of_speech.rb', line 19

def prepositions; words(:preposition); end

#pronoun?(word) ⇒ Boolean

Returns:

  • (Boolean)


51
# File 'lib/moby/parts_of_speech.rb', line 51

def pronoun?(word); pos?(word, :pronoun); end

#pronounsObject



21
# File 'lib/moby/parts_of_speech.rb', line 21

def pronouns; words(:pronoun); end

#verb?(word, options = {:type => :all}) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/moby/parts_of_speech.rb', line 56

def verb?(word, options = {:type => :all})
  case options[:type]
  when :all
    pos?(word, :verb_usu_participle) ||
    pos?(word, :verb_transitive) ||
    pos?(word, :verb_intransitive)
  when :usu
    pos?(word, :verb_usu_participle)
  when :transitive
    pos?(word, :verb_transitive)
  when :intransitive
    pos?(word, :verb_intransitive)
  end
end

#verbs(options = {:type => :all}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/moby/parts_of_speech.rb', line 26

def verbs(options = {:type => :all})
  case options[:type]
  when :all
    words(:verb_usu_participle) +
    words(:verb_transitive) +
    words(:verb_intransitive)
  when :usu
    words(:verb_usu_participle)
  when :transitive
    words(:verb_transitive)
  when :intransitive
    words(:verb_intransitive)
  end
end