class Gamefic::Scanner::Strict


matches one of the entity’s keywords.
An entity will only match a word in a strict scan if the entire word
Strict token matching.

def match_word available, word

def match_word available, word
  available.select { |obj| (obj.keywords + obj.nuance.keywords).include?(word) }
end

def reduce_noise entities, keywords

def reduce_noise entities, keywords
  noiseless = keywords - NOISE
  entities.reject { |entity| (noiseless - entity.nuance.keywords).empty? }
end

def scan

Returns:
  • (Result) -
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