Class Trie.TrieBuilder

java.lang.Object
org.ahocorasick.trie.Trie.TrieBuilder
Enclosing class:
Trie

public static class Trie.TrieBuilder
extends Object
  • Method Details

    • ignoreCase

      public Trie.TrieBuilder 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

      public Trie.TrieBuilder ignoreOverlaps()
      Configure the Trie to ignore overlapping keywords.
      Returns:
      This builder.
    • addKeyword

      public Trie.TrieBuilder addKeyword​(String keyword)
      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

      public Trie.TrieBuilder addKeywords​(String... keywords)
      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

      public Trie.TrieBuilder addKeywords​(Collection<String> keywords)
      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

      public Trie.TrieBuilder onlyWholeWords()
      Configure the Trie to match whole keywords in the text.
      Returns:
      This builder.
    • onlyWholeWordsWhiteSpaceSeparated

      public Trie.TrieBuilder 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

      public Trie.TrieBuilder stopOnHit()
      Configure the Trie to stop after the first keyword is found in the text.
      Returns:
      This builder.
    • build

      public Trie build()
      Configure the Trie based on the builder settings.
      Returns:
      The configured Trie.
    • caseInsensitive

      public Trie.TrieBuilder caseInsensitive()
      Deprecated.
      Use ignoreCase()
      Returns:
      This builder.
    • removeOverlaps

      public Trie.TrieBuilder removeOverlaps()
      Deprecated.
      Use ignoreOverlaps()
      Returns:
      This builder.