public abstract class NfaState extends Object
Constructor and Description |
---|
NfaState() |
Modifier and Type | Method and Description |
---|---|
static NfaState |
and(boolean clausesMayLoopBack,
List<NfaState> nextStates)
Build an AND state.
|
static NfaState |
anyToken(String luceneField,
NfaState nextState) |
String |
dump(Map<NfaState,Integer> stateNrs) |
static String |
dump(NfaState state,
Map<NfaState,Integer> stateNrs) |
protected abstract String |
dumpInternal(Map<NfaState,Integer> stateNrs) |
static Set<NfaState> |
emptySet() |
NavigableSet<Integer> |
findMatches(ForwardIndexDocument fiDoc,
int pos,
int direction)
Find all matches for this NFA in the token source.
|
void |
finish(Set<NfaState> visited)
Visit each node and replace dangling arrows (nulls) with the match state.
|
protected abstract void |
finishInternal(Set<NfaState> visited)
Visit each node and replace dangling arrows (nulls) with the match state.
|
abstract boolean |
hitsAllSameLength(Set<NfaState> statesVisited)
Are all hits from this NFA the same length?
|
abstract int |
hitsLengthMax(Set<NfaState> statesVisited)
What's the maximum hit length?
|
abstract int |
hitsLengthMin(Set<NfaState> statesVisited)
What's the minimum hit length?
|
void |
lookupPropertyNumbers(ForwardIndexAccessor fiAccessor,
Map<NfaState,Boolean> statesVisited) |
static NfaState |
match() |
boolean |
matches(ForwardIndexDocument fiDoc,
int pos,
int direction)
Does the token source match this NFA?
|
abstract boolean |
matchesEmptySequence(Set<NfaState> statesVisited)
Does this NFA match the empty sequence?
|
static NfaState |
or(boolean clausesMayLoopBack,
List<NfaState> nextStates,
boolean clausesAllSameLength)
Build am OR state.
|
static NfaState |
regex(String luceneField,
String pattern,
NfaState nextState) |
abstract void |
setNextState(int input,
NfaState state)
Set the next state for a given input.
|
static NfaState |
token(String luceneField,
Set<String> inputTokens,
NfaState nextState)
Build a token state.
|
static NfaState |
token(String luceneField,
String inputToken,
NfaState nextState)
Build a token state.
|
String |
toString() |
public static NfaState token(String luceneField, String inputToken, NfaState nextState)
luceneField
- what annotation to matchinputToken
- what token to matchnextState
- what state to go to after a succesful matchpublic static NfaState token(String luceneField, Set<String> inputTokens, NfaState nextState)
luceneField
- what annotation to matchinputTokens
- what tokens to matchnextState
- what state to go to after a succesful matchpublic static NfaState or(boolean clausesMayLoopBack, List<NfaState> nextStates, boolean clausesAllSameLength)
clausesMayLoopBack
- if false, no clauses loop back to earlier states,
(a more efficient way of matching can be used in this case)nextStates
- states to tryclausesAllSameLength
- are all hits for all clauses the same length?
(used to optimize matching)public static NfaState and(boolean clausesMayLoopBack, List<NfaState> nextStates)
clausesMayLoopBack
- if false, no clauses loop back to earlier states,
(a more efficient way of matching can be used in this case)nextStates
- NFAs that must matchpublic static NfaState match()
public NavigableSet<Integer> findMatches(ForwardIndexDocument fiDoc, int pos, int direction)
fiDoc
- where to read tokens frompos
- current matching positiondirection
- matching directionpublic boolean matches(ForwardIndexDocument fiDoc, int pos, int direction)
fiDoc
- where to read tokens frompos
- current matching positiondirection
- matching directionpublic abstract void setNextState(int input, NfaState state)
input
- inputstate
- next statepublic void finish(Set<NfaState> visited)
visited
- nodes visited so far, so we don't visit nodes multiple timesprotected abstract void finishInternal(Set<NfaState> visited)
visited
- nodes visited so far, this one included. finish() uses this to
make sure we don't visit the same node twice, so always call
finish() in your implementations, not finishInternal().public abstract boolean matchesEmptySequence(Set<NfaState> statesVisited)
statesVisited
- states we've already visited, so we can deal with cyclespublic abstract boolean hitsAllSameLength(Set<NfaState> statesVisited)
statesVisited
- states we've already visited, so we can deal with cyclespublic abstract int hitsLengthMin(Set<NfaState> statesVisited)
statesVisited
- states we've already visited, so we can deal with cyclespublic abstract int hitsLengthMax(Set<NfaState> statesVisited)
statesVisited
- states we've already visited, so we can deal with cyclespublic final void lookupPropertyNumbers(ForwardIndexAccessor fiAccessor, Map<NfaState,Boolean> statesVisited)
Copyright © 2020 Instituut voor Nederlandse Taal (INT). All rights reserved.