Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #14 from pepijn/master

Add locale and Marshal support to RSemantic::Search
  • Loading branch information...
commit 0c228754b77db6c8c83384cf89e0905cc4cd43d8 2 parents 2edd507 + 9128639
@josephwilk authored
Showing with 21 additions and 2 deletions.
  1. +17 −1 lib/rsemantic/search.rb
  2. +4 −1 lib/rsemantic/vector_space/builder.rb
View
18 lib/rsemantic/search.rb
@@ -11,7 +11,11 @@ def initialize(documents, options = {})
RSemantic.logger.level = options[:verbose] ? Logger::INFO : Logger::ERROR
- @builder = VectorSpace::Builder.new(:filter_stop_words => options[:filter_stop_words], :stem_words => options[:stem_words])
+ @builder = VectorSpace::Builder.new(
+ :filter_stop_words => options[:filter_stop_words],
+ :stem_words => options[:stem_words],
+ :locale => options[:locale]
+ )
@matrix_transformer = MatrixTransformer.new(options[:transforms])
@vector_space_model = @builder.build_document_matrix(documents)
@@ -37,5 +41,17 @@ def search(search_list)
end
ratings
end
+
+ private
+
+ def marshal_dump
+ [@builder, @matrix_transformer, @vector_space_model.to_a]
+ end
+
+ def marshal_load(array)
+ @builder = array.shift
+ @matrix_transformer = array.shift
+ @vector_space_model = GSL::Matrix.alloc(*array.shift)
+ end
end
end
View
5 lib/rsemantic/vector_space/builder.rb
@@ -6,7 +6,10 @@ module VectorSpace
class Builder
def initialize(options = {})
- @parser = Parser.new(:filter_stop_words => options[:filter_stop_words])
+ @parser = Parser.new(
+ :filter_stop_words => options[:filter_stop_words],
+ :locale => options[:locale]
+ )
@parsed_document_cache = []
end
Please sign in to comment.
Something went wrong with that request. Please try again.