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:22:00 UTC

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=17028471#comment-17028471 ] 

xia0c commented on OPENNLP-1286:
--------------------------------

Hi [~smarthi], yes. I have updated my code and uploaded the related bin file.

> 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)