Sha256: 65963399d385473846602c5ab39f91df2662b43754a3d0de548209cee5c8c188
Contents?: true
Size: 621 Bytes
Versions: 1
Compression:
Stored size: 621 Bytes
Contents
# encoding: UTF-8 class TextNlp class Synonyms def initialize(synonyms = []) @synonyms = {} @expressions = Expressions.new synonyms.each do |synos| name = synos.shift register(name,synos) end end def register(name,synonyms) name.normalize! synonyms.each do |synonym| synonym.normalize! @expressions << synonym @synonyms[synonym] = name end end def transform(text) @expressions.expressionize(text).map { |expr| @synonyms.key?(expr) ? @synonyms[expr] : expr }.compact.join(' ') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
text_nlp-0.0.3 | lib/text_nlp/synonyms.rb |