class Gamefic::Scanner::Strict
Strict
token matching.
An entity will only match a word in a strict scan if the entire word matches one of the entity’s keywords.
Constants
- NOISE
Public Instance Methods
Source
# File lib/gamefic/scanner/strict.rb, line 31 def match_word available, word available.select { |obj| (obj.keywords + obj.nuance.keywords).include?(word) } end
Source
# File lib/gamefic/scanner/strict.rb, line 35 def reduce_noise entities, keywords noiseless = keywords - NOISE entities.reject { |entity| (noiseless - entity.nuance.keywords).empty? } end
Source
# File lib/gamefic/scanner/strict.rb, line 16 def scan words = token.keywords available = selection.clone filtered = [] words.each_with_index do |word, idx| # @todo This might not be the best way to filter articles, but it works for now tested = %w[a an the].include?(word) ? available : match_word(available, word) return matched_result(reduce_noise(filtered, words[0, idx]), words[idx..].join(' ')) if tested.empty? filtered = tested available = filtered end matched_result(reduce_noise(filtered, words), '') end
@return [Result]