Sha256: ad18119a48025a84c6780ac9f77e73b74ce2f9d0c60bfd5718ef91b87be27660

Contents?: true

Size: 561 Bytes

Versions: 10

Compression:

Stored size: 561 Bytes

Contents

# coding : utf-8
require 'benchmark'
require 'turkish_stemmer'

Benchmark.bmbm(7) do |x|

  x.report('regex') do
    TurkishStemmer.class_eval do
      def self.turkish?(word)
        !! word.match(TurkishStemmer::ALPHABET)
      end
    end

    100_000.times { TurkishStemmer.turkish?("aaa") }
  end

  x.report('loop') do
    TurkishStemmer.class_eval do
      def self.turkish?(word)
        !! word.chars.to_a.all? { |c| "abcçdefgğhıijklmnoöprsştuüvyz".include?(c) }
      end
    end

    100_000.times { TurkishStemmer.turkish?("aaaa") }
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
turkish_stemmer-0.1.12 benchmarks/turkish_word_recognition.rb
turkish_stemmer-0.1.11 benchmarks/turkish_word_recognition.rb
turkish_stemmer-0.1.10 benchmarks/turkish_word_recognition.rb
turkish_stemmer-0.1.8 benchmarks/turkish_word_recognition.rb
turkish_stemmer-0.1.7 benchmarks/turkish_word_recognition.rb
turkish_stemmer-0.1.6 benchmarks/turkish_word_recognition.rb
turkish_stemmer-0.1.5 benchmarks/turkish_word_recognition.rb
turkish_stemmer-0.1.2 benchmarks/turkish_word_recognition.rb
turkish_stemmer-0.1.1 benchmarks/turkish_word_recognition.rb
turkish_stemmer-0.1.0 benchmarks/turkish_word_recognition.rb