@Override public void setUp() throws Exception { super.setUp(); // build an automaton matching this jvm's letter definition State initial = new State(); State accept = new State(); accept.setAccept(true); for (int i = 0; i <= 0x10FFFF; i++) { if (Character.isLetter(i)) { initial.addTransition(new Transition(i, i, accept)); } } Automaton single = new Automaton(initial); single.reduce(); Automaton repeat = BasicOperations.repeat(single); jvmLetter = new CharacterRunAutomaton(repeat); }
/** Sole constructor. */ public Path(State state, FST.Arc<T> fstNode, T output, IntsRef input) { this.state = state; this.fstNode = fstNode; this.output = output; this.input = input; }
private void copyDestTransitions(State from, State to, List<Transition> transitions) { if (to.isAccept()) { from.setAccept(true); } for(Transition t : to.getTransitions()) { transitions.add(t); } }
private static void addHoles(State startState, RollingBuffer<Position> positions, int pos) { Position posData = positions.get(pos); Position prevPosData = positions.get(pos-1); while(posData.arriving == null || prevPosData.leaving == null) { if (posData.arriving == null) { posData.arriving = new State(); posData.arriving.addTransition(new Transition(POS_SEP, posData.leaving)); } if (prevPosData.leaving == null) { if (pos == 1) { prevPosData.leaving = startState; } else { prevPosData.leaving = new State(); } if (prevPosData.arriving != null) { prevPosData.arriving.addTransition(new Transition(POS_SEP, prevPosData.leaving)); } } prevPosData.leaving.addTransition(new Transition(HOLE, posData.arriving)); pos--; if (pos <= 0) { break; } posData = prevPosData; prevPosData = positions.get(pos-1); } }