You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2014/03/27 09:20:10 UTC
svn commit: r1582213 - in /stanbol/branches/release-0.12/commons/opennlp/src:
main/java/org/apache/stanbol/commons/opennlp/OpenNLP.java
test/java/org/apache/commons/opennlp/OpenNLPTest.java
Author: rwesten
Date: Thu Mar 27 08:20:10 2014
New Revision: 1582213
URL: http://svn.apache.org/r1582213
Log:
fix for STANBOL-1302 for 0.12.1: created a new method that fixes the reported typo. Deprecated the old method. Adapted calling classes in the same module to use the new method; getTokenizer does no longer call getTokenizerModel(language) twice
Modified:
stanbol/branches/release-0.12/commons/opennlp/src/main/java/org/apache/stanbol/commons/opennlp/OpenNLP.java
stanbol/branches/release-0.12/commons/opennlp/src/test/java/org/apache/commons/opennlp/OpenNLPTest.java
Modified: stanbol/branches/release-0.12/commons/opennlp/src/main/java/org/apache/stanbol/commons/opennlp/OpenNLP.java
URL: http://svn.apache.org/viewvc/stanbol/branches/release-0.12/commons/opennlp/src/main/java/org/apache/stanbol/commons/opennlp/OpenNLP.java?rev=1582213&r1=1582212&r2=1582213&view=diff
==============================================================================
--- stanbol/branches/release-0.12/commons/opennlp/src/main/java/org/apache/stanbol/commons/opennlp/OpenNLP.java (original)
+++ stanbol/branches/release-0.12/commons/opennlp/src/main/java/org/apache/stanbol/commons/opennlp/OpenNLP.java Thu Mar 27 08:20:10 2014
@@ -186,7 +186,7 @@ public class OpenNLP {
try {
TokenizerModel model = getTokenizerModel(language);
if(model != null){
- tokenizer = new TokenizerME(getTokenizerModel(language));
+ tokenizer = new TokenizerME(model);
}
} catch (InvalidFormatException e) {
log.warn("Unable to load Tokenizer Model for "+language+": " +
@@ -212,8 +212,25 @@ public class OpenNLP {
* @return the model or <code>null</code> if no model data are found
* @throws InvalidFormatException in case the found model data are in the wrong format
* @throws IOException on any error while reading the model data
+ * @deprecated type in method name. Use {@link #getPartOfSpeechModel(String)} instead.
+ * Will get removed with <code>1.0</code>
+ * @see #getPartOfSpeechModel(String)
*/
public POSModel getPartOfSpeachModel(String language) throws IOException, InvalidFormatException {
+ return getPartOfSpeechModel(language);
+ }
+
+ /**
+ * Getter for the "part-of-speech" model for the parsed language.
+ * If the model is not yet available a new one is built. The required data
+ * are loaded by using the {@link DataFileProvider} service.
+ * @param language the language
+ * @return the model or <code>null</code> if no model data are found
+ * @throws InvalidFormatException in case the found model data are in the wrong format
+ * @throws IOException on any error while reading the model data
+ * @since 0.12.1
+ */
+ public POSModel getPartOfSpeechModel(String language) throws IOException, InvalidFormatException {
//typically there are two versions
//we prefer the perceptron variant but if not available try to build the other
IOException first = null;
Modified: stanbol/branches/release-0.12/commons/opennlp/src/test/java/org/apache/commons/opennlp/OpenNLPTest.java
URL: http://svn.apache.org/viewvc/stanbol/branches/release-0.12/commons/opennlp/src/test/java/org/apache/commons/opennlp/OpenNLPTest.java?rev=1582213&r1=1582212&r2=1582213&view=diff
==============================================================================
--- stanbol/branches/release-0.12/commons/opennlp/src/test/java/org/apache/commons/opennlp/OpenNLPTest.java (original)
+++ stanbol/branches/release-0.12/commons/opennlp/src/test/java/org/apache/commons/opennlp/OpenNLPTest.java Thu Mar 27 08:20:10 2014
@@ -92,14 +92,14 @@ public class OpenNLPTest {
}
@Test
public void testLoadEnPOS() throws IOException{
- POSModel model = openNLP.getPartOfSpeachModel("en");
+ POSModel model = openNLP.getPartOfSpeechModel("en");
Assert.assertNotNull(model);
POSTagger posTagger = openNLP.getPartOfSpeechTagger("en");
Assert.assertNotNull(posTagger);
}
@Test
public void testLoadMissingPOS() throws IOException{
- POSModel model = openNLP.getPartOfSpeachModel("ru");
+ POSModel model = openNLP.getPartOfSpeechModel("ru");
Assert.assertNull(model);
POSTagger posTagger = openNLP.getPartOfSpeechTagger("ru");
Assert.assertNull(posTagger);