adjust rwi index result word position handling used for rwi ranking

- correct WordReferenceVars.toRowEntry posintext parameter
to set expected min posintext (the difference is on multi-word queries,
while positions are ordered by search word order).
- modified posofphrase/posinphrase join operation
 - to set min posofphrase
 - and keep posinphrase if not same posofphrase (was set to 0, no differentiation during ranking)
+ fix compiler msg (missing type declaration)
pull/77/head
reger 8 years ago
parent 14f7577231
commit 681a61dafb

@ -268,7 +268,7 @@ public final class WordReferenceRow extends AbstractReference implements WordRef
@Override @Override
public Collection<Integer> positions() { public Collection<Integer> positions() {
int pos = (int) this.entry.getColLong(col_posintext); int pos = (int) this.entry.getColLong(col_posintext);
ArrayList arr = new ArrayList<Integer>(1); ArrayList<Integer> arr = new ArrayList<Integer>(1);
arr.add(pos); arr.add(pos);
return arr; return arr;
} }

@ -253,7 +253,7 @@ public class WordReferenceVars extends AbstractReference implements WordReferenc
this.hitcount, // how often appears this word in the text this.hitcount, // how often appears this word in the text
this.wordsintext, // total number of words this.wordsintext, // total number of words
this.phrasesintext, // total number of phrases this.phrasesintext, // total number of phrases
this.positions.isEmpty() ? 0 : this.positions.iterator().next(), // position of word in all words ( this.positions.isEmpty() ? 0 : minposition(), // position of word in all words (WordReferenceRow stores first position in text, minpos also important for joined references)
this.posinphrase, // position of word in its phrase this.posinphrase, // position of word in its phrase
this.posofphrase, // number of the phrase where word appears this.posofphrase, // number of the phrase where word appears
this.lastModified, // last-modified time of the document where word appears this.lastModified, // last-modified time of the document where word appears
@ -383,8 +383,17 @@ public class WordReferenceVars extends AbstractReference implements WordReferenc
final WordReference oe = (WordReference) r; final WordReference oe = (WordReference) r;
this.positions.addAll(oe.positions()); this.positions.addAll(oe.positions());
this.posinphrase = (this.posofphrase == oe.posofphrase()) ? Math.min(this.posinphrase, oe.posinphrase()) : 0;
this.posofphrase = Math.min(this.posofphrase, oe.posofphrase()); // join phrase
// this.posinphrase = (this.posofphrase == oe.posofphrase()) ? Math.min(this.posinphrase, oe.posinphrase()) : 0;
// this.posofphrase = Math.min(this.posofphrase, oe.posofphrase());
final int oePosofphrase = oe.posofphrase();
if (this.posofphrase == oePosofphrase) {
this.posinphrase = Math.min(this.posinphrase, oe.posinphrase());
} else if (this.posofphrase > oePosofphrase) {
this.posofphrase = oePosofphrase; // choose min posofphrase
this.posinphrase = oe.posinphrase(); // with corresponding posinphrase
}
// combine term frequency // combine term frequency
this.termFrequency = this.termFrequency + oe.termFrequency(); this.termFrequency = this.termFrequency + oe.termFrequency();

Loading…
Cancel
Save