Permalink
Browse files

Revert "Merge pull request #11 from todorus/feature/rails3"

Some of the tests have gone rogue, reversing.

This reverts commit 2a13c3c, reversing
changes made to 634fd8f.
  • Loading branch information...
1 parent 2a13c3c commit 3c7b6a4da4ff7148e6b055b29a1db41afa71a0e1 @josephwilk committed Nov 26, 2013
Showing with 251 additions and 172 deletions.
  1. +0 −1 Gemfile
  2. +0 −31 Gemfile.lock
  3. +0 −46 Guardfile
  4. +0 −1 lib/rsemantic/transform.rb
  5. +0 −1 lib/rsemantic/vector_space.rb
  6. +12 −12 lib/{rsemantic.rb → semantic.rb}
  7. +1 −1 lib/{rsemantic → semantic}/compare.rb
  8. +4 −4 lib/{rsemantic → semantic}/corpus.rb
  9. +1 −1 lib/{rsemantic → semantic}/document.rb
  10. +6 −6 lib/{rsemantic → semantic}/matrix_transformer.rb
  11. +1 −1 lib/{rsemantic → semantic}/parser.rb
  12. +3 −3 lib/{rsemantic → semantic}/search.rb
  13. +1 −1 lib/{rsemantic → semantic}/search_result.rb
  14. +1 −0 lib/semantic/transform.rb
  15. +1 −1 lib/{rsemantic → semantic}/transform/lsa_transform.rb
  16. +1 −1 lib/{rsemantic → semantic}/transform/tf_idf_transform.rb
  17. +1 −0 lib/semantic/vector_space.rb
  18. +1 −1 lib/{rsemantic → semantic}/vector_space/builder.rb
  19. +1 −1 lib/{rsemantic → semantic}/vector_space/model.rb
  20. +1 −1 lib/{rsemantic → semantic}/version.rb
  21. +1 −1 spec/bugs_spec.rb
  22. +1 −1 spec/{rsemantic → semantic}/compare_spec.rb
  23. +5 −5 spec/{rsemantic → semantic}/matrix_transformer_spec.rb
  24. +11 −11 spec/{rsemantic → semantic}/parser_spec.rb
  25. +24 −24 spec/{rsemantic → semantic}/search_spec.rb
  26. +67 −0 spec/semantic/transform/lsa_transform_spec.rb
  27. +35 −0 spec/semantic/transform/tf_idf_transform_spec.rb
  28. +43 −0 spec/semantic/vector_space/builder_spec.rb
  29. +22 −0 spec/semantic/vector_space/model_spec.rb
  30. +0 −9 spec/semantic_spec.rb
  31. +2 −2 spec/spec_helper.rb
  32. +3 −3 spec_integration/{rsemantic_spec.rb → semantic_spec.rb}
  33. +1 −1 spec_integration/spec_helper.rb
  34. +0 −1 tmp/rspec_guard_result
