class ClassifierReborn::CachedContentNode
Subclass of ContentNode which caches the search_vector transpositions. Its great because its much faster for large indexes, but at the cost of more ram. Additionally, if you Marshal your classifier and want to keep the size down, you'll need to manually clear the cache before you dump
Public Class Methods
new( word_hash, *categories )
click to toggle source
Calls superclass method
# File lib/classifier-reborn/lsi/cached_content_node.rb, line 19 def initialize( word_hash, *categories ) clear_cache! super end
Public Instance Methods
clear_cache!()
click to toggle source
# File lib/classifier-reborn/lsi/cached_content_node.rb, line 24 def clear_cache! @transposed_search_vector = nil end
marshal_dump()
click to toggle source
We don't want the cached_data here
# File lib/classifier-reborn/lsi/cached_content_node.rb, line 40 def marshal_dump [@lsi_vector, @lsi_norm, @raw_vector, @raw_norm, @categories, @word_hash] end
marshal_load(array)
click to toggle source
# File lib/classifier-reborn/lsi/cached_content_node.rb, line 44 def marshal_load(array) @lsi_vector, @lsi_norm, @raw_vector, @raw_norm, @categories, @word_hash = array end
raw_vector_with( word_list )
click to toggle source
Clear the cache before we continue on
Calls superclass method
# File lib/classifier-reborn/lsi/cached_content_node.rb, line 34 def raw_vector_with( word_list ) clear_cache! super end
transposed_search_vector()
click to toggle source
Cache the transposed vector, it gets used a lot
Calls superclass method
# File lib/classifier-reborn/lsi/cached_content_node.rb, line 29 def transposed_search_vector @transposed_search_vector ||= super end