Class: ClassifierReborn::CachedContentNode
- Inherits:
-
ContentNode
- Object
- ContentNode
- ClassifierReborn::CachedContentNode
- Defined in:
- lib/classifier-reborn/lsi/cached_content_node.rb
Overview
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
Defined Under Namespace
Modules: InstanceMethods
Instance Attribute Summary
Attributes inherited from ContentNode
#categories, #lsi_norm, #lsi_vector, #raw_norm, #raw_vector, #word_hash
Instance Method Summary collapse
- #clear_cache! ⇒ Object
-
#initialize(word_hash, *categories) ⇒ CachedContentNode
constructor
A new instance of CachedContentNode.
-
#marshal_dump ⇒ Object
We don’t want the cached_data here.
- #marshal_load(array) ⇒ Object
-
#raw_vector_with(word_list) ⇒ Object
Clear the cache before we continue on.
-
#transposed_search_vector ⇒ Object
Cache the transposed vector, it gets used a lot.
Methods inherited from ContentNode
Constructor Details
#initialize(word_hash, *categories) ⇒ CachedContentNode
Returns a new instance of CachedContentNode.
19 20 21 22 |
# File 'lib/classifier-reborn/lsi/cached_content_node.rb', line 19 def initialize( word_hash, *categories ) clear_cache! super end |
Instance Method Details
#clear_cache! ⇒ Object
24 25 26 |
# File 'lib/classifier-reborn/lsi/cached_content_node.rb', line 24 def clear_cache! @transposed_search_vector = nil end |
#marshal_dump ⇒ Object
We don’t want the cached_data here
40 41 42 |
# 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) ⇒ Object
44 45 46 |
# 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) ⇒ Object
Clear the cache before we continue on
34 35 36 37 |
# File 'lib/classifier-reborn/lsi/cached_content_node.rb', line 34 def raw_vector_with( word_list ) clear_cache! super end |
#transposed_search_vector ⇒ Object
Cache the transposed vector, it gets used a lot
29 30 31 |
# File 'lib/classifier-reborn/lsi/cached_content_node.rb', line 29 def transposed_search_vector @transposed_search_vector ||= super end |