Class GenericExpansionRewriter
java.lang.Object
com.yahoo.component.AbstractComponent
com.yahoo.component.chain.ChainedComponent
com.yahoo.processing.Processor
com.yahoo.search.Searcher
com.yahoo.search.query.rewrite.QueryRewriteSearcher
com.yahoo.search.query.rewrite.rewriters.GenericExpansionRewriter
- All Implemented Interfaces:
com.yahoo.component.Component
,com.yahoo.component.Deconstructable
,Comparable<com.yahoo.component.Component>
This rewriter would add rewrites to entities (e.g abbreviation, synonym, etc)
to boost precision - FSA dict: [normalized original query]\t[rewrite 1]\t[rewrite 2]\t[etc]
- Features:
RewritesAsUnitEquiv flag: add proximity boosted rewrites
PartialPhraseMatch flag: whether to match whole phrase or partial phrase
MaxRewrites flag: the maximum number of rewrites to be added
to boost precision - FSA dict: [normalized original query]\t[rewrite 1]\t[rewrite 2]\t[etc]
- Features:
RewritesAsUnitEquiv flag: add proximity boosted rewrites
PartialPhraseMatch flag: whether to match whole phrase or partial phrase
MaxRewrites flag: the maximum number of rewrites to be added
- Author:
- Karen Sze Wing Lee
-
Field Summary
Fields inherited from class com.yahoo.search.query.rewrite.QueryRewriteSearcher
rewriterDicts
Fields inherited from class com.yahoo.component.AbstractComponent
isDeconstructable
-
Constructor Summary
ConstructorDescriptionGenericExpansionRewriter
(com.yahoo.component.ComponentId id, com.yahoo.filedistribution.fileacquirer.FileAcquirer fileAcquirer, RewritesConfig config) Constructor for GenericExpansionRewriter.GenericExpansionRewriter
(RewritesConfig config, HashMap<String, File> fileList) Constructor for GenericExpansionRewriter unit test. -
Method Summary
Modifier and TypeMethodDescriptionboolean
configure
(com.yahoo.filedistribution.fileacquirer.FileAcquirer fileAcquirer, RewritesConfig config, HashMap<String, File> fileList) Instance creation time config loading besides FSA.Get default FSA dictionary namesGet the name of the rewriterboolean
Get the flag which specifies whether this rewriter should be skipped if the query has been rewrittenMain logic of rewriter
- Retrieve rewrites from FSA dict
- rewrite query using features that are enabled by userMethods inherited from class com.yahoo.search.query.rewrite.QueryRewriteSearcher
getQPConfig, getRewriteFromFSA, search
Methods inherited from class com.yahoo.search.Searcher
ensureFilled, fill, getLogger, process, toString
Methods inherited from class com.yahoo.component.chain.ChainedComponent
getAnnotatedDependencies, getDefaultAnnotatedDependencies, getDependencies, initDependencies
Methods inherited from class com.yahoo.component.AbstractComponent
clone, compareTo, deconstruct, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructable
-
Field Details
-
REWRITER_NAME
- See Also:
-
GENERIC_EXPAND_DICT
- See Also:
-
GENERIC_EXPAND_DICT_FILENAME
- See Also:
-
-
Constructor Details
-
GenericExpansionRewriter
@Inject public GenericExpansionRewriter(com.yahoo.component.ComponentId id, com.yahoo.filedistribution.fileacquirer.FileAcquirer fileAcquirer, RewritesConfig config) Constructor for GenericExpansionRewriter. Load configs using default format -
GenericExpansionRewriter
Constructor for GenericExpansionRewriter unit test. Load configs using default format
-
-
Method Details
-
configure
public boolean configure(com.yahoo.filedistribution.fileacquirer.FileAcquirer fileAcquirer, RewritesConfig config, HashMap<String, File> fileList) Instance creation time config loading besides FSA. Create PhraseMatcher from FSA dict- Specified by:
configure
in classQueryRewriteSearcher
- Parameters:
fileAcquirer
- Required param for retrieving file type config (see vespa's search container doc for more detail)config
- Config from vespa-services.xml (see vespa's search container doc for more detail)fileList
- pairs of file name and file handler for unit tests- Returns:
- boolean true if loaded successfully, false otherwise
-
rewrite
Main logic of rewriter
- Retrieve rewrites from FSA dict
- rewrite query using features that are enabled by user- Specified by:
rewrite
in classQueryRewriteSearcher
- Parameters:
query
- Query object from searcherdictKey
- the key passed from previous rewriter to be treated as "original query from user" For example, if previous is misspell rewriter, it would pass the corrected query as the "original query from user". For other rewriters which add variants, abbr, etc to the query, the original query should be passed as a key. This rewriter could still choose to ignore this key. This key is not the rewritten query itself. For example, if original query is (willl smith) and the rewritten query is (willl smith) OR (will smith) the key to be passed could be (will smith)- Returns:
- HashMap which contains the key value pairs:
- whether this query has been rewritten by this rewriter
key: rewritten
value: true or false
- the key to be treated as "original query from user" in next rewriter downstream, for example, misspell rewriter would pass the corrected query as the "original query from user" to the next rewriter. For other rewriters which add variants, abbr, etc to the query, the original query should be passed as a key. This key is not necessarily consumed by the next rewriter. The next rewriter can still choose to ignore this key.
key: newDictKey
value: new dict key - Throws:
RuntimeException
-
getSkipRewriterIfRewritten
public boolean getSkipRewriterIfRewritten()Get the flag which specifies whether this rewriter should be skipped if the query has been rewritten- Specified by:
getSkipRewriterIfRewritten
in classQueryRewriteSearcher
- Returns:
- true if rewriter should be skipped, false otherwise
-
getRewriterName
Get the name of the rewriter- Specified by:
getRewriterName
in classQueryRewriteSearcher
- Returns:
- Name of the rewriter
-
getDefaultFSAs
Get default FSA dictionary names- Specified by:
getDefaultFSAs
in classQueryRewriteSearcher
- Returns:
- Pair of FSA dictionary name and filename
-