class SlackSmartBot
def get_keywords(sentence, list_avoid: [])
require "engtagger"
keywords = []
unless sentence.to_s.strip.empty?
tagger = EngTagger.new
tagged_sentence = tagger.add_tags(sentence)
unless tagged_sentence.nil?
nouns = tagger.get_nouns(tagged_sentence).keys
proper_nouns = tagger.get_proper_nouns(tagged_sentence).keys
adjectives = tagger.get_adjectives(tagged_sentence).keys
ids = sentence.scan(/([\w]+\-[\w\-]+)/)
keywords = (nouns + proper_nouns + adjectives + ids.flatten).uniq
keywords.delete_if { |keyword| keyword.length < 3 }
if !list_avoid.empty?
keywords.delete_if { |keyword| list_avoid.any? { |avoid| keyword.match?(/#{avoid}/i) } }
end
keywords.map! { |keyword| keyword.gsub(/[^\w\-_]/i, "") }
end
end
return keywords
end
end