Util

object Util

Static helper methods.

Types

Link copied to clipboard
class FSTPath<T>

Represents a path in TopNSearcher.

Link copied to clipboard
class Result<T>(val input: IntsRef, val output: T)

Holds a single input (IntsRef) + output, returned by .shortestPaths.

Link copied to clipboard
open class TopNSearcher<T>(fst: FST<T>, topN: Int, maxQueueDepth: Int, comparator: Comparator<T>, pathComparator: Comparator<Util.FSTPath<T>>)

Utility class to find top N shortest paths from start point(s).

Link copied to clipboard

Holds the results for a top N search using TopNSearcher

Functions

Link copied to clipboard
fun <T> binarySearch(fst: FST<T>, arc: FST.Arc<T>, targetLabel: Int): Int

Perform a binary search of Arcs encoded as a packed array

Link copied to clipboard
fun <T> get(fst: FST<T>, input: BytesRef): T?

Looks up the output for this input, or null if the input is not accepted

fun <T> get(fst: FST<T>, input: IntsRef): T?

Looks up the output for this input, or null if the input is not accepted.

Link copied to clipboard
fun <T> readCeilArc(label: Int, fst: FST<T>, follow: FST.Arc<T>, arc: FST.Arc<T>, in: FST.BytesReader): FST.Arc<T>?

Reads the first arc greater or equal than the given label into the provided arc in place and returns it iff found, otherwise return null.

Link copied to clipboard
fun <T> shortestPaths(fst: FST<T>, fromNode: FST.Arc<T>, startOutput: T, comparator: Comparator<T>, topN: Int, allowEmptyString: Boolean): Util.TopResults<T>

Starting from node, find the top N min cost completions to a final node.

Link copied to clipboard

Just converts IntsRef to BytesRef; you must ensure the int values fit into a byte.

Link copied to clipboard
fun <T> toDot(fst: FST<T>, out: Writer, sameRank: Boolean, labelStates: Boolean)

Dumps an FST to a GraphViz's dot language description for visualization. Example of use:

Link copied to clipboard
fun toIntsRef(input: BytesRef, scratch: IntsRefBuilder): IntsRef

Just takes unsigned byte values from the BytesRef and converts into an IntsRef.

Link copied to clipboard

Just maps each UTF16 unit (char) to the ints in an IntsRef.

Link copied to clipboard

Decodes the Unicode codepoints from the provided CharSequence and places them in the provided scratch IntsRef, which must not be null, returning it.

fun toUTF32(s: CharArray, offset: Int, length: Int, scratch: IntsRefBuilder): IntsRef

Decodes the Unicode codepoints from the provided char[] and places them in the provided scratch IntsRef, which must not be null, returning it.