Package org.terrier.querying
Class QueryExpansion
- java.lang.Object
-
- org.terrier.querying.QueryExpansion
-
- All Implemented Interfaces:
MQTRewritingProcess
,Process
public class QueryExpansion extends java.lang.Object implements MQTRewritingProcess
Implements automatic query expansion as PostProcess that is applied to the result set after 1st-time matching. Controls- qemodel : The query expansion model used for Query Expansion. Defaults to Bo1.
- qe_fb_terms : The maximum number of most weighted terms in the pseudo relevance set to be added to the original query. The system performs a conservative query expansion if this property is set to 0. A conservative query expansion only re-weighs the original query terms without adding new terms to the query. Default set by property expansion.terms.
- qe_fb_docs : The number of top documents from the 1st pass retrieval to use for QE. The query is expanded from this set of documents, also known as the pseudo relevance set. Default set by property expansion.docs.
- qe.feedback.selector : The class to be used for selecting feedback documents.
- qe.expansion.terms.class : The class to be used for selecting expansion terms from feedback documents.
- Author:
- Gianni Amatti, Ben He, Vassilis Plachouras, Craig Macdonald
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
QueryExpansion.QueryExpansionConfig
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,QueryExpansionModel>
Cache_QueryExpansionModel
Caching the query expansion models that have been created so far.protected CollectionStatistics
collStats
The statistics of the indexprotected PostingIndex<?>
directIndex
The direct index used for retrieval.protected DocumentIndex
documentIndex
The document index used for retrieval.protected java.lang.String[]
expanderNames
protected PostingIndex<?>
invertedIndex
The inverted index used for retrieval.java.lang.String
lastExpandedQuery
protected Index
lastIndex
protected Lexicon<java.lang.String>
lexicon
An instance of Lexicon class.protected static org.slf4j.Logger
logger
protected MetaIndex
metaIndex
static java.lang.String
NAMESPACE_QEMODEL
The default namespace of query expansion model classes.protected QueryExpansionModel
QEModel
The query expansion model used.protected FeedbackSelector
selector
The process by which to select feedback documentsprotected boolean
warnQeModel
Set to true if this instancae has warned about the control "qemodel" not being set
-
Constructor Summary
Constructors Constructor Description QueryExpansion()
The default constructor of QueryExpansion.QueryExpansion(java.lang.String[] expansionTerms)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static QueryExpansion.QueryExpansionConfig
configFromRequest(Request r)
Get the standard configuration for QueryExpansion, namely number of terms and docs, from the Request, using two controls.void
configureIndex(Index index)
boolean
expandQuery(MatchingQueryTerms query, Request rq)
This method implements the functionality of expanding a query.protected ExpansionTerms
getExpansionTerms()
load the expansion terms, as per the property qe.expansion.terms.class.protected FeedbackSelector
getFeedbackSelector(Request rq)
load the feedback selector, based on the property qe.feedback.selectorprotected Index
getIndex(Manager m)
For easier sub-classing of which index the query expansion comes fromjava.lang.String
getInfo()
Returns the name of the used query expansion model.QueryExpansionModel
getQueryExpansionModel(java.lang.String Name)
Obtain the query expansion model for QE to use.void
process(Manager manager, Request q)
Runs the actual query expansionvoid
setQueryExpansionModel(QueryExpansionModel _QEModel)
Set the used query expansion model.
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
NAMESPACE_QEMODEL
public static final java.lang.String NAMESPACE_QEMODEL
The default namespace of query expansion model classes. The query expansion model names are prefixed with this namespace, if they are not fully qualified.- See Also:
- Constant Field Values
-
Cache_QueryExpansionModel
protected java.util.Map<java.lang.String,QueryExpansionModel> Cache_QueryExpansionModel
Caching the query expansion models that have been created so far.
-
documentIndex
protected DocumentIndex documentIndex
The document index used for retrieval.
-
metaIndex
protected MetaIndex metaIndex
-
invertedIndex
protected PostingIndex<?> invertedIndex
The inverted index used for retrieval.
-
lexicon
protected Lexicon<java.lang.String> lexicon
An instance of Lexicon class.
-
directIndex
protected PostingIndex<?> directIndex
The direct index used for retrieval.
-
warnQeModel
protected boolean warnQeModel
Set to true if this instancae has warned about the control "qemodel" not being set
-
expanderNames
protected java.lang.String[] expanderNames
-
collStats
protected CollectionStatistics collStats
The statistics of the index
-
QEModel
protected QueryExpansionModel QEModel
The query expansion model used.
-
selector
protected FeedbackSelector selector
The process by which to select feedback documents
-
lastIndex
protected Index lastIndex
-
lastExpandedQuery
public java.lang.String lastExpandedQuery
-
-
Method Detail
-
configFromRequest
public static QueryExpansion.QueryExpansionConfig configFromRequest(Request r)
Get the standard configuration for QueryExpansion, namely number of terms and docs, from the Request, using two controls.
-
setQueryExpansionModel
public void setQueryExpansionModel(QueryExpansionModel _QEModel)
Set the used query expansion model.- Parameters:
_QEModel
- QueryExpansionModel The query expansion model to be used.
-
expandQuery
public boolean expandQuery(MatchingQueryTerms query, Request rq) throws java.io.IOException
This method implements the functionality of expanding a query.- Specified by:
expandQuery
in interfaceMQTRewritingProcess
- Parameters:
query
- MatchingQueryTerms the query terms of the original query.rq
- the Request thus far, giving access to the query and the result set- Throws:
java.io.IOException
-
getIndex
protected Index getIndex(Manager m)
For easier sub-classing of which index the query expansion comes from
-
getExpansionTerms
protected ExpansionTerms getExpansionTerms()
load the expansion terms, as per the property qe.expansion.terms.class. Defaults to DFRBagExpansionTerms.- Returns:
- an ExpansionTerms instance, which may or may not wrap other ExpansionTerms instances
-
getFeedbackSelector
protected FeedbackSelector getFeedbackSelector(Request rq)
load the feedback selector, based on the property qe.feedback.selector
-
process
public void process(Manager manager, Request q)
Runs the actual query expansion- Specified by:
process
in interfaceProcess
- See Also:
Process.process(org.terrier.querying.Manager,org.terrier.querying.SearchRequest)
-
configureIndex
public void configureIndex(Index index)
- Specified by:
configureIndex
in interfaceMQTRewritingProcess
-
getQueryExpansionModel
public QueryExpansionModel getQueryExpansionModel(java.lang.String Name)
Obtain the query expansion model for QE to use. This will be cached in a hashtable for the lifetime of the application. If Name does not contain ".", then NAMESPACE_QEMODEL will be prefixed to it before loading.- Parameters:
Name
- the name of the query expansion model to load.
-
-