Class: ArStemmer
- Inherits:
-
Object
- Object
- ArStemmer
- Defined in:
- lib/ar_stemmer.rb
Overview
ArStemmer is a ruby port of Lucene’s ArabicStemmer class with extensions
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
-
#excepts ⇒ Object
readonly
Returns the value of attribute excepts.
-
#onlys ⇒ Object
readonly
Returns the value of attribute onlys.
-
#word ⇒ Object
readonly
Returns the value of attribute word.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(word, options = {}) ⇒ ArStemmer
constructor
A new instance of ArStemmer.
- #stem ⇒ Object
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, = {}) @word = word.dup @onlys = [] @excepts = [] if [:only] @onlys = [:only] elsif [:except] @excepts = [:except] end end |
Instance Attribute Details
#excepts ⇒ Object (readonly)
Returns the value of attribute excepts.
46 47 48 |
# File 'lib/ar_stemmer.rb', line 46 def excepts @excepts end |
#onlys ⇒ Object (readonly)
Returns the value of attribute onlys.
46 47 48 |
# File 'lib/ar_stemmer.rb', line 46 def onlys @onlys end |
#word ⇒ Object (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, = {}) new(word, ).stem end |
Instance Method Details
#stem ⇒ Object
60 61 62 63 64 |
# File 'lib/ar_stemmer.rb', line 60 def stem stem_prefix stem_suffix word end |