/** * Returns an array with the probabilities for each tag of the last tagged sentence. * * @return an array with the probabilities for each tag of the last tagged sentence. */ public double[] probs() { return bestSequence.getProbs(); }
/** * Populates the specified array with the probabilities for each tag of the last tagged sentence. * * @param probs An array to put the probabilities into. */ public void probs(double[] probs) { bestSequence.getProbs(probs); }
/** * Populates the specified array with the probabilities of the last decoded sequence. The * sequence was determined based on the previous call to <code>chunk</code>. The * specified array should be at least as large as the numbe of tokens in the previous * call to <code>chunk</code>. * * @param probs An array used to hold the probabilities of the last decoded sequence. */ public void probs(double[] probs) { bestSequence.getProbs(probs); }
/** * Returns an array with the probabilities of the last decoded sequence. The * sequence was determined based on the previous call to <code>chunk</code>. * @return An array with the same number of probabilities as tokens were sent to <code>chunk</code> * when it was last called. */ public double[] probs() { return bestSequence.getProbs(); }
/** * Populates the specified array with the probabilities of the last decoded * sequence. The sequence was determined based on the previous call to * <code>chunk</code>. The specified array should be at least as large as the * number of tokens in the previous call to <code>chunk</code>. * * @param probs An array used to hold the probabilities of the last decoded * sequence. */ public void probs(double[] probs) { bestSequence.getProbs(probs); }
/** * Returns an array with the probabilities of the last decoded sequence. The * sequence was determined based on the previous call to <code>chunk</code>. * @return An array with the same number of probabilities as tokens were sent to <code>chunk</code> * when it was last called. */ public double[] probs() { return bestSequence.getProbs(); }
/** * Populates the specified array with the probabilities of the last decoded sequence. The * sequence was determined based on the previous call to <code>lemmatize</code>. The * specified array should be at least as large as the number of tokens in the * previous call to <code>lemmatize</code>. * * @param probs An array used to hold the probabilities of the last decoded sequence. */ public void probs(double[] probs) { bestSequence.getProbs(probs); }
/** * Returns an array with the probabilities of the last decoded sequence. The * sequence was determined based on the previous call to <code>chunk</code>. * * @return An array with the same number of probabilities as tokens were sent * to <code>chunk</code> when it was last called. */ public double[] probs() { return bestSequence.getProbs(); }
/** Returns an array of probabilities associated with the outcomes of this sequence. * @return an array of probabilities. */ public double[] getProbs() { double[] ps = new double[probs.size()]; getProbs(ps); return ps; }
/** * Returns an array of probabilities for each of the specified spans which is * the arithmetic mean of the probabilities for each of the outcomes which * make up the span. * * @param spans The spans of the names for which probabilities are desired. * * @return an array of probabilities for each of the specified spans. */ public double[] probs(Span[] spans) { double[] sprobs = new double[spans.length]; double[] probs = bestSequence.getProbs(); for (int si = 0; si < spans.length; si++) { double p = 0; for (int oi = spans[si].getStart(); oi < spans[si].getEnd(); oi++) { p += probs[oi]; } p /= spans[si].length(); sprobs[si] = p; } return sprobs; }
/** * Advances the parse by assigning it POS tags and returns multiple tag sequences. * @param p The parse to be tagged. * @return Parses with different POS-tag sequence assignments. */ protected Parse[] advanceTags(final Parse p) { Parse[] children = p.getChildren(); String[] words = new String[children.length]; double[] probs = new double[words.length]; for (int i = 0,il = children.length; i < il; i++) { words[i] = children[i].getCoveredText(); } Sequence[] ts = tagger.topKSequences(words); Parse[] newParses = new Parse[ts.length]; for (int i = 0; i < ts.length; i++) { String[] tags = ts[i].getOutcomes().toArray(new String[words.length]); ts[i].getProbs(probs); newParses[i] = (Parse) p.clone(); //copies top level if (createDerivationString) newParses[i].getDerivation().append(i).append("."); for (int j = 0; j < words.length; j++) { Parse word = children[j]; //System.err.println("inserting tag "+tags[j]); double prob = probs[j]; newParses[i].insert(new Parse(word.getText(), word.getSpan(), tags[j], prob,j)); newParses[i].addProb(Math.log(prob)); } } return newParses; }
/** * Returns an array with the probabilities of the last decoded sequence. The * sequence was determined based on the previous call to <code>chunk</code>. * * @return An array with the same number of probabilities as tokens were sent * to <code>chunk</code> when it was last called. */ public double[] probs() { return bestSequence.getProbs(); }
/** * Returns an array with the probabilities of the last decoded sequence. The * sequence was determined based on the previous call to <code>chunk</code>. * @return An array with the same number of probabilities as tokens were sent to <code>chunk</code> * when it was last called. */ public double[] probs() { return bestSequence.getProbs(); }
/** * Populates the specified array with the probabilities of the last decoded sequence. The * sequence was determined based on the previous call to <code>lemmatize</code>. The * specified array should be at least as large as the number of tokens in the * previous call to <code>lemmatize</code>. * * @param probs An array used to hold the probabilities of the last decoded sequence. */ public void probs(double[] probs) { bestSequence.getProbs(probs); }
/** * Tests {@link Sequence#add(String, double)}, also * tests {@link Sequence#getOutcomes()} and {@link Sequence#getProbs()}. */ @Test public void testAddMethod() { Sequence sequence = new Sequence(); sequence.add("a", 10d); // check if insert was successful Assert.assertEquals("a", sequence.getOutcomes().get(0)); Assert.assertEquals(10d, sequence.getProbs()[0], 0d); }
@Test public void testTokenProbArray() throws Exception { Sequence[] preds = chunker.topKSequences(toks1, tags1); Assert.assertTrue(preds.length > 0); Assert.assertEquals(expect1.length, preds[0].getProbs().length); Assert.assertEquals(Arrays.asList(expect1), preds[0].getOutcomes()); Assert.assertNotSame(Arrays.asList(expect1), preds[1].getOutcomes()); }
@Test public void testTokenProbMinScore() throws Exception { Sequence[] preds = chunker.topKSequences(toks1, tags1, -5.55); Assert.assertEquals(4, preds.length); Assert.assertEquals(expect1.length, preds[0].getProbs().length); Assert.assertEquals(Arrays.asList(expect1), preds[0].getOutcomes()); Assert.assertNotSame(Arrays.asList(expect1), preds[1].getOutcomes()); }
cs[si].getProbs(probs); int start = -1; int end = 0;
/** * Tests the copy constructor {@link Sequence#Sequence(Sequence)}. */ @Test public void testCopyConstructor() { Sequence sequence = new Sequence(); sequence.add("a", 10); sequence.add("b", 20); Sequence copy = new Sequence(sequence); Assert.assertEquals(sequence.getOutcomes(), copy.getOutcomes()); Assert.assertArrayEquals(sequence.getProbs(), copy.getProbs(), 0.0); Assert.assertTrue(sequence.compareTo(copy) == 0); }
/** Returns an array of probabilities associated with the outcomes of this sequence. * @return an array of probabilities. */ public double[] getProbs() { double[] ps = new double[probs.size()]; getProbs(ps); return ps; }