@ -27,7 +27,8 @@
package net.yacy.kelondro.data.image ;
package net.yacy.kelondro.data.image ;
import java.util.Collection ;
import java.util.Collection ;
import java.util.concurrent.ConcurrentLinkedQueue ;
import java.util.Queue ;
import java.util.concurrent.LinkedBlockingQueue ;
import net.yacy.kelondro.index.Row.Entry ;
import net.yacy.kelondro.index.Row.Entry ;
import net.yacy.kelondro.order.Bitfield ;
import net.yacy.kelondro.order.Bitfield ;
@ -54,7 +55,7 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
posinphrase , posofphrase ,
posinphrase , posofphrase ,
urlcomps , urllength , virtualAge ,
urlcomps , urllength , virtualAge ,
wordsintext , wordsintitle ;
wordsintext , wordsintitle ;
private final ConcurrentLinked Queue< Integer > positions ;
private final Queue< Integer > positions ;
public double termFrequency ;
public double termFrequency ;
public ImageReferenceVars (
public ImageReferenceVars (
@ -65,7 +66,7 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
final int hitcount , // how often appears this word in the text
final int hitcount , // how often appears this word in the text
final int wordcount , // total number of words
final int wordcount , // total number of words
final int phrasecount , // total number of phrases
final int phrasecount , // total number of phrases
final ConcurrentLinked Queue< Integer > ps , // positions of words that are joined into the reference
final Queue< Integer > ps , // positions of words that are joined into the reference
final int posinphrase , // position of word in its phrase
final int posinphrase , // position of word in its phrase
final int posofphrase , // number of the phrase where word appears
final int posofphrase , // number of the phrase where word appears
final long lastmodified , // last-modified time of the document where word appears
final long lastmodified , // last-modified time of the document where word appears
@ -90,7 +91,7 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
this . llocal = outlinksSame ;
this . llocal = outlinksSame ;
this . lother = outlinksOther ;
this . lother = outlinksOther ;
this . phrasesintext = phrasecount ;
this . phrasesintext = phrasecount ;
this . positions = new Concurrent LinkedQueue< Integer > ( ) ;
this . positions = new LinkedBlocking Queue< Integer > ( ) ;
for ( Integer i : ps ) this . positions . add ( i ) ;
for ( Integer i : ps ) this . positions . add ( i ) ;
this . posinphrase = posinphrase ;
this . posinphrase = posinphrase ;
this . posofphrase = posofphrase ;
this . posofphrase = posofphrase ;
@ -113,7 +114,7 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
this . llocal = e . llocal ( ) ;
this . llocal = e . llocal ( ) ;
this . lother = e . lother ( ) ;
this . lother = e . lother ( ) ;
this . phrasesintext = e . phrasesintext ( ) ;
this . phrasesintext = e . phrasesintext ( ) ;
this . positions = new Concurrent LinkedQueue< Integer > ( ) ;
this . positions = new LinkedBlocking Queue< Integer > ( ) ;
for ( Integer i : e . positions ( ) ) this . positions . add ( i ) ;
for ( Integer i : e . positions ( ) ) this . positions . add ( i ) ;
this . posinphrase = e . posinphrase ( ) ;
this . posinphrase = e . posinphrase ( ) ;
this . posofphrase = e . posofphrase ( ) ;
this . posofphrase = e . posofphrase ( ) ;
@ -184,113 +185,134 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
this . termFrequency = this . termFrequency + v . termFrequency ;
this . termFrequency = this . termFrequency + v . termFrequency ;
}
}
@Override
public Bitfield flags ( ) {
public Bitfield flags ( ) {
return flags;
return this . flags;
}
}
/ *
/ *
public long freshUntil ( ) {
public long freshUntil ( ) {
return freshUntil ;
return freshUntil ;
}
}
* /
* /
@Override
public String getLanguage ( ) {
public String getLanguage ( ) {
return language;
return this . language;
}
}
@Override
public char getType ( ) {
public char getType ( ) {
return type;
return this . type;
}
}
@Override
public int hitcount ( ) {
public int hitcount ( ) {
return hitcount;
return this . hitcount;
}
}
@Override
public boolean isOlder ( final Reference other ) {
public boolean isOlder ( final Reference other ) {
assert false ; // should not be used
assert false ; // should not be used
return false ;
return false ;
}
}
@Override
public long lastModified ( ) {
public long lastModified ( ) {
return lastModified;
return this . lastModified;
}
}
@Override
public int llocal ( ) {
public int llocal ( ) {
return llocal;
return this . llocal;
}
}
@Override
public int lother ( ) {
public int lother ( ) {
return lother;
return this . lother;
}
}
@Override
public int phrasesintext ( ) {
public int phrasesintext ( ) {
return phrasesintext;
return this . phrasesintext;
}
}
@Override
public int posinphrase ( ) {
public int posinphrase ( ) {
return posinphrase;
return this . posinphrase;
}
}
@Override
public Collection < Integer > positions ( ) {
public Collection < Integer > positions ( ) {
return this . positions ;
return this . positions ;
}
}
@Override
public int posofphrase ( ) {
public int posofphrase ( ) {
return posofphrase;
return this . posofphrase;
}
}
public ImageReferenceRow toRowEntry ( ) {
public ImageReferenceRow toRowEntry ( ) {
return new ImageReferenceRow (
return new ImageReferenceRow (
urlHash,
this . urlHash,
urllength, // byte-length of complete URL
this . urllength, // byte-length of complete URL
urlcomps, // number of path components
this . urlcomps, // number of path components
wordsintitle, // length of description/length (longer are better?)
this . wordsintitle, // length of description/length (longer are better?)
hitcount, // how often appears this word in the text
this . hitcount, // how often appears this word in the text
wordsintext, // total number of words
this . wordsintext, // total number of words
phrasesintext, // total number of phrases
this . phrasesintext, // total number of phrases
positions. iterator ( ) . next ( ) , // position of word in all words
this . positions. iterator ( ) . next ( ) , // position of word in all words
posinphrase, // position of word in its phrase
this . posinphrase, // position of word in its phrase
posofphrase, // number of the phrase where word appears
this . posofphrase, // number of the phrase where word appears
lastModified, // last-modified time of the document where word appears
this . lastModified, // last-modified time of the document where word appears
System . currentTimeMillis ( ) , // update time;
System . currentTimeMillis ( ) , // update time;
language, // (guessed) language of document
this . language, // (guessed) language of document
type, // type of document
this . type, // type of document
llocal, // outlinks to same domain
this . llocal, // outlinks to same domain
lother, // outlinks to other domain
this . lother, // outlinks to other domain
flags // attributes to the url and to the word according the url
this . flags // attributes to the url and to the word according the url
) ;
) ;
}
}
@Override
public Entry toKelondroEntry ( ) {
public Entry toKelondroEntry ( ) {
return toRowEntry ( ) . toKelondroEntry ( ) ;
return toRowEntry ( ) . toKelondroEntry ( ) ;
}
}
@Override
public String toPropertyForm ( ) {
public String toPropertyForm ( ) {
return toRowEntry ( ) . toPropertyForm ( ) ;
return toRowEntry ( ) . toPropertyForm ( ) ;
}
}
@Override
public byte [ ] urlhash ( ) {
public byte [ ] urlhash ( ) {
return urlHash;
return this . urlHash;
}
}
@Override
public int urlcomps ( ) {
public int urlcomps ( ) {
return urlcomps;
return this . urlcomps;
}
}
@Override
public int urllength ( ) {
public int urllength ( ) {
return urllength;
return this . urllength;
}
}
@Override
public int virtualAge ( ) {
public int virtualAge ( ) {
return virtualAge;
return this . virtualAge;
}
}
@Override
public int wordsintext ( ) {
public int wordsintext ( ) {
return wordsintext;
return this . wordsintext;
}
}
@Override
public int wordsintitle ( ) {
public int wordsintitle ( ) {
return wordsintitle;
return this . wordsintitle;
}
}
@Override
public double termFrequency ( ) {
public double termFrequency ( ) {
if ( this . termFrequency = = 0.0 ) this . termFrequency = ( ( ( double ) this . hitcount ( ) ) / ( ( double ) ( this . wordsintext ( ) + this . wordsintitle ( ) + 1 ) ) ) ;
if ( this . termFrequency = = 0.0 ) this . termFrequency = ( ( ( double ) this . hitcount ( ) ) / ( ( double ) ( this . wordsintext ( ) + this . wordsintitle ( ) + 1 ) ) ) ;
return this . termFrequency ;
return this . termFrequency ;
@ -340,6 +362,7 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
if ( this . termFrequency < ( d = other . termFrequency ) ) this . termFrequency = d ;
if ( this . termFrequency < ( d = other . termFrequency ) ) this . termFrequency = d ;
}
}
@Override
public void join ( final Reference r ) {
public void join ( final Reference r ) {
// joins two entries into one entry
// joins two entries into one entry