You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by co...@apache.org on 2011/01/28 14:11:29 UTC
svn commit: r1064657 - in /incubator/opennlp/trunk/opennlp-tools/src:
main/java/opennlp/tools/chunker/ test/java/opennlp/tools/chunker/
Author: colen
Date: Fri Jan 28 13:11:29 2011
New Revision: 1064657
URL: http://svn.apache.org/viewvc?rev=1064657&view=rev
Log:
OPENNLP-107 List methods are now deprecated
Modified:
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/Chunker.java
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/ChunkerME.java
incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkerMETest.java
incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/chunker/DummyChunker.java
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/Chunker.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/Chunker.java?rev=1064657&r1=1064656&r2=1064657&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/Chunker.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/Chunker.java Fri Jan 28 13:11:29 2011
@@ -66,13 +66,27 @@ public interface Chunker {
* @param tags The pos-tags for the specified sentence.
*
* @return the top k chunk sequences for the specified sentence.
+ *
+ * @deprecated please use {@link #topKSequences(String[], String[])} instead.
*/
+ @Deprecated
public Sequence[] topKSequences(List<String> sentence, List<String> tags);
+
+
+ /**
+ * Returns the top k chunk sequences for the specified sentence with the specified pos-tags
+ * @param sentence The tokens of the sentence.
+ * @param tags The pos-tags for the specified sentence.
+ *
+ * @return the top k chunk sequences for the specified sentence.
+ */
+ public Sequence[] topKSequences(String[] sentence, String[] tags);
/**
* Returns the top k chunk sequences for the specified sentence with the specified pos-tags
* @param sentence The tokens of the sentence.
* @param tags The pos-tags for the specified sentence.
+ * @param minSequenceScore A lower bound on the score of a returned sequence.
*
* @return the top k chunk sequences for the specified sentence.
*/
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/ChunkerME.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/ChunkerME.java?rev=1064657&r1=1064656&r2=1064657&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/ChunkerME.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/ChunkerME.java Fri Jan 28 13:11:29 2011
@@ -151,6 +151,7 @@ public class ChunkerME implements Chunke
this.model = mod;
}
+ @Deprecated
public List<String> chunk(List<String> toks, List<String> tags) {
bestSequence =
beam.bestSequence(toks.toArray(new String[toks.size()]), new Object[] { (String[]) tags.toArray(new String[tags.size()]) });
@@ -168,10 +169,15 @@ public class ChunkerME implements Chunke
return ChunkSample.phrasesAsSpanList(toks, tags, preds);
}
+ @Deprecated
public Sequence[] topKSequences(List<String> sentence, List<String> tags) {
- return beam.bestSequences(DEFAULT_BEAM_SIZE,
- sentence.toArray(new String[sentence.size()]),
- new Object[] { tags.toArray(new String[tags.size()]) });
+ return topKSequences(sentence.toArray(new String[sentence.size()]),
+ tags.toArray(new String[tags.size()]));
+ }
+
+ public Sequence[] topKSequences(String[] sentence, String[] tags) {
+ return beam.bestSequences(DEFAULT_BEAM_SIZE, sentence,
+ new Object[] { tags });
}
public Sequence[] topKSequences(String[] sentence, String[] tags, double minSequenceScore) {
Modified: incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkerMETest.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkerMETest.java?rev=1064657&r1=1064656&r2=1064657&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkerMETest.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkerMETest.java Fri Jan 28 13:11:29 2011
@@ -120,8 +120,9 @@ public class ChunkerMETest {
}
@Test
- public void testTokenProb() throws Exception {
+ public void testTokenProbList() throws Exception {
+ @SuppressWarnings("deprecation")
Sequence[] preds = chunker.topKSequences(Arrays.asList(toks1),
Arrays.asList(tags1));
@@ -130,10 +131,21 @@ public class ChunkerMETest {
assertEquals(Arrays.asList(expect1), preds[0].getOutcomes());
assertNotSame(Arrays.asList(expect1), preds[1].getOutcomes());
}
-
+
@Test
public void testTokenProbArray() throws Exception {
+ Sequence[] preds = chunker.topKSequences(toks1, tags1);
+
+ assertTrue(preds.length > 0);
+ assertEquals(expect1.length, preds[0].getProbs().length);
+ assertEquals(Arrays.asList(expect1), preds[0].getOutcomes());
+ assertNotSame(Arrays.asList(expect1), preds[1].getOutcomes());
+ }
+
+ @Test
+ public void testTokenProbMinScore() throws Exception {
+
Sequence[] preds = chunker.topKSequences(toks1, tags1, -5.55);
assertTrue(preds.length == 4);
Modified: incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/chunker/DummyChunker.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/chunker/DummyChunker.java?rev=1064657&r1=1064656&r2=1064657&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/chunker/DummyChunker.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/chunker/DummyChunker.java Fri Jan 28 13:11:29 2011
@@ -81,4 +81,8 @@ public class DummyChunker implements Chu
return null;
}
+ public Sequence[] topKSequences(String[] sentence, String[] tags) {
+ return null;
+ }
+
}