Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: kinosearch: commits

r3679 - in trunk: c_src/KinoSearch/Highlight perl/lib perl/lib/KinoSearch/Highlight

 

 

kinosearch commits RSS feed   Index | Next | Previous | View Threaded


marvin at rectangular

Jul 30, 2008, 11:17 AM

Post #1 of 1 (483 views)
Permalink
r3679 - in trunk: c_src/KinoSearch/Highlight perl/lib perl/lib/KinoSearch/Highlight

Author: creamyg
Date: 2008-07-30 11:17:13 -0700 (Wed, 30 Jul 2008)
New Revision: 3679

Modified:
trunk/c_src/KinoSearch/Highlight/HeatMap.bp
trunk/perl/lib/KinoSearch.pm
trunk/perl/lib/KinoSearch/Highlight/HeatMap.pm
Log:
Remove some of the public API of HeatMap for now, simplifying in anticipation
of refactoring.


Modified: trunk/c_src/KinoSearch/Highlight/HeatMap.bp
===================================================================
--- trunk/c_src/KinoSearch/Highlight/HeatMap.bp 2008-07-30 16:46:21 UTC (rev 3678)
+++ trunk/c_src/KinoSearch/Highlight/HeatMap.bp 2008-07-30 18:17:13 UTC (rev 3679)
@@ -1,5 +1,11 @@
parcel KinoSearch cnick Kino;

+/** Density of relevant data in a string.
+ *
+ * A HeatMap stores a number for each location in a string, indicating the
+ * "heat" (density) of relevant data in that areas that match a search query.
+ */
+
class KinoSearch::Highlight::HeatMap extends KinoSearch::Obj {

VArray *spans;
@@ -9,7 +15,8 @@
new(VArray *spans, u32_t window = 133);

/**
- * @param spans An array of Spans, which need not be sorted.
+ * @param spans An array of Spans, which need not be sorted and will not
+ * be modified.
* @param window The greatest distance between which heat points may
* reinforce each other.
*/

Modified: trunk/perl/lib/KinoSearch/Highlight/HeatMap.pm
===================================================================
--- trunk/perl/lib/KinoSearch/Highlight/HeatMap.pm 2008-07-30 16:46:21 UTC (rev 3678)
+++ trunk/perl/lib/KinoSearch/Highlight/HeatMap.pm 2008-07-30 18:17:13 UTC (rev 3679)
@@ -6,6 +6,13 @@

__AUTO_XS__

+my $constructor = <<'END_CONSTRUCTOR';
+ my $heat_map = KinoSearch::Highlight::HeatMap->new(
+ spans => \@highlight_spans,
+ window => 100,
+ );
+END_CONSTRUCTOR
+
{ "KinoSearch::Highlight::HeatMap" => {
bind_methods => [
qw( calc_proximity_boost
@@ -16,6 +23,10 @@
],
make_getters => [qw( spans window )],
make_constructors => ["_new"],
+ make_pod => {
+ synopsis => " # TODO.\n",
+ constructor => { sample => $constructor },
+ },
}
}

@@ -32,40 +43,3 @@

=head1 METHODS

-=head2 new
-
- my $heat_map = KinoSearch::Highlight::HeatMap->new(
- spans => \@highlight_spans,
- window => 100,
- );
-
-Constructor.
-
-=head2 as_hashref
-
-Returns a hash ref, the keys being locations and the values the density at
-each location.
-
-=head2 hottest
-
-Returns the offset of the hottest location. More or less equivalent to the
-following, but faster:
-
- do { my $h = $heat_map->as_hashref;
- ( sort { $h->{$a} <=> $h->{$b} } keys %$h )[-1]; }
-
-=head2 hot_to_cold
-
- my $ordered = $heat_map->hot_to_cold;
-
-Returns the locations of the highlight spans, from hottest to coldest.
-
-=head1 COPYRIGHT
-
-Copyright 2005-2008 Marvin Humphrey
-
-=head1 LICENSE, DISCLAIMER, BUGS, etc.
-
-See L<KinoSearch> version 0.20.
-
-=cut

Modified: trunk/perl/lib/KinoSearch.pm
===================================================================
--- trunk/perl/lib/KinoSearch.pm 2008-07-30 16:46:21 UTC (rev 3678)
+++ trunk/perl/lib/KinoSearch.pm 2008-07-30 18:17:13 UTC (rev 3679)
@@ -402,41 +402,12 @@
package KinoSearch::Highlight::HeatMap;
use KinoSearch::Util::ToolSet qw( to_kino to_perl );

- our %instance_vars = __PACKAGE__->init_instance_vars(
- # members
- heat_map => \our %heat_map,
- sorted_loc => \our %sorted_loc,
- );
-
sub new {
my ( $either, %args ) = @_;
$args{spans} = to_kino( $args{spans} );
- my $self = $either->_new(%args);
- my $locations = $heat_map{$$self}
- = { map { ( $_->get_offset => $_->get_weight ) }
- @{ $self->get_spans->to_perl } };
-
- # Sort by temperature, lowest to highest.
- $sorted_loc{$$self} = [.
- sort { $locations->{$a} <=> $locations->{$b} }
- keys %$locations
- ];
-
- return $self;
+ return $either->_new(%args);
}

- sub _hottest {
- return $sorted_loc{ ${ +shift } }[-1];
- }
-
- sub as_hashref {
- return $heat_map{ ${ +shift } };
- }
-
- sub hot_to_cold {
- return [ reverse @{ $sorted_loc{ ${ +shift } } } ];
- }
-
sub flatten_spans {
my ( $self, $spans ) = @_;
my $flattened = $self->_flatten_spans( to_kino($spans) );


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits [at] rectangular
http://www.rectangular.com/mailman/listinfo/kinosearch-commits

kinosearch commits RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.