Package com.yahoo.search.query.rewrite
Class RewriterUtils
java.lang.Object
com.yahoo.search.query.rewrite.RewriterUtils
Contains common utilities used by rewriters
- Author:
- Karen Sze Wing Lee
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Print error messagestatic void
Print error messagestatic String
getNormalizedOriginalQuery
(Query query) Retrieve normalized original query from query objectstatic String
getQPConfig
(Query query, String rewriterName, String paramName) Get config parameter value set in query profilestatic String
Retrieve rewrite from FSA given the original querygetRewriteMeta
(Query query) Retrieve metadata passed by previous rewriter from query properties Initialize values if this is the first rewriterstatic String
getRewriterChain
(Query query) Get rewriter chain valuestatic String
getSpellCorrected
(Query query, boolean qss_rw, boolean qss_sugg) Retrieve spell corrected query with highest score from QLASstatic String
getUserParam
(Query query, String paramName) Get user param valuestatic com.yahoo.fsa.FSA
Load FSA from filestatic com.yahoo.fsa.FSA
Load FSA from filestatic void
Log messagestatic void
Log messagestatic void
setRewriteMeta
(Query query, HashMap<String, Object> metadata) Pass metadata to the next rewriter through query properties
-
Constructor Details
-
RewriterUtils
public RewriterUtils()
-
-
Method Details
-
loadFSA
Load FSA from file- Parameters:
file
- FSA dictionary file objectquery
- Query object from the searcher, could be null if not available- Returns:
- FSA The FSA object for the input file path
- Throws:
IOException
-
loadFSA
Load FSA from file- Parameters:
filename
- FSA dictionary file pathquery
- Query object from the searcher, could be null if not available- Returns:
- FSA The FSA object for the input file path
- Throws:
IOException
-
getRewriteFromFSA
public static String getRewriteFromFSA(Query query, HashMap<String, Object> rewriterDicts, String dictName, String key) throws RuntimeExceptionRetrieve rewrite from FSA given the original query- Parameters:
query
- Query object from searcherdictName
- FSA dictionary namerewriterDicts
- list of rewriter dictionaries It has the following format: HashMap<dictionary name, FSA>key
- The original query used to retrieve rewrite from the dictionary- Returns:
- String The retrieved rewrites, null if query doesn't exist
- Throws:
RuntimeException
-
getQPConfig
Get config parameter value set in query profile- Parameters:
query
- Query object from the searcherrewriterName
- Name of the rewriterparamName
- parameter to be retrieved- Returns:
- parameter value or null if not found
-
getRewriterChain
Get rewriter chain value- Parameters:
query
- Query object from the searcher- Returns:
- parameter value or null if not found
-
getUserParam
Get user param value- Parameters:
query
- Query object from the searcherparamName
- parameter to be retrieved- Returns:
- parameter value or null if not found
-
getRewriteMeta
Retrieve metadata passed by previous rewriter from query properties Initialize values if this is the first rewriter- Parameters:
query
- Query object from the searcher- Returns:
- hashmap containing the metadata
-
setRewriteMeta
Pass metadata to the next rewriter through query properties- Parameters:
query
- Query object from the searchermetadata
- HashMap containing the metadata
-
getSpellCorrected
public static String getSpellCorrected(Query query, boolean qss_rw, boolean qss_sugg) throws RuntimeException Retrieve spell corrected query with highest score from QLAS- Parameters:
query
- Query object from the searcherqss_rw
- Whether to consider qss_rw modificationqss_sugg
- Whether ot consider qss_sugg modification- Returns:
- Spell corrected query or null if not found
- Throws:
RuntimeException
-
getNormalizedOriginalQuery
Retrieve normalized original query from query object- Parameters:
query
- Query object from searcher- Returns:
- normalized query
-
log
Log message- Parameters:
logger
- Logger used for this msgmsg
- Log message
-
log
Log message- Parameters:
logger
- Logger used for this msgquery
- Query object from searchermsg
- Log message
-
error
Print error message- Parameters:
logger
- Logger used for this msgmsg
- Error message
-
error
Print error message- Parameters:
logger
- Logger used for this msgquery
- Query object from searchermsg
- Error message
-