@ -9,7 +9,7 @@
// $LastChangedBy$
// $LastChangedBy$
//
//
// LICENSE
// LICENSE
//
//
// This program is free software; you can redistribute it and/or modify
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// the Free Software Foundation; either version 2 of the License, or
@ -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 ;
@ -43,8 +44,8 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
* object for termination of concurrent blocking queue processing
* object for termination of concurrent blocking queue processing
* /
* /
public static final ImageReferenceVars poison = new ImageReferenceVars ( ) ;
public static final ImageReferenceVars poison = new ImageReferenceVars ( ) ;
public Bitfield flags ;
public Bitfield flags ;
public long lastModified ;
public long lastModified ;
public byte [ ] urlHash ;
public byte [ ] urlHash ;
@ -54,9 +55,9 @@ 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 (
final byte [ ] urlHash ,
final byte [ ] urlHash ,
final int urlLength , // byte-length of complete URL
final int urlLength , // byte-length of complete URL
@ -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 ;
@ -101,7 +102,7 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
this . wordsintitle = titleLength ;
this . wordsintitle = titleLength ;
this . termFrequency = termfrequency ;
this . termFrequency = termfrequency ;
}
}
public ImageReferenceVars ( final ImageReference e ) {
public ImageReferenceVars ( final ImageReference e ) {
this . flags = e . flags ( ) ;
this . flags = e . flags ( ) ;
//this.freshUntil = e.freshUntil();
//this.freshUntil = e.freshUntil();
@ -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 ( ) ;
@ -124,7 +125,7 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
this . wordsintitle = e . wordsintitle ( ) ;
this . wordsintitle = e . wordsintitle ( ) ;
this . termFrequency = e . termFrequency ( ) ;
this . termFrequency = e . termFrequency ( ) ;
}
}
/ * *
/ * *
* initializer for special poison object
* initializer for special poison object
* /
* /
@ -148,7 +149,7 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
this . wordsintitle = 0 ;
this . wordsintitle = 0 ;
this . termFrequency = 0.0 ;
this . termFrequency = 0.0 ;
}
}
@Override
@Override
public ImageReferenceVars clone ( ) {
public ImageReferenceVars clone ( ) {
final ImageReferenceVars c = new ImageReferenceVars (
final ImageReferenceVars c = new ImageReferenceVars (
@ -172,7 +173,7 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
this . termFrequency ) ;
this . termFrequency ) ;
return c ;
return c ;
}
}
public void join ( final ImageReferenceVars v ) {
public void join ( final ImageReferenceVars v ) {
// combine the distance
// combine the distance
this . positions . addAll ( v . positions ) ;
this . positions . addAll ( v . positions ) ;
@ -184,118 +185,139 @@ 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 ;
}
}
public final void min ( final ImageReferenceVars other ) {
public final void min ( final ImageReferenceVars other ) {
if ( other = = null ) return ;
if ( other = = null ) return ;
int v ;
int v ;
@ -317,7 +339,7 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
if ( this . wordsintitle > ( v = other . wordsintitle ) ) this . wordsintitle = v ;
if ( this . wordsintitle > ( v = other . wordsintitle ) ) this . wordsintitle = v ;
if ( this . termFrequency > ( d = other . termFrequency ) ) this . termFrequency = d ;
if ( this . termFrequency > ( d = other . termFrequency ) ) this . termFrequency = d ;
}
}
public final void max ( final ImageReferenceVars other ) {
public final void max ( final ImageReferenceVars other ) {
if ( other = = null ) return ;
if ( other = = null ) return ;
int v ;
int v ;
@ -340,11 +362,12 @@ 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
// combine the distance
// combine the distance
ImageReference oe = ( ImageReference ) r ;
ImageReference oe = ( ImageReference ) r ;
for ( Integer i : r . positions ( ) ) this . positions . add ( i ) ;
for ( Integer i : r . positions ( ) ) this . positions . add ( i ) ;
this . posinphrase = ( this . posofphrase = = oe . posofphrase ( ) ) ? Math . min ( this . posinphrase , oe . posinphrase ( ) ) : 0 ;
this . posinphrase = ( this . posofphrase = = oe . posofphrase ( ) ) ? Math . min ( this . posinphrase , oe . posinphrase ( ) ) : 0 ;
this . posofphrase = Math . min ( this . posofphrase , oe . posofphrase ( ) ) ;
this . posofphrase = Math . min ( this . posofphrase , oe . posofphrase ( ) ) ;
@ -362,5 +385,5 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
public void addPosition ( int position ) {
public void addPosition ( int position ) {
this . positions . add ( position ) ;
this . positions . add ( position ) ;
}
}
}
}