public static class Util.TopNSearcher<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private FST.BytesReader |
bytesReader |
private java.util.Comparator<T> |
comparator |
private FST<T> |
fst |
private int |
maxQueueDepth |
private java.util.Comparator<Util.FSTPath<T>> |
pathComparator |
(package private) java.util.TreeSet<Util.FSTPath<T>> |
queue |
private FST.Arc<T> |
scratchArc |
private int |
topN |
Constructor and Description |
---|
TopNSearcher(FST<T> fst,
int topN,
int maxQueueDepth,
java.util.Comparator<T> comparator)
Creates an unbounded TopNSearcher
|
TopNSearcher(FST<T> fst,
int topN,
int maxQueueDepth,
java.util.Comparator<T> comparator,
java.util.Comparator<Util.FSTPath<T>> pathComparator) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
acceptPartialPath(Util.FSTPath<T> path)
Override this to prevent considering a path before it's complete
|
protected boolean |
acceptResult(IntsRef input,
T output) |
protected boolean |
acceptResult(Util.FSTPath<T> path) |
protected void |
addIfCompetitive(Util.FSTPath<T> path) |
void |
addStartPaths(FST.Arc<T> node,
T startOutput,
boolean allowEmptyString,
IntsRefBuilder input) |
void |
addStartPaths(FST.Arc<T> node,
T startOutput,
boolean allowEmptyString,
IntsRefBuilder input,
float boost,
java.lang.CharSequence context,
int payload)
Adds all leaving arcs, including 'finished' arc, if
the node is final, from this node into the queue.
|
Util.TopResults<T> |
search() |
private final FST.BytesReader bytesReader
private final int topN
private final int maxQueueDepth
private final java.util.Comparator<T> comparator
private final java.util.Comparator<Util.FSTPath<T>> pathComparator
java.util.TreeSet<Util.FSTPath<T>> queue
public TopNSearcher(FST<T> fst, int topN, int maxQueueDepth, java.util.Comparator<T> comparator)
fst
- the FST
to search ontopN
- the number of top scoring entries to retrievemaxQueueDepth
- the maximum size of the queue of possible top entriescomparator
- the comparator to select the top Npublic TopNSearcher(FST<T> fst, int topN, int maxQueueDepth, java.util.Comparator<T> comparator, java.util.Comparator<Util.FSTPath<T>> pathComparator)
protected void addIfCompetitive(Util.FSTPath<T> path)
public void addStartPaths(FST.Arc<T> node, T startOutput, boolean allowEmptyString, IntsRefBuilder input) throws java.io.IOException
java.io.IOException
public void addStartPaths(FST.Arc<T> node, T startOutput, boolean allowEmptyString, IntsRefBuilder input, float boost, java.lang.CharSequence context, int payload) throws java.io.IOException
java.io.IOException
public Util.TopResults<T> search() throws java.io.IOException
java.io.IOException
protected boolean acceptResult(Util.FSTPath<T> path)
protected boolean acceptPartialPath(Util.FSTPath<T> path)