Class: Lingua::Stemmer

Inherits:
Object
  • Object
show all
Defined in:
lib/lingua/stemmer.rb

Constant Summary

VERSION =
File.read(File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "VERSION"))).strip!

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Stemmer

Creates a new Stemmer, pass :language and :encoding as arguments to change encoding or language, otherwise english with UTF_8 will be used

require 'lingua/stemmer'
s = Lingua::Stemmer.new :language => 'fr'


40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/lingua/stemmer.rb', line 40

def initialize(options={})
  @language = (options[:language] || 'en').to_s
  @encoding = (options[:encoding] || 'UTF_8').to_s

  if RUBY_VERSION >= "1.9"
    if not @encoding.is_a?(Encoding)
      @encoding = Encoding.find(@encoding.gsub("_", "-"))
    end
  else
    @encoding = @encoding.upcase.gsub("-", "_")
  end

  native_init(@language, native_encoding(@encoding))
end

Instance Attribute Details

#encodingObject (readonly)

Returns the value of attribute encoding



31
32
33
# File 'lib/lingua/stemmer.rb', line 31

def encoding
  @encoding
end

#languageObject (readonly)

Returns the value of attribute language



30
31
32
# File 'lib/lingua/stemmer.rb', line 30

def language
  @language
end