StringSetTokenRecognizer

class StringSetTokenRecognizer(stringsToRecognize: List<String>) : TokenRecognizer

A StringSetTokenRecognizer is a TokenRecognizer specifically built to be able to recognize whether a substring of the input matches at a relatively high speed. The speed improvements are mostly noticeable when the input consists of strings of characters of the same length.

Internally, this recognizer uses a map from integers (length of strings to detect) to a set of strings (the strings of said length). This allows for a fairly efficient recognizer.

These recognizers should be created using the anyOf DSL function.

Constructors

Link copied to clipboard
constructor(stringsToRecognize: List<String>)

Functions

Link copied to clipboard
open override fun recognize(s: String, startAt: Int): Pair<String, Int>?

Check whether the string s starting from index startAt matches the pattern this recognizer uses.