Class: ArStemmer

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

Overview

Constant Summary collapse

ALEF =

–> أ

"\u0627"
BEH =

–> ب

"\u0628"
TEH_MARBUTA =

–> ة

"\u0629"
TEH =

–> ت

"\u062A"
FEH =

–> ف

"\u0641"
KAF =

–> ك

"\u0643"
LAM =

–> ل

"\u0644"
NOON =

–> ن

"\u0646"
HEH =

–> ه

"\u0647"
WAW =

–> و

"\u0648"
YEH =

–> ي

"\u064A"
PREFIXES =
{
  alef_lam:     ALEF + LAM,
  waw_alef_lam: WAW + ALEF + LAM,
  beh_alef_lam: BEH + ALEF + LAM,
  kaf_alef_lam: KAF + ALEF + LAM,
  feh_alef_lam: FEH + ALEF + LAM,
  lam_lam:      LAM + LAM,
  waw:          WAW,
  beh:          BEH
}
SUFFIXES =
{
  heh_alef:        HEH + ALEF,
  alef_noon:       ALEF + NOON,
  alef_teh:        ALEF + TEH,
  waw_noon:        WAW + NOON,
  yeh_noon:        YEH + NOON,
  yeh_heh:         YEH + HEH,
  yeh_teh_marbuta: YEH + TEH_MARBUTA,
  heh:             HEH,
  teh_marbuta:     TEH_MARBUTA,
  yeh:             YEH
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ArStemmer.



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ar_stemmer.rb', line 48

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

  @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.



46
47
48
# File 'lib/ar_stemmer.rb', line 46

def excepts
  @excepts
end

#onlysObject (readonly)

Returns the value of attribute onlys.



46
47
48
# File 'lib/ar_stemmer.rb', line 46

def onlys
  @onlys
end

#wordObject (readonly)

Returns the value of attribute word.



46
47
48
# File 'lib/ar_stemmer.rb', line 46

def word
  @word
end

Class Method Details

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



42
43
44
# File 'lib/ar_stemmer.rb', line 42

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

Instance Method Details

#stemObject



60
61
62
63
64
# File 'lib/ar_stemmer.rb', line 60

def stem
  stem_prefix
  stem_suffix
  word
end