You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@opennlp.apache.org by "xia0c (Jira)" <ji...@apache.org> on 2020/02/02 16:21:00 UTC
[jira] [Updated] (OPENNLP-1286) Updating from 1.7.0 to 1.9.1 breaks
[ https://issues.apache.org/jira/browse/OPENNLP-1286?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
xia0c updated OPENNLP-1286:
---------------------------
Attachment: pt-leis.bin
Description:
When I try to upgrade Opennlp-tools from 1.7.0 to the version after 1.8.0. The following code breaks.
{code:java}
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Paths;
import org.junit.Test;
import opennlp.tools.doccat.DoccatModel;
import opennlp.tools.doccat.DocumentCategorizerME;
public class TestOpenNLP {
@Test
public void demo() throws FileNotFoundException {
classify("test");
}
public void classify(String summary) throws FileNotFoundException {
String bin = "/pt-leis.bin";
InputStream inputStrean = null;
try {
inputStrean = new FileInputStream(Paths.get(bin).toFile());
DoccatModel doccatModel = new DoccatModel(inputStrean);
DocumentCategorizerME myCategorizer = new DocumentCategorizerME(doccatModel);
double[] outcomes = myCategorizer.categorize(summary);
String category = myCategorizer.getBestCategory(outcomes);
} catch (IOException e) {
System.out.println(e);
}
}
}
{code}
The code should pass, but it throws an error:
{code:java}
incompatible types: java.lang.String cannot be converted to java.lang.String[]
{code}
was:
When I try to upgrade Opennlp-tools from 1.7.0 to the version after 1.8.0. The following code breaks.
{code:java}
public void demo(String summary) {
try {
inputStrean = new FileInputStream(Paths.get(bin).toFile());
DoccatModel doccatModel = new DoccatModel(inputStrean);
DocumentCategorizerME myCategorizer = new DocumentCategorizerME(doccatModel);
double[] outcomes = myCategorizer.categorize(summary);
String category = myCategorizer.getBestCategory(outcomes);
LOGGER.info(category);
} catch (IOException e) {
LOGGER.error(ExceptionUtils.getStackTrace(e));
}
}
{code}
The code should pass, but it throws an error:
{code:java}
incompatible types: java.lang.String cannot be converted to java.lang.String[]
{code}
> Updating from 1.7.0 to 1.9.1 breaks
> -----------------------------------
>
> Key: OPENNLP-1286
> URL: https://issues.apache.org/jira/browse/OPENNLP-1286
> Project: OpenNLP
> Issue Type: Bug
> Affects Versions: 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4
> Reporter: xia0c
> Priority: Major
> Attachments: pt-leis.bin
>
>
> When I try to upgrade Opennlp-tools from 1.7.0 to the version after 1.8.0. The following code breaks.
> {code:java}
> import java.io.FileInputStream;
> import java.io.FileNotFoundException;
> import java.io.IOException;
> import java.io.InputStream;
> import java.nio.file.Paths;
> import org.junit.Test;
> import opennlp.tools.doccat.DoccatModel;
> import opennlp.tools.doccat.DocumentCategorizerME;
> public class TestOpenNLP {
>
> @Test
> public void demo() throws FileNotFoundException {
> classify("test");
> }
>
> public void classify(String summary) throws FileNotFoundException {
>
>
> String bin = "/pt-leis.bin";
> InputStream inputStrean = null;
> try {
> inputStrean = new FileInputStream(Paths.get(bin).toFile());
> DoccatModel doccatModel = new DoccatModel(inputStrean);
> DocumentCategorizerME myCategorizer = new DocumentCategorizerME(doccatModel);
> double[] outcomes = myCategorizer.categorize(summary);
> String category = myCategorizer.getBestCategory(outcomes);
> } catch (IOException e) {
> System.out.println(e);
> }
> }
> }
> {code}
> The code should pass, but it throws an error:
> {code:java}
> incompatible types: java.lang.String cannot be converted to java.lang.String[]
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)