class Rouge::Guessers::Disambiguation
def self.disambiguate(*patterns, &decider)
def self.disambiguate(*patterns, &decider) @disambiguators << Disambiguator.new(patterns, &decider) end
def self.disambiguators
def self.disambiguators @disambiguators end
def contains?(text)
def contains?(text) return @analyzer.include?(text) end
def filter(lexers)
def filter(lexers) return lexers if lexers.size == 1 return lexers if lexers.size == Lexer.all.size @analyzer = TextAnalyzer.new(get_source(@source)) self.class.disambiguators.each do |disambiguator| next unless disambiguator.match?(@filename) filtered = disambiguator.decide!(self) return filtered if filtered end return lexers end
def initialize(filename, source)
def initialize(filename, source) @filename = File.basename(filename) @source = source end
def matches?(re)
def matches?(re) return !!(@analyzer =~ re) end