public void prependOutput(T outputPrefix) { assert owner.validOutput(outputPrefix); for(int arcIdx=0;arcIdx<numArcs;arcIdx++) { arcs[arcIdx].output = owner.fst.outputs.add(outputPrefix, arcs[arcIdx].output); assert owner.validOutput(arcs[arcIdx].output); } if (isFinal) { output = owner.fst.outputs.add(outputPrefix, output); assert owner.validOutput(output); } } }
/** Looks up the output for this input, or null if the * input is not accepted */ public static<T> T get(FST<T> fst, BytesRef input) throws IOException { assert fst.inputType == FST.INPUT_TYPE.BYTE1; final BytesReader fstReader = fst.getBytesReader(); // TODO: would be nice not to alloc this on every lookup final FST.Arc<T> arc = fst.getFirstArc(new FST.Arc<T>()); // Accumulate output as we go T output = fst.outputs.getNoOutput(); for(int i=0;i<input.length;i++) { if (fst.findTargetArc(input.bytes[i+input.offset] & 0xFF, arc, arc, fstReader) == null) { return null; } output = fst.outputs.add(output, arc.output); } if (arc.isFinal()) { return fst.outputs.add(output, arc.nextFinalOutput); } else { return null; } }
/** Looks up the output for this input, or null if the * input is not accepted. */ public static<T> T get(FST<T> fst, IntsRef input) throws IOException { // TODO: would be nice not to alloc this on every lookup final FST.Arc<T> arc = fst.getFirstArc(new FST.Arc<T>()); final BytesReader fstReader = fst.getBytesReader(); // Accumulate output as we go T output = fst.outputs.getNoOutput(); for(int i=0;i<input.length;i++) { if (fst.findTargetArc(input.ints[input.offset + i], arc, arc, fstReader) == null) { return null; } output = fst.outputs.add(output, arc.output); } if (arc.isFinal()) { return fst.outputs.add(output, arc.nextFinalOutput); } else { return null; } }
private void pushLast() throws IOException { FST.Arc<T> arc = arcs[upto]; assert arc != null; while (true) { setCurrentLabel(arc.label); output[upto] = fst.outputs.add(output[upto-1], arc.output); if (arc.label == FST.END_LABEL) { // Final node break; } incr(); arc = fst.readLastTargetArc(arc, getArc(upto), fstReader); } }
private void pushFirst() throws IOException { FST.Arc<T> arc = arcs[upto]; assert arc != null; while (true) { output[upto] = fst.outputs.add(output[upto-1], arc.output); if (arc.label == FST.END_LABEL) { // Final node break; } //System.out.println(" pushFirst label=" + (char) arc.label + " upto=" + upto + " output=" + fst.outputs.outputToString(output[upto])); setCurrentLabel(arc.label); incr(); final FST.Arc<T> nextArc = getArc(upto); fst.readFirstTargetArc(arc, nextArc, fstReader); arc = nextArc; } }
T output = fst.outputs.add(path.output, path.arc.output);
output = BlockTreeTermsReader.FST_OUTPUTS.add(output, arc.output); currentFrame = pushFrame(arc, BlockTreeTermsReader.FST_OUTPUTS.add(output, arc.nextFinalOutput), 0); output = BlockTreeTermsReader.FST_OUTPUTS.add(output, arc.output); currentFrame = pushFrame(arc, BlockTreeTermsReader.FST_OUTPUTS.add(output, arc.nextFinalOutput), targetUpto);
assert arc.label == (target.bytes[target.offset + targetUpto] & 0xFF): "arc.label=" + (char) arc.label + " targetLabel=" + (char) (target.bytes[target.offset + targetUpto] & 0xFF); if (arc.output != BlockTreeTermsReader.NO_OUTPUT) { output = BlockTreeTermsReader.FST_OUTPUTS.add(output, arc.output); currentFrame = pushFrame(arc, BlockTreeTermsReader.FST_OUTPUTS.add(output, arc.nextFinalOutput), 0); output = BlockTreeTermsReader.FST_OUTPUTS.add(output, arc.output); currentFrame = pushFrame(arc, BlockTreeTermsReader.FST_OUTPUTS.add(output, arc.nextFinalOutput), targetUpto);
output[upto] = fst.outputs.add(output[upto-1], nextArc.output); if (targetLabel == FST.END_LABEL) {
/** * Returns the value mapped to the given key or <code>null</code> if the key is not in the FST dictionary. */ public BytesRef get(char[] buffer, int bufferLen, Arc<BytesRef> scratchArc, BytesReader fstReader) throws IOException { BytesRef pendingOutput = fst.outputs.getNoOutput(); BytesRef matchOutput = null; int bufUpto = 0; fst.getFirstArc(scratchArc); while (bufUpto < bufferLen) { final int codePoint = Character.codePointAt(buffer, bufUpto, bufferLen); if (fst.findTargetArc(ignoreCase ? Character.toLowerCase(codePoint) : codePoint, scratchArc, scratchArc, fstReader) == null) { return null; } pendingOutput = fst.outputs.add(pendingOutput, scratchArc.output); bufUpto += Character.charCount(codePoint); } if (scratchArc.isFinal()) { matchOutput = fst.outputs.add(pendingOutput, scratchArc.nextFinalOutput); } return matchOutput; }
assert arc.arcIdx == mid; assert arc.label == targetLabel: "arc.label=" + arc.label + " vs targetLabel=" + targetLabel + " mid=" + mid; output[upto] = fst.outputs.add(output[upto-1], arc.output); if (targetLabel == FST.END_LABEL) { return; output[upto] = fst.outputs.add(output[upto-1], arc.output); if (targetLabel == FST.END_LABEL) { return;
assert arc.arcIdx == mid; assert arc.label == targetLabel: "arc.label=" + arc.label + " vs targetLabel=" + targetLabel + " mid=" + mid; output[upto] = fst.outputs.add(output[upto-1], arc.output); if (targetLabel == FST.END_LABEL) { return; output[upto] = fst.outputs.add(output[upto-1], arc.output); if (targetLabel == FST.END_LABEL) { return;
pendingOutput = fst.outputs.add(pendingOutput, scratchArc.output); matchOutput = fst.outputs.add(pendingOutput, scratchArc.nextFinalOutput); matchInputLength = tokenCount; matchEndOffset = inputEndOffset; pendingOutput = fst.outputs.add(pendingOutput, scratchArc.output); if (nextRead == nextWrite) { capture();
pendingOutput = fst.outputs.add(pendingOutput, scratchArc.output); bufUpto += Character.charCount(codePoint); matchOutput = fst.outputs.add(pendingOutput, scratchArc.nextFinalOutput); matchInputLength = matchLength; matchEndOffset = inputEndOffset; pendingOutput = fst.outputs.add(pendingOutput, scratchArc.output); doFinalCapture = true; if (liveToken) {