View
@@ -7,6 +7,5 @@ group :test, :development do
gem 'rspec'
gem 'limited_red'
gem 'rake'
- gem 'guard-rspec', require: false
end
View
@@ -2,55 +2,28 @@ GEM
remote: http://rubygems.org/
specs:
builder (3.2.0)
- celluloid (0.15.2)
- timers (~> 1.1.0)
- coderay (1.1.0)
cucumber (1.2.2)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.11.6)
multi_json (~> 1.3)
diff-lcs (1.2.1)
fast-stemmer (1.0.2)
- ffi (1.9.3)
- formatador (0.2.4)
gherkin (2.11.6)
json (>= 1.7.6)
gsl (1.15.3)
narray (>= 0.5.9)
- guard (2.2.4)
- formatador (>= 0.2.4)
- listen (~> 2.1)
- lumberjack (~> 1.0)
- pry (>= 0.9.12)
- thor (>= 0.18.1)
- guard-rspec (3.1.0)
- guard (>= 1.8)
- rspec (~> 2.13)
httparty (0.8.1)
multi_json
multi_xml
json (1.7.7)
limited_red (0.4.8)
cucumber (>= 1.1.4)
httparty (= 0.8.1)
- listen (2.2.0)
- celluloid (>= 0.15.2)
- rb-fsevent (>= 0.9.3)
- rb-inotify (>= 0.9)
- lumberjack (1.0.4)
- method_source (0.8.2)
multi_json (1.6.1)
multi_xml (0.5.3)
narray (0.6.0.8)
- pry (0.9.12.4)
- coderay (~> 1.0)
- method_source (~> 0.8)
- slop (~> 3.4)
rake (10.0.3)
- rb-fsevent (0.9.3)
- rb-inotify (0.9.2)
- ffi (>= 0.5.0)
rspec (2.13.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
@@ -59,17 +32,13 @@ GEM
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.0)
- slop (3.4.7)
- thor (0.18.1)
- timers (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
fast-stemmer
gsl
- guard-rspec
limited_red
rake
rspec
View
@@ -1,46 +0,0 @@
-# A sample Guardfile
-# More info at https://github.com/guard/guard#readme
-
-guard :rspec do
- watch(%r{^spec/.+_spec\.rb$})
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
- watch('spec/spec_helper.rb') { "spec" }
-
- # Rails example
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
- watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
- watch('config/routes.rb') { "spec/routing" }
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
-
- # Capybara features specs
- watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
-
- # Turnip features and steps
- watch(%r{^spec/acceptance/(.+)\.feature$})
- watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
-end
-
-
-guard :rspec do
- watch(%r{^spec/.+_spec\.rb$})
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
- watch('spec/spec_helper.rb') { "spec" }
-
- # Rails example
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
- watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
- watch('config/routes.rb') { "spec/routing" }
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
-
- # Capybara features specs
- watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
-
- # Turnip features and steps
- watch(%r{^spec/acceptance/(.+)\.feature$})
- watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
-end
-
@@ -1 +0,0 @@
-%w{tf_idf lsa}.each{|f| require "rsemantic/transform/#{f}_transform.rb"}
@@ -1 +0,0 @@
-%w{model builder}.each{|f| require "rsemantic/vector_space/#{f}"}
@@ -1,25 +1,25 @@
$:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
-require "rsemantic/vector_space"
-require "rsemantic/compare"
-require "rsemantic/parser"
-require "rsemantic/matrix_transformer"
-require "rsemantic/search"
-require "rsemantic/transform"
-require "rsemantic/version"
-
-require "rsemantic/corpus"
-require "rsemantic/document"
-require "rsemantic/search_result"
+require "semantic/vector_space"
+require "semantic/compare"
+require "semantic/parser"
+require "semantic/matrix_transformer"
+require "semantic/search"
+require "semantic/transform"
+require "semantic/version"
+
+require "semantic/corpus"
+require "semantic/document"
+require "semantic/search_result"
require 'rubygems'
require 'gsl'
require 'stemmer'
require 'logger'
-module RSemantic
+module Semantic
class << self
attr_writer :logger
@@ -1,4 +1,4 @@
-module RSemantic
+module Semantic
class Compare
class << self
@@ -1,4 +1,4 @@
-module RSemantic
+module Semantic
class Corpus
# @return [Array<Document>]
attr_reader :documents
@@ -30,22 +30,22 @@ def add_document(document)
#
# @return [void]
def build_index
- @search = RSemantic::Search.new(@documents.map(&:text), @options)
+ @search = Semantic::Search.new(@documents.map(&:text), @options)
end
def search(*words)
# TODO raise if no index built yet
results = @search.search(words)
results.map.with_index { |result, index|
document = @documents[index]
- RSemantic::SearchResult.new(document, result)
+ Semantic::SearchResult.new(document, result)
}.sort
end
def find_related_document(document)
@search.related(@documents.index(document)).map.with_index { |result, index|
document = @documents[index]
- RSemantic::SearchResult.new(document, result)
+ Semantic::SearchResult.new(document, result)
}.sort
end
@@ -1,4 +1,4 @@
-module RSemantic
+module Semantic
class Document
attr_reader :text
attr_reader :attributes
@@ -1,4 +1,4 @@
-module RSemantic
+module Semantic
class MatrixTransformer
def initialize(transforms)
@@ -8,13 +8,13 @@ def initialize(transforms)
def apply_transforms(vector_space_model)
@transforms.each do |transform|
begin
- transform_class = RSemantic::Transform.const_get(transform)
- RSemantic.logger.info("Applying #{transform} transform")
+ transform_class = Semantic::Transform.const_get(transform)
+ Semantic.logger.info("Applying #{transform} transform")
transform_class.transform!(vector_space_model.matrix)
- RSemantic.logger.info(vector_space_model)
+ Semantic.logger.info(vector_space_model)
rescue => e
- RSemantic.logger.error("Error: Cannot perform transform: #{transform}")
- RSemantic.logger.error(e)
+ Semantic.logger.error("Error: Cannot perform transform: #{transform}")
+ Semantic.logger.error(e)
end
end
vector_space_model
@@ -1,6 +1,6 @@
require "set"
-module RSemantic
+module Semantic
class Parser
def initialize(options = {})
@@ -1,4 +1,4 @@
-module RSemantic
+module Semantic
class Search
def initialize(documents, options = {})
@@ -8,15 +8,15 @@ def initialize(documents, options = {})
:filter_stop_words => true,
:stem_words => true,
}.merge(options)
- RSemantic.logger.level = options[:verbose] ? Logger::INFO : Logger::ERROR
+ Semantic.logger.level = options[:verbose] ? Logger::INFO : Logger::ERROR
@builder = VectorSpace::Builder.new(:filter_stop_words => options[:filter_stop_words], :stem_words => options[:stem_words])
@matrix_transformer = MatrixTransformer.new(options[:transforms])
@vector_space_model = @builder.build_document_matrix(documents)
- RSemantic.logger.info(@vector_space_model)
+ Semantic.logger.info(@vector_space_model)
@vector_space_model = @matrix_transformer.apply_transforms(@vector_space_model)
end
@@ -1,4 +1,4 @@
-module RSemantic
+module Semantic
class SearchResult
include Comparable
@@ -0,0 +1 @@
+%w{tf_idf lsa}.each{|f| require "semantic/transform/#{f}_transform.rb"}
@@ -1,4 +1,4 @@
-module RSemantic
+module Semantic
module Transform
class LSA
@@ -1,4 +1,4 @@
-module RSemantic
+module Semantic
module Transform
class TFIDF
@@ -0,0 +1 @@
+%w{model builder}.each{|f| require "semantic/vector_space/#{f}"}
@@ -1,4 +1,4 @@
-module RSemantic
+module Semantic
module VectorSpace
# A algebraic model for representing text documents as vectors of identifiers.
# A document is represented as a vector. Each dimension of the vector corresponds to a
@@ -2,7 +2,7 @@
require 'delegate'
require 'stringio'
-module RSemantic
+module Semantic
module VectorSpace
class Model < DelegateClass(::GSL::Matrix)
@@ -1,4 +1,4 @@
-module RSemantic #:nodoc:
+module Semantic #:nodoc:
class VERSION #:nodoc:
MAJOR = 0
MINOR = 2
View
@@ -6,7 +6,7 @@
"A cat is a fine pet ponies.",
"Do and cats make good pets.",
"I haven't got a cat."]
- @search = RSemantic::Search.new(documents)
+ @search = Semantic::Search.new(documents)
end
describe "finding the related document weightings" do
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/../spec_helper'
-module RSemantic
+module Semantic
describe Compare do
it "should calculate cosine" do
@@ -1,9 +1,9 @@
require File.dirname(__FILE__) + '/../spec_helper'
-module RSemantic
+module Semantic
describe MatrixTransformer do
- let(:mock_transform){ double(Transform) }
- let(:mock_vector_space){ double("vector space", :matrix => GSL::Matrix[[1,0],[0,1]], :matrix= => nil ) }
+ let(:mock_transform){ mock(Transform) }
+ let(:mock_vector_space){ mock("vector space", :matrix => GSL::Matrix[[1,0],[0,1]], :matrix= => nil ) }
describe "transforming matrix" do
@@ -16,7 +16,7 @@ module RSemantic
it "should send transform message to class to transform matrix" do
matrix_transformer = MatrixTransformer.new(:transforms => [:LSA])
- Transform.stub(:const_get).and_return(mock_transform)
+ Transform.stub!(:const_get).and_return(mock_transform)
mock_transform.should_receive(:transform!)
@@ -28,7 +28,7 @@ class DudTransform
end
matrix_transformer = MatrixTransformer.new(:transforms => [:DudTransform])
- Transform.stub(:const_get).and_return(DudTransform.new)
+ Transform.stub!(:const_get).and_return(DudTransform.new)
matrix_transformer.apply_transforms(mock_vector_space)
end
Oops, something went wrong. Retry.

0 comments on commit 3c7b6a4

Please sign in to comment.