int[] bestSequence = tagInference.bestSequence(model);
private void runTagInference() { this.initializeScorer(); if (Thread.interrupted()) { // Allow interrupting throw new RuntimeInterruptedException(); } BestSequenceFinder ti = new ExactBestSequenceFinder(); //new BeamBestSequenceFinder(50); //new KBestSequenceFinder() int[] bestTags = ti.bestSequence(this); finalTags = new String[bestTags.length]; for (int j = 0; j < size; j++) { finalTags[j] = maxentTagger.tags.getTag(bestTags[j + leftWindow()]); } if (Thread.interrupted()) { // Allow interrupting throw new RuntimeInterruptedException(); } cleanUpScorer(); }
public static void main(String[] args) { BestSequenceFinder ti = new ExactBestSequenceFinder(); SequenceModel ts = new TestSequenceModel(); int[] bestTags = ti.bestSequence(ts); System.out.println("The best sequence is ... " + Arrays.toString(bestTags)); }
public static void main(String[] args) { BestSequenceFinder ti = new BeamBestSequenceFinder(4, true); SequenceModel ts = new TestSequenceModel(); int[] bestTags = ti.bestSequence(ts); System.out.println("The best sequence is .... " + Arrays.toString(bestTags)); }
private List<IN> classifyMaxEnt(List<IN> document, SequenceModel model) { if (document.isEmpty()) { return document; } if (flags.inferenceType == null) { flags.inferenceType = "Viterbi"; } BestSequenceFinder tagInference; if (flags.inferenceType.equalsIgnoreCase("Viterbi")) { tagInference = new ExactBestSequenceFinder(); } else if (flags.inferenceType.equalsIgnoreCase("Beam")) { tagInference = new BeamBestSequenceFinder(flags.beamSize); } else { throw new RuntimeException("Unknown inference type: "+flags.inferenceType+". Your options are Viterbi|Beam."); } int[] bestSequence = tagInference.bestSequence(model); if (flags.useReverse) { Collections.reverse(document); } for (int j = 0, docSize = document.size(); j < docSize; j++) { IN wi = document.get(j); String guess = classIndex.get(bestSequence[j + windowSize - 1]); wi.set(AnswerAnnotation.class, guess); } if (flags.useReverse) { Collections.reverse(document); } return document; }
private List<IN> classifyMaxEnt(List<IN> document, SequenceModel model) { if (document.isEmpty()) { return document; } if (flags.inferenceType == null) { flags.inferenceType = "Viterbi"; } BestSequenceFinder tagInference; if (flags.inferenceType.equalsIgnoreCase("Viterbi")) { tagInference = new ExactBestSequenceFinder(); } else if (flags.inferenceType.equalsIgnoreCase("Beam")) { tagInference = new BeamBestSequenceFinder(flags.beamSize); } else { throw new RuntimeException("Unknown inference type: " + flags.inferenceType + ". Your options are Viterbi|Beam."); } int[] bestSequence = tagInference.bestSequence(model); if (flags.useReverse) { Collections.reverse(document); } for (int j = 0, docSize = document.size(); j < docSize; j++) { IN wi = document.get(j); String guess = classIndex.get(bestSequence[j + windowSize - 1]); wi.set(CoreAnnotations.AnswerAnnotation.class, guess); } if (flags.useReverse) { Collections.reverse(document); } return document; }
int[] bestSequence = tagInference.bestSequence(model);
private void runTagInference() { this.initializeScorer(); if (Thread.interrupted()) { // Allow interrupting throw new RuntimeInterruptedException(); } BestSequenceFinder ti = new ExactBestSequenceFinder(); //new BeamBestSequenceFinder(50); //new KBestSequenceFinder() int[] bestTags = ti.bestSequence(this); finalTags = new String[bestTags.length]; for (int j = 0; j < size; j++) { finalTags[j] = maxentTagger.tags.getTag(bestTags[j + leftWindow()]); } if (Thread.interrupted()) { // Allow interrupting throw new RuntimeInterruptedException(); } cleanUpScorer(); }
private void runTagInference() { this.initializeScorer(); BestSequenceFinder ti = new ExactBestSequenceFinder(); //new BeamBestSequenceFinder(50); //new KBestSequenceFinder() int[] bestTags = ti.bestSequence(this); finalTags = new String[bestTags.length]; for (int j = 0; j < size; j++) { finalTags[j] = maxentTagger.tags.getTag(bestTags[j + leftWindow()]); } cleanUpScorer(); }
private void runTagInference() { this.initializeScorer(); BestSequenceFinder ti = new ExactBestSequenceFinder(); //new BeamBestSequenceFinder(50); //new KBestSequenceFinder() int[] bestTags = ti.bestSequence(this); finalTags = new String[bestTags.length]; for (int j = 0; j < size; j++) { finalTags[j] = maxentTagger.tags.getTag(bestTags[j + leftWindow()]); } cleanUpScorer(); }
private void runTagInference() { this.initializeScorer(); if (Thread.interrupted()) { // Allow interrupting throw new RuntimeInterruptedException(); } BestSequenceFinder ti = new ExactBestSequenceFinder(); //new BeamBestSequenceFinder(50); //new KBestSequenceFinder() int[] bestTags = ti.bestSequence(this); finalTags = new String[bestTags.length]; for (int j = 0; j < size; j++) { finalTags[j] = maxentTagger.tags.getTag(bestTags[j + leftWindow()]); } if (Thread.interrupted()) { // Allow interrupting throw new RuntimeInterruptedException(); } cleanUpScorer(); }