Package org.ahocorasick.trie
Class Trie.TrieBuilder
java.lang.Object
org.ahocorasick.trie.Trie.TrieBuilder
- Enclosing class:
- Trie
public static class Trie.TrieBuilder extends Object
-
Method Summary
Modifier and Type Method Description Trie.TrieBuilder
addKeyword(String keyword)
Adds a keyword to the Trie's list of text search keywords.Trie.TrieBuilder
addKeywords(String... keywords)
Adds a list of keywords to the Trie's list of text search keywords.Trie.TrieBuilder
addKeywords(Collection<String> keywords)
Adds a list of keywords to the Trie's list of text search keywords.Trie
build()
Configure the Trie based on the builder settings.Trie.TrieBuilder
caseInsensitive()
Deprecated.Use ignoreCase()Trie.TrieBuilder
ignoreCase()
Configure the Trie to ignore case when searching for keywords in the text.Trie.TrieBuilder
ignoreOverlaps()
Configure the Trie to ignore overlapping keywords.Trie.TrieBuilder
onlyWholeWords()
Configure the Trie to match whole keywords in the text.Trie.TrieBuilder
onlyWholeWordsWhiteSpaceSeparated()
Configure the Trie to match whole keywords that are separated by whitespace in the text.Trie.TrieBuilder
removeOverlaps()
Deprecated.Use ignoreOverlaps()Trie.TrieBuilder
stopOnHit()
Configure the Trie to stop after the first keyword is found in the text.
-
Method Details
-
ignoreCase
Configure the Trie to ignore case when searching for keywords in the text. This must be called before calling addKeyword because the algorithm converts keywords to lowercase as they are added, depending on this case sensitivity setting.- Returns:
- This builder.
-
ignoreOverlaps
Configure the Trie to ignore overlapping keywords.- Returns:
- This builder.
-
addKeyword
Adds a keyword to the Trie's list of text search keywords.- Parameters:
keyword
- The keyword to add to the list.- Returns:
- This builder.
- Throws:
NullPointerException
- if the keyword is null.
-
addKeywords
Adds a list of keywords to the Trie's list of text search keywords.- Parameters:
keywords
- The keywords to add to the list.- Returns:
- This builder.
-
addKeywords
Adds a list of keywords to the Trie's list of text search keywords.- Parameters:
keywords
- The keywords to add to the list.- Returns:
- This builder.
-
onlyWholeWords
Configure the Trie to match whole keywords in the text.- Returns:
- This builder.
-
onlyWholeWordsWhiteSpaceSeparated
Configure the Trie to match whole keywords that are separated by whitespace in the text. For example, "this keyword thatkeyword" would only match the first occurrence of "keyword".- Returns:
- This builder.
-
stopOnHit
Configure the Trie to stop after the first keyword is found in the text.- Returns:
- This builder.
-
build
Configure the Trie based on the builder settings.- Returns:
- The configured Trie.
-
caseInsensitive
Deprecated.Use ignoreCase()- Returns:
- This builder.
-
removeOverlaps
Deprecated.Use ignoreOverlaps()- Returns:
- This builder.
-