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 CHANGED
@@ -2,6 +2,7 @@ require 'rake'
2
2
  require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new do |t|
5
+ t.libs << 'test'
5
6
  t.verbose = false
6
7
  end
7
8
 
@@ -1,4 +1,3 @@
1
- require 'text/util'
2
1
  require 'text/double_metaphone'
3
2
  require 'text/levenshtein'
4
3
  require 'text/metaphone'
@@ -2,7 +2,7 @@ module Text
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 2
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,9 +1,14 @@
1
1
  require 'test/unit'
2
2
 
3
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ lib = File.expand_path("../../lib")
4
+ $:.unshift lib unless $:.include?(lib)
4
5
 
5
- class File
6
- def self.rel(*path)
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 File.join(File.dirname(__FILE__), 'preamble')
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(File.rel('data', 'double_metaphone.csv'), 'r').to_a.each do |row|
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
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'preamble')
1
+ require "preamble"
2
2
  require "text/levenshtein"
3
3
 
4
4
  class LevenshteinTest < Test::Unit::TestCase
@@ -1,17 +1,17 @@
1
- require File.join(File.dirname(__FILE__), 'preamble')
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(File.read(File.rel('data', 'metaphone.txt'))).each do |input, expected_output|
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(File.read(File.rel('data', 'metaphone_buggy.txt'))).each do |input, expected_output|
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 File.join(File.dirname(__FILE__), 'preamble')
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
- cases = slurp('data', 'porter_stemming_input.txt').zip(slurp('data', 'porter_stemming_output.txt'))
12
- cases.each do |word, expected_output|
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
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'preamble')
1
+ require "preamble"
2
2
  require "text/soundex"
3
3
  require 'yaml'
4
4
 
@@ -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
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'preamble')
1
+ require "preamble"
2
2
  require "text/white_similarity"
3
3
 
4
4
  class WhiteSimilarityTest < Test::Unit::TestCase
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.0
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-07 00:00:00.000000000 Z
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