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 CHANGED
@@ -2,7 +2,6 @@ require 'rake'
2
2
  require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new do |t|
5
- t.libs << 'test'
6
5
  t.verbose = false
7
6
  end
8
7
 
@@ -1,3 +1,4 @@
1
+ require 'text/util'
1
2
  require 'text/double_metaphone'
2
3
  require 'text/levenshtein'
3
4
  require 'text/metaphone'
@@ -1,8 +1,8 @@
1
1
  module Text
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
- MINOR = 0
5
- TINY = 5
4
+ MINOR = 2
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,14 +1,9 @@
1
1
  require 'test/unit'
2
2
 
3
- lib = File.expand_path("../../lib")
4
- $:.unshift lib unless $:.include?(lib)
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
5
4
 
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))
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 "preamble"
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(data_file_path('double_metaphone.csv'), 'r').to_a.each do |row|
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
@@ -1,4 +1,4 @@
1
- require "preamble"
1
+ require File.join(File.dirname(__FILE__), 'preamble')
2
2
  require "text/levenshtein"
3
3
 
4
4
  class LevenshteinTest < Test::Unit::TestCase
@@ -1,17 +1,17 @@
1
- require "preamble"
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(data_file('metaphone.txt')).each do |input, expected_output|
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(data_file('metaphone_buggy.txt')).each do |input, expected_output|
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 "preamble"
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 test_cases
7
- inputs = data_file('porter_stemming_input.txt').split(/\n/)
8
- outputs = data_file('porter_stemming_output.txt').split(/\n/)
6
+ def slurp(*path)
7
+ File.read(File.rel(*path)).split(/\n/)
8
+ end
9
9
 
10
- inputs.zip(outputs).each do |word, expected_output|
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
@@ -1,4 +1,4 @@
1
- require "preamble"
1
+ require File.join(File.dirname(__FILE__), 'preamble')
2
2
  require "text/soundex"
3
3
  require 'yaml'
4
4
 
@@ -1,4 +1,4 @@
1
- require "preamble"
1
+ require File.join(File.dirname(__FILE__), '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.0.5
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-04 00:00:00.000000000 Z
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.23
69
+ rubygems_version: 1.8.11
71
70
  signing_key:
72
71
  specification_version: 3
73
72
  summary: A collection of text algorithms
@@ -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