Mailing List Archive

r3676 - in trunk: c_src/KinoSearch/Highlight c_src/KinoSearch/Search perl perl/lib/KinoSearch/Highlight perl/lib/KinoSearch/Search perl/t
Author: creamyg
Date: 2008-07-29 23:37:28 -0700 (Tue, 29 Jul 2008)
New Revision: 3676

Added:
trunk/c_src/KinoSearch/Search/Span.bp
trunk/c_src/KinoSearch/Search/Span.c
trunk/perl/lib/KinoSearch/Search/Span.pm
trunk/perl/t/309-span.t
Removed:
trunk/c_src/KinoSearch/Highlight/HighlightSpan.bp
trunk/c_src/KinoSearch/Highlight/HighlightSpan.c
trunk/perl/lib/KinoSearch/Highlight/HighlightSpan.pm
trunk/perl/t/309-highlight_span.t
Modified:
trunk/c_src/KinoSearch/Highlight/HeatMap.bp
trunk/c_src/KinoSearch/Highlight/HeatMap.c
trunk/c_src/KinoSearch/Highlight/Highlighter.c
trunk/c_src/KinoSearch/Search/ANDQuery.c
trunk/c_src/KinoSearch/Search/Compiler.bp
trunk/c_src/KinoSearch/Search/MatchAllQuery.c
trunk/c_src/KinoSearch/Search/PhraseQuery.c
trunk/c_src/KinoSearch/Search/PolyQuery.c
trunk/c_src/KinoSearch/Search/RangeQuery.c
trunk/c_src/KinoSearch/Search/TermQuery.c
trunk/perl/MANIFEST
trunk/perl/t/303-highlighter.t
trunk/perl/t/310-heat_map.t
Log:
Move KinoSearch::Highlight::HighlightSpan to KinoSearch::Search::Span and
define it more generally. Port Span's accessors and documentation.


Modified: trunk/c_src/KinoSearch/Highlight/HeatMap.bp
===================================================================
--- trunk/c_src/KinoSearch/Highlight/HeatMap.bp 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/c_src/KinoSearch/Highlight/HeatMap.bp 2008-07-30 06:37:28 UTC (rev 3676)
@@ -9,7 +9,7 @@
new(VArray *spans, u32_t window = 133);

/**
- * @param spans An array of HighlightSpans, which need not be sorted.
+ * @param spans An array of Spans, which need not be sorted.
* @param window The greatest distance between which heat points may
* reinforce each other.
*/
@@ -27,8 +27,8 @@
* Span 2: positions 16-20, score .8
* Span 3: positions 20-30, score .5
*
- * @param spans An array of HighlightSpans. The spans must be sorted by
- * offset then length.
+ * @param spans An array of Spans, which must be sorted by offset then
+ * length.
*/
incremented VArray*
Flatten_Spans(HeatMap *self, VArray *spans);
@@ -38,14 +38,13 @@
* at the edge of the <code>window</code>.
*/
float
- Calc_Proximity_Boost(HeatMap *self, HighlightSpan *span1,
- HighlightSpan *span2);
+ Calc_Proximity_Boost(HeatMap *self, Span *span1, Span *span2);

/** Iterate through a sorted array of spans, generating a new span for
* each pair that yields a non-zero proximity boost.
*
- * @param spans An array of HighlightSpans. The spans must be sorted by
- * offset then length.
+ * @param spans An array of Spans, which must be sorted by offset then
+ * length.
*/
incremented VArray*
Generate_Proximity_Boosts(HeatMap *self, VArray *spans);

Modified: trunk/c_src/KinoSearch/Highlight/HeatMap.c
===================================================================
--- trunk/c_src/KinoSearch/Highlight/HeatMap.c 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/c_src/KinoSearch/Highlight/HeatMap.c 2008-07-30 06:37:28 UTC (rev 3676)
@@ -1,7 +1,7 @@
#include "KinoSearch/Util/ToolSet.h"

#include "KinoSearch/Highlight/HeatMap.h"
-#include "KinoSearch/Highlight/HighlightSpan.h"
+#include "KinoSearch/Search/Span.h"
#include "KinoSearch/Util/Native.h"

