ar-stemmer 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dc21e273c406dd6d38f7517a7a560e38635a5bf
4
- data.tar.gz: 26fc0d3b1055d9c72d50a14dafec6b73f0df0c2f
3
+ metadata.gz: 6ceb4076e652815af29f052fdee80703387ec221
4
+ data.tar.gz: a41c51a64dcb5e3c5aa8c907b107fdcae224a7c8
5
5
  SHA512:
6
- metadata.gz: b5a86a69fd409515cfb0e6ef19efee86807506edad369966656062715542004e4cab9526d95211f570d15538de7eab617ea70f451522916baaa3209adac18f06
7
- data.tar.gz: cda405430462c6591d48bb026237a5d1872f100633c53b024933213b20ffd90c02d40fd7f2ffa9c64e8f67f21c79ce8044060c3441fe194a2894869be3904f42
6
+ metadata.gz: 8d41ccb2cabfb1eb171228f9a282edc89f4c1cd935114623e202b79b0ef364e0858b6598afe6c81a5830e732151931b7ef7c2b6be14639a9eedcfa76ad045610
7
+ data.tar.gz: b96df525795e8d4d7e325f19aa2bb27029f9c5a410bad9b552e8208a86532978be2c419ae9bab6ab6dd6ce4272410a25281dfb7764cccd55843ec92c2c834bd8
data/README.md CHANGED
@@ -30,12 +30,15 @@ ArStemmer.stem("الدونات")
30
30
  "دونات"
31
31
  ```
32
32
 
33
- When you want to turn off the specific rules for your own purpose, you can pass the name to `disable` option.
33
+ When you want to turn on/off the specific rules for your own purpose, you can pass the name to `only/except` option.
34
34
 
35
35
  ```
36
- ArStemmer.stem(word, disable: [:yeh_noon, :waw_noon])
36
+ ArStemmer.stem(word, only: [:alef_lam, :waw_alef_lam])
37
+ ArStemmer.stem(word, except: [:yeh_noon, :waw_noon])
37
38
  ```
38
39
 
40
+ You can find the rule names in [the source code](https://github.com/tomoya55/ar-stemmer/blob/master/lib/ar_stemmer.rb#L18-L39).
41
+
39
42
  ## License
40
43
 
41
44
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/ar-stemmer.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "ar-stemmer"
7
- spec.version = "0.2.0"
7
+ spec.version = "0.3.0"
8
8
  spec.authors = ["Tomoya Hirano"]
9
9
  spec.email = ["hiranotomoya@gmail.com"]
10
10
 
data/lib/ar_stemmer.rb CHANGED
@@ -42,11 +42,18 @@ class ArStemmer
42
42
  new(word, options).stem
43
43
  end
44
44
 
45
- attr_reader :word, :disabled
45
+ attr_reader :word, :excepts, :onlys
46
46
 
47
47
  def initialize(word, options = {})
48
48
  @word = word.dup
49
- @disabled = options[:disable] || []
49
+
50
+ @onlys = []
51
+ @excepts = []
52
+ if options[:only]
53
+ @onlys = options[:only]
54
+ elsif options[:except]
55
+ @excepts = options[:except]
56
+ end
50
57
  end
51
58
 
52
59
  def stem
@@ -58,7 +65,10 @@ class ArStemmer
58
65
  private
59
66
 
60
67
  def rules(rule_set)
61
- rule_set.reject {|k, v| disabled.include?(k) }.values
68
+ rule_set
69
+ .reject {|k, v| excepts.any? ? excepts.include?(k) : false }
70
+ .select {|k, v| onlys.any? ? onlys.include?(k) : true }
71
+ .values
62
72
  end
63
73
 
64
74
  def stem_prefix
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar-stemmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomoya Hirano
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-22 00:00:00.000000000 Z
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler