Class: FarsiProcessor

Inherits:
Object
  • Object
show all
Includes:
Normalizer, Stemmer
Defined in:
lib/farsi_processor.rb,
lib/farsi_processor/version.rb

Constant Summary collapse

VERSION =
"0.2.1"

Constants included from Stemmer

Stemmer::ALEF, Stemmer::GAF, Stemmer::HEH, Stemmer::MEEM, Stemmer::NOON, Stemmer::PLURAL_FORMS, Stemmer::REH, Stemmer::SUFFIXES, Stemmer::TET, Stemmer::YEH

Constants included from Normalizer

Normalizer::ALEF, Normalizer::ALEF_MADDA, Normalizer::ALEF_WITH_HAMZA_ABOVE, Normalizer::ALEF_WITH_HAMZA_BELOW, Normalizer::ARABIC_ALEF_MAKSOURA, Normalizer::ARABIC_KAF, Normalizer::ARABIC_YEH, Normalizer::CHARACTERS_MAPPINGS, Normalizer::DAMMA, Normalizer::DAMMATAN, Normalizer::DIACRITICS, Normalizer::FARSI_KEHEH, Normalizer::FARSI_YEH, Normalizer::FATHA, Normalizer::FATHATAN, Normalizer::KASRA, Normalizer::KASRATAN, Normalizer::SHADDA, Normalizer::SUKUN, Normalizer::TATWIL

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Stemmer

#stem

Methods included from Normalizer

#normalize

Constructor Details

#initialize(word, options = {}) ⇒ FarsiProcessor

Returns a new instance of FarsiProcessor.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/farsi_processor.rb', line 23

def initialize(word, options = {})
  @word = word
  @options = options

  @onlys = []
  @excepts = []
  if options[:only]
    @onlys = options[:only]
  elsif options[:except]
    @excepts = options[:except]
  end
end

Instance Attribute Details

#exceptsObject (readonly)

Returns the value of attribute excepts.



21
22
23
# File 'lib/farsi_processor.rb', line 21

def excepts
  @excepts
end

#onlysObject (readonly)

Returns the value of attribute onlys.



21
22
23
# File 'lib/farsi_processor.rb', line 21

def onlys
  @onlys
end

#optionsObject (readonly)

Returns the value of attribute options.



21
22
23
# File 'lib/farsi_processor.rb', line 21

def options
  @options
end

#wordObject (readonly)

Returns the value of attribute word.



21
22
23
# File 'lib/farsi_processor.rb', line 21

def word
  @word
end

Class Method Details

.normalize(word, options = {}) ⇒ Object



13
14
15
# File 'lib/farsi_processor.rb', line 13

def self.normalize(word, options = {})
  new(word, options).normalize
end

.process(word, options = {}) ⇒ Object



9
10
11
# File 'lib/farsi_processor.rb', line 9

def self.process(word, options = {})
  new(word, options).process
end

.stem(word, options = {}) ⇒ Object



17
18
19
# File 'lib/farsi_processor.rb', line 17

def self.stem(word, options = {})
  new(word, options).stem
end

Instance Method Details

#processObject



36
37
38
39
# File 'lib/farsi_processor.rb', line 36

def process
  normalize
  stem
end