HeatMap*
@@ -20,10 +20,10 @@
self->spans = NULL;
self->window = window;

- VA_Sort(spans_copy, HLSpan_compare);
+ VA_Sort(spans_copy, Span_compare);
spans_plus_boosts = HeatMap_Generate_Proximity_Boosts(self, spans_copy);
VA_Push_VArray(spans_plus_boosts, spans_copy);
- VA_Sort(spans_plus_boosts, HLSpan_compare);
+ VA_Sort(spans_plus_boosts, Span_compare);
self->spans = HeatMap_Flatten_Spans(self, spans_plus_boosts);
REFCOUNT_DEC(spans_copy);
REFCOUNT_DEC(spans_plus_boosts);
@@ -57,7 +57,7 @@

/* Assemble a list of all unique start/end boundaries. */
for (i = 0; i < num_spans; i++) {
- HighlightSpan *span = (HighlightSpan*)VA_Fetch(spans, i);
+ Span *span = (Span*)VA_Fetch(spans, i);
bounds[i] = span->offset;
bounds[i + num_spans] = span->offset + span->length;
}
@@ -69,12 +69,12 @@
}
}

- /* Create one HighlightSpan for each zone between two bounds. */
+ /* Create one Span for each zone between two bounds. */
flattened = VA_new(num_bounds - 1);
for (i = 0; i < num_bounds - 1; i++) {
- u32_t start = bounds[i];
- u32_t length = bounds[i + 1] - start;
- HighlightSpan *span = HLSpan_new(start, length, 0.0f);
+ u32_t start = bounds[i];
+ u32_t length = bounds[i + 1] - start;
+ Span *span = Span_new(start, length, 0.0f);
VA_Push(flattened, (Obj*)span);
REFCOUNT_DEC(span);
}
@@ -99,23 +99,21 @@
/* Iterate over each of the source spans, contributing their scores to
* any destination span that falls within range. */
for (i = 0; i < spans->size; i++) {
- HighlightSpan *source_span = (HighlightSpan*)VA_Fetch(spans, i);
+ Span *source_span = (Span*)VA_Fetch(spans, i);
u32_t j;
u32_t source_span_end = source_span->offset + source_span->length;

/* Get the location of the flattened span that shares the source
* span's offset. */
for ( ; dest_tick < flattened->size; dest_tick++) {
- HighlightSpan *dest_span
- = (HighlightSpan*)VA_Fetch(flattened, dest_tick);
+ Span *dest_span = (Span*)VA_Fetch(flattened, dest_tick);
if (dest_span->offset == source_span->offset)
break;
}

/* Fill in scores. */
for (j = dest_tick; j < flattened->size; j++) {
- HighlightSpan *dest_span
- = (HighlightSpan*)VA_Fetch(flattened, j);
+ Span *dest_span = (Span*)VA_Fetch(flattened, j);
if (dest_span->offset == source_span_end)
break;
else {
@@ -128,7 +126,7 @@
{
u32_t dest_tick;
for (i = 0, dest_tick = 0; i < flattened->size; i++) {
- HighlightSpan *span = (HighlightSpan*)VA_Fetch(flattened, i);
+ Span *span = (Span*)VA_Fetch(flattened, i);
if (span->weight) {
VA_Store(flattened, dest_tick++, (Obj*)span);
}
@@ -141,12 +139,11 @@
}

float
-HeatMap_calc_proximity_boost(HeatMap *self, HighlightSpan *span1,
- HighlightSpan *span2)
+HeatMap_calc_proximity_boost(HeatMap *self, Span *span1, Span *span2)
{
- int comparison = HLSpan_compare(&span1, &span2);
- HighlightSpan *lower = comparison <= 0 ? span1 : span2;
- HighlightSpan *upper = comparison >= 0 ? span1 : span2;
+ int comparison = Span_compare(&span1, &span2);
+ Span *lower = comparison <= 0 ? span1 : span2;
+ Span *upper = comparison >= 0 ? span1 : span2;
i32_t lower_end_offset = lower->offset + lower->length;
i32_t distance = (i32_t)upper->offset - lower_end_offset;

@@ -172,11 +169,11 @@
u32_t i;
u32_t max = spans->size - 1;
for (i = 0; i < max; i++ ) {
- HighlightSpan *span1 = (HighlightSpan*)VA_Fetch(spans, i);
+ Span *span1 = (Span*)VA_Fetch(spans, i);
u32_t j;

for (j = i + 1; j <= max; j++) {
- HighlightSpan *span2 = (HighlightSpan*)VA_Fetch(spans, j);
+ Span *span2 = (Span*)VA_Fetch(spans, j);
float prox_score
= HeatMap_Calc_Proximity_Boost(self, span1, span2);
if (prox_score == 0) {
@@ -185,8 +182,8 @@
else {
u32_t length = (span2->offset - span1->offset)
+ span2->length;
- HighlightSpan *boost_span = HLSpan_new(span1->offset,
- length, prox_score);
+ Span *boost_span = Span_new(span1->offset, length,
+ prox_score);
VA_Push(boosts, (Obj*)boost_span);
REFCOUNT_DEC(boost_span);
}

Deleted: trunk/c_src/KinoSearch/Highlight/HighlightSpan.bp
===================================================================
--- trunk/c_src/KinoSearch/Highlight/HighlightSpan.bp 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/c_src/KinoSearch/Highlight/HighlightSpan.bp 2008-07-30 06:37:28 UTC (rev 3676)
@@ -1,26 +0,0 @@
-parcel KinoSearch cnick Kino;
-
-class KinoSearch::Highlight::HighlightSpan cnick HLSpan
- extends KinoSearch::Obj {
-
- u32_t offset;
- u32_t length;
- float weight;
-
- static incremented HighlightSpan*
- new(u32_t offset, u32_t length, float weight);
-
- static HighlightSpan*
- init(HighlightSpan *self, u32_t offset, u32_t length,
- float weight);
-
- static int
- compare(const void *va, const void *vb);
-}
-
-/* Copyright 2008 Marvin Humphrey
- *
- * This program is free software; you can redistribute it and/or modify
- * under the same terms as Perl itself.
- */
-

Deleted: trunk/c_src/KinoSearch/Highlight/HighlightSpan.c
===================================================================
--- trunk/c_src/KinoSearch/Highlight/HighlightSpan.c 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/c_src/KinoSearch/Highlight/HighlightSpan.c 2008-07-30 06:37:28 UTC (rev 3676)
@@ -1,38 +0,0 @@
-#include "KinoSearch/Util/ToolSet.h"
-
-#include "KinoSearch/Highlight/HighlightSpan.h"
-
-
-HighlightSpan*
-HLSpan_new(u32_t offset, u32_t length, float weight)
-{
- HighlightSpan *self = (HighlightSpan*)CREATE(NULL, HIGHLIGHTSPAN);
- return HLSpan_init(self, offset, length, weight);
-}
-
-HighlightSpan*
-HLSpan_init(HighlightSpan *self, u32_t offset, u32_t length,
- float weight)
-{
- self->offset = offset;
- self->length = length;
- self->weight = weight;
- return self;
-}
-
-int
-HLSpan_compare(const void *va, const void *vb)
-{
- HighlightSpan *a = *(HighlightSpan**)va;
- HighlightSpan *b = *(HighlightSpan**)vb;
- int comparison = a->offset - b->offset;
- if (comparison == 0) comparison = a->length - b->length;
- return comparison;
-}
-
-/* Copyright 2006-2008 Marvin Humphrey
- *
- * This program is free software; you can redistribute it and/or modify
- * under the same terms as Perl itself.
- */
-

Modified: trunk/c_src/KinoSearch/Highlight/Highlighter.c
===================================================================
--- trunk/c_src/KinoSearch/Highlight/Highlighter.c 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/c_src/KinoSearch/Highlight/Highlighter.c 2008-07-30 06:37:28 UTC (rev 3676)
@@ -6,7 +6,7 @@
#include "KinoSearch/Search/Query.h"
#include "KinoSearch/Search/Searchable.h"
#include "KinoSearch/Highlight/HeatMap.h"
-#include "KinoSearch/Highlight/HighlightSpan.h"
+#include "KinoSearch/Search/Span.h"
#include "KinoSearch/Index/DocVector.h"
#include "KinoSearch/Util/ByteBuf.h"
#include "KinoSearch/Util/IntMap.h"
@@ -92,7 +92,7 @@

top = Highlighter_Raw_Excerpt(self, (CharBuf*)field_val,
(CharBuf*)&fragment, raw_excerpt, top, edges);
- VA_Sort(score_spans, HLSpan_compare);
+ VA_Sort(score_spans, Span_compare);
Highlighter_highlight_excerpt(self, score_spans, raw_excerpt,
highlighted, top);

@@ -112,7 +112,7 @@
float max_score = 0.0f;
u32_t retval = 0;
for (i = heat_map->spans->size; i--; ) {
- HighlightSpan *span = (HighlightSpan*)VA_Fetch(heat_map->spans, i);
+ Span *span = (Span*)VA_Fetch(heat_map->spans, i);
if (span->weight >= max_score) {
retval = span->offset;
max_score = span->weight;
@@ -330,7 +330,7 @@
ZombieCharBuf temp = ZCB_make(raw_excerpt);

for (i = 0; i < spans->size; i++) {
- HighlightSpan *span = (HighlightSpan*)VA_Fetch(spans, i);
+ Span *span = (Span*)VA_Fetch(spans, i);
if (span->offset < top) {
continue;
}

Modified: trunk/c_src/KinoSearch/Search/ANDQuery.c
===================================================================
--- trunk/c_src/KinoSearch/Search/ANDQuery.c 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/c_src/KinoSearch/Search/ANDQuery.c 2008-07-30 06:37:28 UTC (rev 3676)
@@ -2,7 +2,7 @@

#include "KinoSearch/Search/ANDQuery.h"
#include "KinoSearch/Schema.h"
-#include "KinoSearch/Highlight/HighlightSpan.h"
+#include "KinoSearch/Search/Span.h"
#include "KinoSearch/Index/DocVector.h"
#include "KinoSearch/Index/IndexReader.h"
#include "KinoSearch/Search/ANDScorer.h"

Modified: trunk/c_src/KinoSearch/Search/Compiler.bp
===================================================================
--- trunk/c_src/KinoSearch/Search/Compiler.bp 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/c_src/KinoSearch/Search/Compiler.bp 2008-07-30 06:37:28 UTC (rev 3676)
@@ -116,9 +116,10 @@
public void
Normalize(Compiler *self);

- /** Return a list of HighlightSpan objects, indicating where in the
- * given field the text that matches the parent query occurs.
- * The base class's method returns an empty list.
+ /** Return a list of Span objects, indicating where in the given field the
+ * text that matches the parent query occurs. In this case, the span's
+ * offset and length are measured in Unicode code points. The base class's
+ * method returns an empty list.
*
* @param searchable A Searchable.
* @param doc_vec A DocVector.

Modified: trunk/c_src/KinoSearch/Search/MatchAllQuery.c
===================================================================
--- trunk/c_src/KinoSearch/Search/MatchAllQuery.c 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/c_src/KinoSearch/Search/MatchAllQuery.c 2008-07-30 06:37:28 UTC (rev 3676)
@@ -2,7 +2,7 @@

#include "KinoSearch/Search/MatchAllQuery.h"
#include "KinoSearch/Schema.h"
-#include "KinoSearch/Highlight/HighlightSpan.h"
+#include "KinoSearch/Search/Span.h"
#include "KinoSearch/Index/DocVector.h"
#include "KinoSearch/Index/IndexReader.h"
#include "KinoSearch/Search/MatchAllScorer.h"

Modified: trunk/c_src/KinoSearch/Search/PhraseQuery.c
===================================================================
--- trunk/c_src/KinoSearch/Search/PhraseQuery.c 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/c_src/KinoSearch/Search/PhraseQuery.c 2008-07-30 06:37:28 UTC (rev 3676)
@@ -7,7 +7,7 @@
#include "KinoSearch/Posting.h"
#include "KinoSearch/Posting/ScorePosting.h"
#include "KinoSearch/Schema.h"
-#include "KinoSearch/Highlight/HighlightSpan.h"
+#include "KinoSearch/Search/Span.h"
#include "KinoSearch/Index/DocVector.h"
#include "KinoSearch/Index/IndexReader.h"
#include "KinoSearch/Index/PostingList.h"
@@ -367,7 +367,7 @@
i32_t valid_start_posit = IntMap_Get(valid_posits, posit_tick);
i32_t valid_end_posit = valid_start_posit + num_terms;
i32_t start_offset = 0, end_offset = 0;
- HighlightSpan *span;
+ Span *span;

for ( ; i < (u32_t)tv_start_positions->size; i++) {
if (IntMap_Get(tv_start_positions, i) == valid_start_posit) {
@@ -382,7 +382,7 @@
}
}

- span = HLSpan_new(start_offset, end_offset - start_offset, weight);
+ span = Span_new(start_offset, end_offset - start_offset, weight);
VA_Push(spans, (Obj*)span);
REFCOUNT_DEC(span);


Modified: trunk/c_src/KinoSearch/Search/PolyQuery.c
===================================================================
--- trunk/c_src/KinoSearch/Search/PolyQuery.c 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/c_src/KinoSearch/Search/PolyQuery.c 2008-07-30 06:37:28 UTC (rev 3676)
@@ -2,7 +2,7 @@

#include "KinoSearch/Search/PolyQuery.h"
#include "KinoSearch/Schema.h"
-#include "KinoSearch/Highlight/HighlightSpan.h"
+#include "KinoSearch/Search/Span.h"
#include "KinoSearch/Index/DocVector.h"
#include "KinoSearch/Index/IndexReader.h"
#include "KinoSearch/Search/Searchable.h"

Modified: trunk/c_src/KinoSearch/Search/RangeQuery.c
===================================================================
--- trunk/c_src/KinoSearch/Search/RangeQuery.c 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/c_src/KinoSearch/Search/RangeQuery.c 2008-07-30 06:37:28 UTC (rev 3676)
@@ -2,7 +2,7 @@

#include "KinoSearch/Search/RangeQuery.h"
#include "KinoSearch/Schema.h"
-#include "KinoSearch/Highlight/HighlightSpan.h"
+#include "KinoSearch/Search/Span.h"
#include "KinoSearch/Index/DocVector.h"
#include "KinoSearch/Index/IndexReader.h"
#include "KinoSearch/Index/Lexicon.h"

Copied: trunk/c_src/KinoSearch/Search/Span.bp (from rev 3675, trunk/c_src/KinoSearch/Highlight/HighlightSpan.bp)
===================================================================
--- trunk/c_src/KinoSearch/Search/Span.bp (rev 0)
+++ trunk/c_src/KinoSearch/Search/Span.bp 2008-07-30 06:37:28 UTC (rev 3676)
@@ -0,0 +1,70 @@
+parcel KinoSearch cnick Kino;
+
+/** An offset, a length, and a weight.
+ *
+ * Span objects store information about a span across an array of...
+ * something. The unit is context-dependent.
+ *
+ * Text is one possibility, in which case offset and length might be measured
+ * in Unicode code points. However, the Span could also refer to a span
+ * within an array of tokens, for example -- in which case the start and
+ * offset might be measured in token positions.
+ */
+class KinoSearch::Search::Span extends KinoSearch::Obj {
+
+ u32_t offset;
+ u32_t length;
+ float weight;
+
+ static incremented Span*
+ new(u32_t offset, u32_t length, float weight = 0.0);
+
+ /**
+ * @param offset Integer offset, unit is context-dependent.
+ * @param length Integer length, unit is context-dependent.
+ * @param weight A floating point weight.
+ */
+ static Span*
+ init(Span *self, u32_t offset, u32_t length,
+ float weight = 0.0);
+
+ /** Accessor for <code>offset</code> attribute.
+ */
+ u32_t
+ Get_Offset(Span *self);
+
+ /** Setter for <code>offset</code> attribute.
+ */
+ void
+ Set_Offset(Span *self, u32_t offset);
+
+ /** Accessor for <code>length</code> attribute.
+ */
+ u32_t
+ Get_Length(Span *self);
+
+ /** Setter for <code>length</code> attribute.
+ */
+ void
+ Set_Length(Span *self, u32_t length);
+
+ /** Accessor for <code>weight</code> attribute.
+ */
+ float
+ Get_Weight(Span *self);
+
+ /** Setter for <code>weight</code> attribute.
+ */
+ void
+ Set_Weight(Span *self, float weight);
+
+ static int
+ compare(const void *va, const void *vb);
+}
+
+/* Copyright 2008 Marvin Humphrey
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * under the same terms as Perl itself.
+ */
+

Copied: trunk/c_src/KinoSearch/Search/Span.c (from rev 3675, trunk/c_src/KinoSearch/Highlight/HighlightSpan.c)
===================================================================
--- trunk/c_src/KinoSearch/Search/Span.c (rev 0)
+++ trunk/c_src/KinoSearch/Search/Span.c 2008-07-30 06:37:28 UTC (rev 3676)
@@ -0,0 +1,50 @@
+#include "KinoSearch/Util/ToolSet.h"
+
+#include "KinoSearch/Search/Span.h"
+
+Span*
+Span_new(u32_t offset, u32_t length, float weight)
+{
+ Span *self = (Span*)CREATE(NULL, SPAN);
+ return Span_init(self, offset, length, weight);
+}
+
+Span*
+Span_init(Span *self, u32_t offset, u32_t length,
+ float weight)
+{
+ self->offset = offset;
+ self->length = length;
+ self->weight = weight;
+ return self;
+}
+
+u32_t
+Span_get_offset(Span *self) { return self->offset; }
+u32_t
+Span_get_length(Span *self) { return self->length; }
+float
+Span_get_weight(Span *self) { return self->weight; }
+void
+Span_set_offset(Span *self, u32_t offset) { self->offset = offset; }
+void
+Span_set_length(Span *self, u32_t length) { self->length = length; }
+void
+Span_set_weight(Span *self, float weight) { self->weight = weight; }
+
+int
+Span_compare(const void *va, const void *vb)
+{
+ Span *a = *(Span**)va;
+ Span *b = *(Span**)vb;
+ int comparison = a->offset - b->offset;
+ if (comparison == 0) comparison = a->length - b->length;
+ return comparison;
+}
+
+/* Copyright 2006-2008 Marvin Humphrey
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * under the same terms as Perl itself.
+ */
+

Modified: trunk/c_src/KinoSearch/Search/TermQuery.c
===================================================================
--- trunk/c_src/KinoSearch/Search/TermQuery.c 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/c_src/KinoSearch/Search/TermQuery.c 2008-07-30 06:37:28 UTC (rev 3676)
@@ -2,7 +2,7 @@

#include "KinoSearch/Search/TermQuery.h"
#include "KinoSearch/Schema.h"
-#include "KinoSearch/Highlight/HighlightSpan.h"
+#include "KinoSearch/Search/Span.h"
#include "KinoSearch/Index/DocVector.h"
#include "KinoSearch/Index/IndexReader.h"
#include "KinoSearch/Index/PostingList.h"
@@ -244,8 +244,7 @@
for (i = 0; i < starts->size; i++) {
i32_t start = IntMap_Get(starts, i);
i32_t length = IntMap_Get(ends, i) - start;
- HighlightSpan *span = HLSpan_new(start, length,
- TermCompiler_Get_Weight(self));
+ Span *span = Span_new(start, length, TermCompiler_Get_Weight(self));
VA_Push(spans, (Obj*)span);
REFCOUNT_DEC(span);
}

Modified: trunk/perl/MANIFEST
===================================================================
--- trunk/perl/MANIFEST 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/perl/MANIFEST 2008-07-30 06:37:28 UTC (rev 3676)
@@ -73,7 +73,6 @@
lib/KinoSearch/FieldSpec/text.pm
lib/KinoSearch/Highlight/HeatMap.pm
lib/KinoSearch/Highlight/Highlighter.pm
-lib/KinoSearch/Highlight/HighlightSpan.pm
lib/KinoSearch/Index/DelDocs.pm
lib/KinoSearch/Index/DocReader.pm
lib/KinoSearch/Index/DocVector.pm
@@ -158,6 +157,7 @@
lib/KinoSearch/Search/Similarity.pm
lib/KinoSearch/Search/SortedHitQueue.pm
lib/KinoSearch/Search/SortSpec.pm
+lib/KinoSearch/Search/Span.pm
lib/KinoSearch/Search/Tally.pm
lib/KinoSearch/Search/TermQuery.pm
lib/KinoSearch/Search/TermScorer.pm
@@ -338,7 +338,7 @@
t/305-invindexer.t
t/306-dynamic_schema.t
t/308-simple.t
-t/309-highlight_span.t
+t/309-span.t
t/310-heat_map.t
t/501-termquery.t
t/502-phrasequery.t

Deleted: trunk/perl/lib/KinoSearch/Highlight/HighlightSpan.pm
===================================================================
--- trunk/perl/lib/KinoSearch/Highlight/HighlightSpan.pm 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/perl/lib/KinoSearch/Highlight/HighlightSpan.pm 2008-07-30 06:37:28 UTC (rev 3676)
@@ -1,59 +0,0 @@
-use KinoSearch;
-
-1;
-
-__END__
-
-__AUTO_XS__
-
-{ "KinoSearch::Highlight::HighlightSpan" => {
- make_getters => [qw( offset length weight )],
- make_setters => [qw( offset length weight )],
- make_constructors => ["new"],
- }
-}
-
-__POD__
-
-=head1 NAME
-
-KinoSearch::Highlight::HighlightSpan - Character offsets and weights for words in a field
-
-=head1 DESCRIPTION
-
-Objects of this class store information about a span of text that is a
-possible candidate for highlighting.
-
-=head1 METHODS
-
-=head2 new
-
- my $highlighter = KinoSearch::Highlight::Highlighter->new(
- offset => 75,
- length => 7,
- weight => 1,
- );
-
-Constructor.
-
-=head2 get_offset
-
-Accessor method.
-
-=head2 get_length
-
-Likewise.
-
-=head2 get_weight
-
-This one, too.
-
-=head1 COPYRIGHT
-
-Copyright 2005-2008 Marvin Humphrey
-
-=head1 LICENSE, DISCLAIMER, BUGS, etc.
-
-See L<KinoSearch> version 0.20.
-
-=cut

Copied: trunk/perl/lib/KinoSearch/Search/Span.pm (from rev 3675, trunk/perl/lib/KinoSearch/Highlight/HighlightSpan.pm)
===================================================================
--- trunk/perl/lib/KinoSearch/Search/Span.pm (rev 0)
+++ trunk/perl/lib/KinoSearch/Search/Span.pm 2008-07-30 06:37:28 UTC (rev 3676)
@@ -0,0 +1,58 @@
+use KinoSearch;
+
+1;
+
+__END__
+
+__AUTO_XS__
+
+my $synopsis = <<'END_SYNOPSIS';
+ my $combined_length = $upper_span->get_length
+ + ( $upper_span->get_offset - $lower_span->get_offset );
+ my $combined_span = KinoSearch::Search::Span->new(
+ offset => $lower_span->get_offset,
+ length => $combined_length,
+ );
+ ...
+END_SYNOPSIS
+
+my $constructor = <<'END_CONSTRUCTOR';
+ my $span = KinoSearch::Search::Span->new(
+ offset => 75, # required
+ length => 7, # required
+ weight => 1.0, # default 0.0
+ );
+END_CONSTRUCTOR
+
+{ "KinoSearch::Search::Span" => {
+ bind_methods => [.
+ qw( set_offset
+ get_offset
+ set_length
+ get_length
+ set_weight
+ get_weight )
+ ],
+ make_constructors => ["new"],
+ make_pod => {
+ synopsis => $synopsis,
+ constructor => { sample => $constructor },
+ methods => [.
+ qw( set_offset
+ get_offset
+ set_length
+ get_length
+ set_weight
+ get_weight )
+ ],
+ }
+ }
+}
+
+__COPYRIGHT__
+
+Copyright 2008 Marvin Humphrey
+
+This program is free software; you can redistribute it and/or modify
+under the same terms as Perl itself.
+

Modified: trunk/perl/t/303-highlighter.t
===================================================================
--- trunk/perl/t/303-highlighter.t 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/perl/t/303-highlighter.t 2008-07-30 06:37:28 UTC (rev 3676)
@@ -328,12 +328,12 @@
sub make_spans {
my $spans = KinoSearch::Util::VArray->new( capacity => @_ / 2 );
for my $span_spec (@_) {
- my $hl_span = KinoSearch::Highlight::HighlightSpan->new(
+ my $span = KinoSearch::Search::Span->new(
offset => $span_spec->[0],
length => $span_spec->[1],
weight => 1,
);
- $spans->push($hl_span);
+ $spans->push($span);
}
return $spans;
}

Deleted: trunk/perl/t/309-highlight_span.t
===================================================================
--- trunk/perl/t/309-highlight_span.t 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/perl/t/309-highlight_span.t 2008-07-30 06:37:28 UTC (rev 3676)
@@ -1,26 +0,0 @@
-use strict;
-use warnings;
-use lib 'buildlib';
-
-use Test::More tests => 6;
-
-use KinoSearch::Highlight::HighlightSpan;
-
-my $span = KinoSearch::Highlight::HighlightSpan->new(
- offset => 2,
- length => 3,
- weight => 7,
-);
-
-is( $span->get_offset, 2, "get_offset" );
-is( $span->get_length, 3, "get_length" );
-is( $span->get_weight, 7, "get_weight" );
-
-$span->set_offset(10);
-$span->set_length(1);
-$span->set_weight(4);
-
-is( $span->get_offset, 10, "set_offset" );
-is( $span->get_length, 1, "set_length" );
-is( $span->get_weight, 4, "set_weight" );
-

Copied: trunk/perl/t/309-span.t (from rev 3675, trunk/perl/t/309-highlight_span.t)
===================================================================
--- trunk/perl/t/309-span.t (rev 0)
+++ trunk/perl/t/309-span.t 2008-07-30 06:37:28 UTC (rev 3676)
@@ -0,0 +1,26 @@
+use strict;
+use warnings;
+use lib 'buildlib';
+
+use Test::More tests => 6;
+
+use KinoSearch::Search::Span;
+
+my $span = KinoSearch::Search::Span->new(
+ offset => 2,
+ length => 3,
+ weight => 7,
+);
+
+is( $span->get_offset, 2, "get_offset" );
+is( $span->get_length, 3, "get_length" );
+is( $span->get_weight, 7, "get_weight" );
+
+$span->set_offset(10);
+$span->set_length(1);
+$span->set_weight(4);
+
+is( $span->get_offset, 10, "set_offset" );
+is( $span->get_length, 1, "set_length" );
+is( $span->get_weight, 4, "set_weight" );
+

Modified: trunk/perl/t/310-heat_map.t
===================================================================
--- trunk/perl/t/310-heat_map.t 2008-07-30 03:39:39 UTC (rev 3675)
+++ trunk/perl/t/310-heat_map.t 2008-07-30 06:37:28 UTC (rev 3676)
@@ -3,7 +3,7 @@
use Test::More tests => 13;

use KinoSearch::Highlight::HeatMap;
-use KinoSearch::Highlight::HighlightSpan;
+use KinoSearch::Search::Span;

my $heat_map = KinoSearch::Highlight::HeatMap->new( spans => [], );

@@ -103,7 +103,7 @@
is( scalar @$boosts, 2 + 1, "boosts not generated for out of range span" );

sub make_span {
- return KinoSearch::Highlight::HighlightSpan->new(
+ return KinoSearch::Search::Span->new(
offset => $_[0],
length => $_[1],
weight => $_[2],


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits