public class RewriterUtils extends Object
Constructor and Description |
---|
RewriterUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
error(Logger logger,
Query query,
String msg)
Print error message
|
static void |
error(Logger logger,
String msg)
Print error message
|
static String |
getNormalizedOriginalQuery(Query query)
Retrieve normalized original query from query object
|
static String |
getQPConfig(Query query,
String rewriterName,
String paramName)
Get config parameter value set in query profile
|
static String |
getRewriteFromFSA(Query query,
HashMap<String,Object> rewriterDicts,
String dictName,
String key)
Retrieve rewrite from FSA given the original query
|
static HashMap<String,Object> |
getRewriteMeta(Query query)
Retrieve metadata passed by previous rewriter
from query properties
Initialize values if this is the first rewriter
|
static String |
getRewriterChain(Query query)
Get rewriter chain value
|
static String |
getSpellCorrected(Query query,
boolean qss_rw,
boolean qss_sugg)
Retrieve spell corrected query with highest score from QLAS
|
static String |
getUserParam(Query query,
String paramName)
Get user param value
|
static com.yahoo.fsa.FSA |
loadFSA(File file,
Query query)
Load FSA from file
|
static com.yahoo.fsa.FSA |
loadFSA(String filename,
Query query)
Load FSA from file
|
static void |
log(Logger logger,
Query query,
String msg)
Log message
|
static void |
log(Logger logger,
String msg)
Log message
|
static void |
setRewriteMeta(Query query,
HashMap<String,Object> metadata)
Pass metadata to the next rewriter through query properties
|
public static com.yahoo.fsa.FSA loadFSA(File file, Query query) throws IOException
file
- FSA dictionary file objectquery
- Query object from the searcher, could be null if not availableIOException
public static com.yahoo.fsa.FSA loadFSA(String filename, Query query) throws IOException
filename
- FSA dictionary file pathquery
- Query object from the searcher, could be null if not availableIOException
public static String getRewriteFromFSA(Query query, HashMap<String,Object> rewriterDicts, String dictName, String key) throws RuntimeException
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 dictionaryRuntimeException
public static String getQPConfig(Query query, String rewriterName, String paramName)
query
- Query object from the searcherrewriterName
- Name of the rewriterparamName
- parameter to be retrievedpublic static String getRewriterChain(Query query)
query
- Query object from the searcherpublic static String getUserParam(Query query, String paramName)
query
- Query object from the searcherparamName
- parameter to be retrievedpublic static HashMap<String,Object> getRewriteMeta(Query query)
query
- Query object from the searcherpublic static void setRewriteMeta(Query query, HashMap<String,Object> metadata)
query
- Query object from the searchermetadata
- HashMap containing the metadatapublic static String getSpellCorrected(Query query, boolean qss_rw, boolean qss_sugg) throws RuntimeException
query
- Query object from the searcherqss_rw
- Whether to consider qss_rw modificationqss_sugg
- Whether ot consider qss_sugg modificationRuntimeException
public static String getNormalizedOriginalQuery(Query query)
query
- Query object from searcherpublic static void log(Logger logger, String msg)
logger
- Logger used for this msgmsg
- Log messagepublic static void log(Logger logger, Query query, String msg)
logger
- Logger used for this msgquery
- Query object from searchermsg
- Log messagepublic static void error(Logger logger, String msg)
logger
- Logger used for this msgmsg
- Error messageCopyright © 2018. All rights reserved.