|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iglu.ir.RAMSearchEngine
An implementation of the SearchEngine interface that keeps all intermediate information in memory. This class is best used for building search-engine-like structures that will hold a small number of documents (under 1000). The data stored by this search engine is not inherently persistent. To keep the information between program runs, you must serialize this object.
Field Summary | |
private java.lang.String |
description
|
private java.util.HashMap |
idDataMap
|
private java.util.HashMap |
idVectorMap
|
private java.lang.String |
metricName
|
private java.lang.String |
name
|
Constructor Summary | |
RAMSearchEngine()
|
Method Summary | |
void |
addDocument(java.io.Serializable docId,
java.io.Serializable docData,
TermVector docVector)
Add a vector to the collection. |
boolean |
docExists(java.io.Serializable docId)
Returns true if a document with that ID is already in the database. |
boolean |
equals(java.lang.Object o)
Indicates whether an object is equal to this SearchEngine |
java.lang.String |
getDescription()
Returns a textual description of this information source. |
java.io.Serializable |
getDocData(java.io.Serializable docId)
Returns the document data associated with docId. |
java.lang.String |
getMetricName()
Returns the name of the similarity metric used by this class. |
java.lang.String |
getName()
Returns the name of this particular source. |
double |
getSimilarityScore(TermVector vector1,
TermVector vector2)
Returns the similarity of the two vectors based on the metric indicated by getMetricName() . |
TermVector |
getVector(java.io.Serializable docId)
Get the vector for the given document. |
int |
hashCode()
Provides a hash code for this SearchEngine. |
java.util.Iterator |
iterator()
Returns an iterator over the document identifiers. |
static void |
main(java.lang.String[] args)
Runs some tests on this class. |
ValueSortedMap |
retrieveDocuments(TermVector vector,
int numSimilar)
Return a list of document identifiers with documents similar to the given vector, sorted by similarity. |
void |
setDescription(java.lang.String description)
Sets the description of this particular search engine |
void |
setDocData(java.io.Serializable docId,
java.io.Serializable docData)
Sets the document's data. |
void |
setName(java.lang.String name)
Sets the name of this particular source. |
void |
setVector(java.io.Serializable docId,
TermVector docVector)
Change the vector for docId to the given vector. |
int |
size()
Returns the number of documents in this engine. |
static void |
test()
Runs some tests on this class. |
java.lang.String |
toString()
Returns a string indicating the type and size of this engine. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
private java.lang.String description
private java.lang.String name
private java.lang.String metricName
private java.util.HashMap idDataMap
private java.util.HashMap idVectorMap
Constructor Detail |
public RAMSearchEngine()
Method Detail |
public java.lang.String getDescription()
getDescription
in interface SearchEngine
public void setDescription(java.lang.String description)
setDescription
in interface SearchEngine
public java.lang.String getName()
getName
in interface SearchEngine
public void setName(java.lang.String name)
setName
in interface SearchEngine
public java.lang.String getMetricName()
getMetricName
in interface SearchEngine
public double getSimilarityScore(TermVector vector1, TermVector vector2)
getMetricName()
. For best efficiency,
vector1 should be the shorter of the two vectors.
getSimilarityScore
in interface SearchEngine
public boolean equals(java.lang.Object o)
equals
in interface SearchEngine
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int size()
public java.lang.String toString()
toString
in class java.lang.Object
public void addDocument(java.io.Serializable docId, java.io.Serializable docData, TermVector docVector) throws SearchEngineException
addDocument
in interface SearchEngine
SearchEngineException
public void setVector(java.io.Serializable docId, TermVector docVector)
setVector
in interface SearchEngine
public TermVector getVector(java.io.Serializable docId)
getVector
in interface SearchEngine
public java.io.Serializable getDocData(java.io.Serializable docId)
getDocData
in interface SearchEngine
docId
- an identifier of the document.public void setDocData(java.io.Serializable docId, java.io.Serializable docData)
setDocData
in interface SearchEngine
public ValueSortedMap retrieveDocuments(TermVector vector, int numSimilar)
retrieveDocuments
in interface SearchEngine
numSimilar
- The maximum number of documents to return. If
0, return all documents.
public boolean docExists(java.io.Serializable docId)
docExists
in interface SearchEngine
public java.util.Iterator iterator()
iterator
in interface SearchEngine
public static void test()
public static void main(java.lang.String[] args)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |