infomat.algorithms.search
Class Searcher

java.lang.Object
  extended by infomat.algorithms.search.Searcher
All Implemented Interfaces:
NeedsISimilarity, HasProperties

public class Searcher
extends java.lang.Object
implements HasProperties, NeedsISimilarity

A search tool.


Field Summary
private  Properties properties
           
private  ISimilarity similarity
           
 
Constructor Summary
Searcher()
           
Searcher(Properties properties)
           
 
Method Summary
private  IVector<IObject> basicSearch(IVector<IObject> queryVec, IMatrix matrix, IObjectGroup rowGroup, IObjectGroup columnGroup, boolean row, int number)
          Returns a ranked IVector of the objects in "rowGroup" that match the terms in "queryVec".
 Properties getDefaultProperties()
           
 Properties getProperties()
           
 java.lang.Object getPropertyValue(java.lang.String name)
           
 ISimilarity getSimilarity()
           
private  IVector<IObject> multiSearch(java.util.Vector<IVector<IObject>> queryVecs, IMatrix matrix, IObjectGroup rowGroup, IObjectGroup columnGroup, boolean row, int number)
          As basicSearch() but several different queries are considered.
 IVector<IObject> parseText(java.lang.String queryString, IMatrix matrix, IObjectGroup rowGroup, IObjectGroup columnGroup, boolean row)
          Constructs a term vector with column objects when row is true.
private  IVector<IObject> rank(IVector<IObject> queryVec, java.util.Vector<IObject> resVec)
          Ranks the objects in "resVec" according to similarity to the terms in "queryVec".
private  java.util.Vector<IObject> removeObjectsWithFewTerms(java.util.Vector<IObject> resVec, java.util.HashMap<IObject,java.util.HashSet<IObject>> termsForObjectMap, int number)
          Removes objects that has fewer terms than "number".
 IVector<IObject> search(IVector<IObject> queryVec, IMatrix matrix, IObjectGroup rowGroup, IObjectGroup columnGroup, boolean row)
           
 IVector<IObject> search(java.lang.String queryString, IMatrix matrix, IObjectGroup rowGroup, IObjectGroup columnGroup, boolean row)
           
 void setProperties(Properties properties)
           
 void setProperty(java.lang.String name, java.lang.Object value)
           
 void setSimilarity(ISimilarity similarity)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

properties

private Properties properties

similarity

private ISimilarity similarity
Constructor Detail

Searcher

public Searcher()

Searcher

public Searcher(Properties properties)
Method Detail

getDefaultProperties

public Properties getDefaultProperties()
Specified by:
getDefaultProperties in interface HasProperties

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String name)
Specified by:
getPropertyValue in interface HasProperties

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
                 throws PropertyNotFoundException
Specified by:
setProperty in interface HasProperties
Throws:
PropertyNotFoundException

getProperties

public Properties getProperties()
Specified by:
getProperties in interface HasProperties

setProperties

public void setProperties(Properties properties)
Specified by:
setProperties in interface HasProperties

setSimilarity

public void setSimilarity(ISimilarity similarity)
Specified by:
setSimilarity in interface NeedsISimilarity

getSimilarity

public ISimilarity getSimilarity()

search

public IVector<IObject> search(IVector<IObject> queryVec,
                               IMatrix matrix,
                               IObjectGroup rowGroup,
                               IObjectGroup columnGroup,
                               boolean row)

multiSearch

private IVector<IObject> multiSearch(java.util.Vector<IVector<IObject>> queryVecs,
                                     IMatrix matrix,
                                     IObjectGroup rowGroup,
                                     IObjectGroup columnGroup,
                                     boolean row,
                                     int number)
As basicSearch() but several different queries are considered. When counting number of terms they must come from different "queryVecs".


basicSearch

private IVector<IObject> basicSearch(IVector<IObject> queryVec,
                                     IMatrix matrix,
                                     IObjectGroup rowGroup,
                                     IObjectGroup columnGroup,
                                     boolean row,
                                     int number)
Returns a ranked IVector of the objects in "rowGroup" that match the terms in "queryVec". "queryVec" is restricted by "columnGroup". Each object has to have "number" terms from "queryVec". If "row" is false objects are taken from "columnGroup" and terms from "rowGroup".


removeObjectsWithFewTerms

private java.util.Vector<IObject> removeObjectsWithFewTerms(java.util.Vector<IObject> resVec,
                                                            java.util.HashMap<IObject,java.util.HashSet<IObject>> termsForObjectMap,
                                                            int number)
Removes objects that has fewer terms than "number".


rank

private IVector<IObject> rank(IVector<IObject> queryVec,
                              java.util.Vector<IObject> resVec)
Ranks the objects in "resVec" according to similarity to the terms in "queryVec".


search

public IVector<IObject> search(java.lang.String queryString,
                               IMatrix matrix,
                               IObjectGroup rowGroup,
                               IObjectGroup columnGroup,
                               boolean row)

parseText

public IVector<IObject> parseText(java.lang.String queryString,
                                  IMatrix matrix,
                                  IObjectGroup rowGroup,
                                  IObjectGroup columnGroup,
                                  boolean row)
Constructs a term vector with column objects when row is true.