You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2011/07/19 10:42:25 UTC
svn commit: r1148237 -
/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java
Author: joern
Date: Tue Jul 19 08:42:24 2011
New Revision: 1148237
URL: http://svn.apache.org/viewvc?rev=1148237&view=rev
Log:
OPENNLP-230 Changed calculation of probs for name spans
Modified:
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java?rev=1148237&r1=1148236&r2=1148237&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java Tue Jul 19 08:42:24 2011
@@ -290,8 +290,8 @@ public class NameFinderME implements Tok
}
/**
- * Returns an array of probabilities for each of the specified spans which is the product
- * the probabilities for each of the outcomes which make up the span.
+ * 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.
*
@@ -302,14 +302,16 @@ public class NameFinderME implements Tok
double[] sprobs = new double[spans.length];
double[] probs = bestSequence.getProbs();
- for (int si=0;si<spans.length;si++) {
+ for (int si=0; si<spans.length; si++) {
- double p = 1;
+ double p = 0;
for (int oi = spans[si].getStart(); oi < spans[si].getEnd(); oi++) {
- p *= probs[oi];
+ p += probs[oi];
}
+ p /= spans[si].length();
+
sprobs[si] = p;
}