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