text 1.0.5 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -1
- data/lib/text.rb +1 -0
- data/lib/text/version.rb +2 -2
- data/test/preamble.rb +4 -9
- data/test/test_double_metaphone.rb +2 -2
- data/test/test_levenshtein.rb +1 -1
- data/test/test_metaphone.rb +3 -3
- data/test/test_porter_stemming.rb +7 -5
- data/test/test_soundex.rb +1 -1
- data/test/test_white_similarity.rb +1 -1
- metadata +3 -4
- data/test/test_text.rb +0 -13
data/Rakefile
CHANGED
data/lib/text.rb
CHANGED
data/lib/text/version.rb
CHANGED
data/test/preamble.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
|
3
|
-
|
4
|
-
$:.unshift lib unless $:.include?(lib)
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
5
4
|
|
6
|
-
class
|
7
|
-
def
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
def data_file(*path)
|
12
|
-
File.read(data_file_path(*path))
|
5
|
+
class File
|
6
|
+
def self.rel(*path)
|
7
|
+
join(dirname(__FILE__), *path)
|
13
8
|
end
|
14
9
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require File.join(File.dirname(__FILE__), 'preamble')
|
2
2
|
require "text/double_metaphone"
|
3
3
|
|
4
4
|
require 'csv'
|
@@ -6,7 +6,7 @@ require 'csv'
|
|
6
6
|
class DoubleMetaphoneTest < Test::Unit::TestCase
|
7
7
|
|
8
8
|
def test_cases
|
9
|
-
CSV.open(
|
9
|
+
CSV.open(File.rel('data', 'double_metaphone.csv'), 'r').to_a.each do |row|
|
10
10
|
primary, secondary = Text::Metaphone.double_metaphone(row[0])
|
11
11
|
|
12
12
|
assert_equal row[1], primary
|
data/test/test_levenshtein.rb
CHANGED
data/test/test_metaphone.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require
|
1
|
+
require File.join(File.dirname(__FILE__), 'preamble')
|
2
2
|
require "text/metaphone"
|
3
3
|
require 'yaml'
|
4
4
|
|
5
5
|
class MetaphoneTest < Test::Unit::TestCase
|
6
6
|
|
7
7
|
def test_cases
|
8
|
-
YAML.load(
|
8
|
+
YAML.load(File.read(File.rel('data', 'metaphone.txt'))).each do |input, expected_output|
|
9
9
|
assert_equal expected_output, Text::Metaphone.metaphone(input)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_cases_for_buggy_implementation
|
14
|
-
YAML.load(
|
14
|
+
YAML.load(File.read(File.rel('data', 'metaphone_buggy.txt'))).each do |input, expected_output|
|
15
15
|
assert_equal expected_output, Text::Metaphone.metaphone(input, :buggy=>true)
|
16
16
|
end
|
17
17
|
end
|
@@ -1,13 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require File.join(File.dirname(__FILE__), 'preamble')
|
2
2
|
require "text/porter_stemming"
|
3
3
|
|
4
4
|
class PorterStemmingTest < Test::Unit::TestCase
|
5
5
|
|
6
|
-
def
|
7
|
-
|
8
|
-
|
6
|
+
def slurp(*path)
|
7
|
+
File.read(File.rel(*path)).split(/\n/)
|
8
|
+
end
|
9
9
|
|
10
|
-
|
10
|
+
def test_cases
|
11
|
+
cases = slurp('data', 'porter_stemming_input.txt').zip(slurp('data', 'porter_stemming_output.txt'))
|
12
|
+
cases.each do |word, expected_output|
|
11
13
|
assert_equal expected_output, Text::PorterStemming.stem(word)
|
12
14
|
end
|
13
15
|
end
|
data/test/test_soundex.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-07
|
14
|
+
date: 2012-06-07 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: ! 'A collection of text algorithms: Levenshtein, Soundex, Metaphone,
|
17
17
|
Double Metaphone, Porter Stemming'
|
@@ -40,7 +40,6 @@ files:
|
|
40
40
|
- test/data/big.txt
|
41
41
|
- test/preamble.rb
|
42
42
|
- test/test_soundex.rb
|
43
|
-
- test/test_text.rb
|
44
43
|
- test/test_white_similarity.rb
|
45
44
|
- test/test_metaphone.rb
|
46
45
|
- test/test_levenshtein.rb
|
@@ -67,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
66
|
version: '0'
|
68
67
|
requirements: []
|
69
68
|
rubyforge_project: text
|
70
|
-
rubygems_version: 1.8.
|
69
|
+
rubygems_version: 1.8.11
|
71
70
|
signing_key:
|
72
71
|
specification_version: 3
|
73
72
|
summary: A collection of text algorithms
|
data/test/test_text.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'preamble'
|
2
|
-
|
3
|
-
class TextTest < Test::Unit::TestCase
|
4
|
-
def test_should_load_all_components
|
5
|
-
require 'text'
|
6
|
-
assert defined? Text::Levenshtein
|
7
|
-
assert defined? Text::Metaphone
|
8
|
-
assert defined? Text::PorterStemming
|
9
|
-
assert defined? Text::Soundex
|
10
|
-
assert defined? Text::VERSION
|
11
|
-
assert defined? Text::WhiteSimilarity
|
12
|
-
end
|
13
|
-
end
|