abbreviates adjective and adverb to work properly with rwordnet
This commit is contained in:
parent
f61adc8187
commit
2d6891ab9c
|
@ -1,12 +1,12 @@
|
|||
module Treat
|
||||
|
||||
|
||||
# The current version of Treat.
|
||||
VERSION = '2.1.0'
|
||||
|
||||
|
||||
# Treat requires Ruby >= 1.9.2
|
||||
if RUBY_VERSION < '1.9.2'
|
||||
raise "Treat requires Ruby version 1.9.2 " +
|
||||
"or higher, but current is #{RUBY_VERSION}."
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,9 +20,6 @@ class Treat::Workers::Lexicalizers::Sensers::Wordnet
|
|||
# Require an adaptor for Wordnet synsets.
|
||||
require_relative 'wordnet/synset'
|
||||
|
||||
# Noun, adjective and verb indexes.
|
||||
@@indexes = {}
|
||||
|
||||
# Obtain lexical information about a word using the
|
||||
# ruby 'wordnet' gem.
|
||||
def self.sense(word, options = nil)
|
||||
|
@ -49,9 +46,9 @@ class Treat::Workers::Lexicalizers::Sensers::Wordnet
|
|||
return []
|
||||
end
|
||||
|
||||
cat = category.to_s.capitalize
|
||||
cat = abbreviate(category)
|
||||
|
||||
lemma = ::WordNet::Lemma.find(word.value.downcase, cat.to_sym)
|
||||
lemma = ::WordNet::Lemma.find(word.value.downcase, cat)
|
||||
|
||||
return [] if lemma.nil?
|
||||
synsets = []
|
||||
|
@ -69,4 +66,14 @@ class Treat::Workers::Lexicalizers::Sensers::Wordnet
|
|||
end
|
||||
end
|
||||
|
||||
def self.abbreviate category
|
||||
if category == 'adjective'
|
||||
:adj
|
||||
elsif category == 'adverb'
|
||||
:adv
|
||||
else
|
||||
category.to_sym
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue