text 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/lib/text.rb +0 -1
- data/lib/text/version.rb +1 -1
- data/test/preamble.rb +9 -4
- 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 +5 -7
- data/test/test_soundex.rb +1 -1
- data/test/test_text.rb +13 -0
- data/test/test_white_similarity.rb +1 -1
- metadata +3 -2
data/Rakefile
CHANGED
data/lib/text.rb
CHANGED
data/lib/text/version.rb
CHANGED
data/test/preamble.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
|
3
|
-
|
3
|
+
lib = File.expand_path("../../lib")
|
4
|
+
$:.unshift lib unless $:.include?(lib)
|
4
5
|
|
5
|
-
class
|
6
|
-
def
|
7
|
-
join(dirname(__FILE__), *path)
|
6
|
+
class Test::Unit::TestCase
|
7
|
+
def data_file_path(*path)
|
8
|
+
File.join(File.dirname(__FILE__), "data", *path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def data_file(*path)
|
12
|
+
File.read(data_file_path(*path))
|
8
13
|
end
|
9
14
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "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(data_file_path('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 "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(data_file('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(data_file('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,15 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require "preamble"
|
2
2
|
require "text/porter_stemming"
|
3
3
|
|
4
4
|
class PorterStemmingTest < Test::Unit::TestCase
|
5
5
|
|
6
|
-
def slurp(*path)
|
7
|
-
File.read(File.rel(*path)).split(/\n/)
|
8
|
-
end
|
9
|
-
|
10
6
|
def test_cases
|
11
|
-
|
12
|
-
|
7
|
+
inputs = data_file('porter_stemming_input.txt').split(/\n/)
|
8
|
+
outputs = data_file('porter_stemming_output.txt').split(/\n/)
|
9
|
+
|
10
|
+
inputs.zip(outputs).each do |word, expected_output|
|
13
11
|
assert_equal expected_output, Text::PorterStemming.stem(word)
|
14
12
|
end
|
15
13
|
end
|
data/test/test_soundex.rb
CHANGED
data/test/test_text.rb
ADDED
@@ -0,0 +1,13 @@
|
|
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
|
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.2.
|
4
|
+
version: 1.2.1
|
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-06-
|
14
|
+
date: 2012-06-10 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,6 +40,7 @@ files:
|
|
40
40
|
- test/data/big.txt
|
41
41
|
- test/preamble.rb
|
42
42
|
- test/test_soundex.rb
|
43
|
+
- test/test_text.rb
|
43
44
|
- test/test_white_similarity.rb
|
44
45
|
- test/test_metaphone.rb
|
45
46
|
- test/test_levenshtein.rb
|