org.jbox.searcher.simpleSearcher
Class SimpleSearcher

java.lang.Object
  extended by org.jbox.searcher.AbstractSearcher
      extended by org.jbox.searcher.simpleSearcher.SimpleSearcher
All Implemented Interfaces:
Searcher

public class SimpleSearcher
extends AbstractSearcher

A concrete Searcher.

Version:
1.0
Author:
YiBin.H
See Also:
Page, PageProxy

Field Summary
 
Fields inherited from class org.jbox.searcher.AbstractSearcher
ALLPAGENUM, cutterBox, pageHome, wordHome
 
Constructor Summary
SimpleSearcher()
           
 
Method Summary
protected  java.util.HashMap<java.lang.Long,PageProxy> query(java.lang.String word)
          Query the index with a specified word string.
 java.util.Collection<PageProxy> query(java.lang.String[] words)
          Query index by a string array.
 Page[] search(java.lang.String query)
          Search index by a query string, return a Page array related to the query string.
 
Methods inherited from class org.jbox.searcher.AbstractSearcher
calculateTFIDF, getAllPageNum, pageRank, setCutterBox, setPageHome, setWordHome
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSearcher

public SimpleSearcher()
Method Detail

query

protected java.util.HashMap<java.lang.Long,PageProxy> query(java.lang.String word)
Query the index with a specified word string.

Parameters:
word - a string to queried.
Returns:
HashMap mapping page id to PageProxy.

query

public java.util.Collection<PageProxy> query(java.lang.String[] words)
Query index by a string array.

Parameters:
words - String array to be queried.
Returns:
Collection containing PageProxy objects which relate to the query words.

search

public Page[] search(java.lang.String query)
Search index by a query string, return a Page array related to the query string.

It should be noticed that the type of result of this method is not real Page,but PageProxy, a proxy of Page. It change the behavior of Page.getText(), returning a introduction instead of returning the whole text.
If need to get the the prototype of Page, cast the result type to PageProxy, and then calling PageProxy.getPage() to get the Page object.

Note: results of the method are sorted by TFIDF.

Parameters:
query - string to be queried.
Returns:
Page array related to the query string.