Package com.viglet.turing.sn.ac
Class TurSNSuggestionFilter
Object
TurSNSuggestionFilter
The
SuggestionFilter
class is responsible for filtering a list of
suggestions
based on a specified strategy and a list of stop words. It currently supports
two
strategies: DEFAULT
and AUTOMATON
.
- The
DEFAULT
strategy follows the original filter implemented in "TurSNAutoComplete". - The
AUTOMATON
strategy uses a finite state machine to filter suggestions. The behaviour of this strategy filters suggestion for a single word, if the query has an space at the end, it will consider the query as a two-word query and will suggests a next word for the query. It will consider a stop word followed by a non-stop as a valid suggestion.
- Since:
- 0.3.9
- Author:
- Gabriel F. Gomazako
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
automatonStrategyConfig
(int numberOfWordsFromQuery) Configures the suggestion filter to use the automaton strategy - New strategy.void
defaultStrategyConfig
(int numberOfWordsFromQuery) Configures the suggestion filter to use the default strategy - Legacy strategy.void
defaultStrategyConfig
(int numberOfWordsFromQuery, boolean useTermsQueryEqualsAutoComplete) Configures the default strategy for suggestions - Legacy strategy.Filters a list of suggestions based on the defined strategy.
-
Constructor Details
-
TurSNSuggestionFilter
-
-
Method Details
-
defaultStrategyConfig
public void defaultStrategyConfig(int numberOfWordsFromQuery) Configures the suggestion filter to use the default strategy - Legacy strategy.- Parameters:
numberOfWordsFromQuery
- the number of words from the query to be considered in the suggestion filter.
-
defaultStrategyConfig
public void defaultStrategyConfig(int numberOfWordsFromQuery, boolean useTermsQueryEqualsAutoComplete) Configures the default strategy for suggestions - Legacy strategy.- Parameters:
numberOfWordsFromQuery
- the number of words to consider from the query.useTermsQueryEqualsAutoComplete
- flag indicating whether to use terms query equals auto-complete.
-
automatonStrategyConfig
public void automatonStrategyConfig(int numberOfWordsFromQuery) Configures the suggestion filter to use the automaton strategy - New strategy.- Parameters:
numberOfWordsFromQuery
- the number of words from the query to be used in the automaton strategy
-
filter
Filters a list of suggestions based on the defined strategy.- Parameters:
suggestions
- the list of suggestions to be filtered- Returns:
- a list of filtered suggestions based on the strategy
- Throws:
IllegalArgumentException
- if the suggestion list is null
-