ar-stemmer 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/ar-stemmer.gemspec +1 -1
- data/lib/ar_stemmer.rb +13 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ceb4076e652815af29f052fdee80703387ec221
|
4
|
+
data.tar.gz: a41c51a64dcb5e3c5aa8c907b107fdcae224a7c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 `
|
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,
|
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
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, :
|
45
|
+
attr_reader :word, :excepts, :onlys
|
46
46
|
|
47
47
|
def initialize(word, options = {})
|
48
48
|
@word = word.dup
|
49
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2016-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|