tagelizer 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/lib/tagelizer.rb CHANGED
@@ -14,7 +14,7 @@ class Tagelizer
14
14
  end
15
15
 
16
16
  def parse( text )
17
- text.split(" ").collect {|i| /(\w*)/.match(i)[1]}.select {|i| i.size > @minwordsize}.collect {|w| stemmer.stem corrected_word(w)}
17
+ remove_duplicates(text.split(" ").collect {|i| /(\w*)/.match(i)[1]}.select {|i| i.size > @minwordsize}.collect {|w| corrected_word(w)})
18
18
  end
19
19
 
20
20
  def speller
@@ -63,6 +63,15 @@ class Tagelizer
63
63
  end
64
64
  end
65
65
 
66
+ def remove_duplicates list
67
+ if list.empty?
68
+ []
69
+ else
70
+ tmp = list.pop
71
+ remove_duplicates(list.select { |word| stemmer.stem(word) != stemmer.stem(tmp) }) + [tmp]
72
+ end
73
+ end
74
+
66
75
 
67
76
 
68
77
  end
@@ -22,6 +22,12 @@ describe "Tagelizer" do
22
22
  it "can use basic form of words" do
23
23
  tagi = Tagelizer.new
24
24
  text = "He reads a book."
25
- tagi.parse(text).should == ["read", "book"]
25
+ tagi.parse(text).should == ["reads", "book"]
26
+ end
27
+
28
+ it "should compare stems" do
29
+ tagi = Tagelizer.new
30
+ text = "He reads a book as a reading."
31
+ tagi.parse(text).should == ["book", "reading"]
26
32
  end
27
33
  end
data/tagelizer.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tagelizer}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jonatan Reiners"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tagelizer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonatan Reiners