lib/text_nlp/synonyms.rb in text_nlp-0.0.2 vs lib/text_nlp/synonyms.rb in text_nlp-0.0.3
- old
+ new
@@ -11,18 +11,19 @@
register(name,synos)
end
end
def register(name,synonyms)
- normalized_name = name.normalize
+ name.normalize!
synonyms.each do |synonym|
+ synonym.normalize!
@expressions << synonym
- @synonyms[synonym.normalize] = normalized_name
+ @synonyms[synonym] = name
end
end
- def translate(text)
- @expressions.expressionize(text).map { |expr| @synonyms.key?(expr) ? @synonyms[expr] : expr }.join(' ')
+ def transform(text)
+ @expressions.expressionize(text).map { |expr| @synonyms.key?(expr) ? @synonyms[expr] : expr }.compact.join(' ')
end
end
end
\ No newline at end of file