[ 
https://issues.apache.org/jira/browse/OPENNLP-1307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17645226#comment-17645226
 ] 

ASF GitHub Bot commented on OPENNLP-1307:
-----------------------------------------

mawiesne opened a new pull request, #450:
URL: https://github.com/apache/opennlp/pull/450

   Change
   -
   - fixes `doccat.xml` as proposed in OPENNLP-1307; the current example in the 
DOC was inconsistent with `DocumentCategorizerME#categorize(..)` and required a 
change
   
   Tasks
   -
   Thank you for contributing to Apache OpenNLP.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [x] Does your PR title start with OPENNLP-XXXX where XXXX is the JIRA 
number you are trying to resolve? Pay particular attention to the hyphen "-" 
character.
   
   - [x] Has your PR been rebased against the latest commit within the target 
branch (typically master)?
   
   - [x] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [x] Have you ensured that the full suite of tests is executed via mvn 
clean install at the root opennlp folder?
   - [ ] Have you written or updated unit tests to verify your changes?
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)? 
   - [ ] If applicable, have you updated the LICENSE file, including the main 
LICENSE file in opennlp folder?
   - [ ] If applicable, have you updated the NOTICE file, including the main 
NOTICE file found in opennlp folder?
   
   ### For documentation related changes:
   - [x] Have you ensured that format looks appropriate for the output in which 
it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions for 
build issues and submit an update to your PR as soon as possible.
   




> Incorrect code example for Document Categorization (9.3)
> --------------------------------------------------------
>
>                 Key: OPENNLP-1307
>                 URL: https://issues.apache.org/jira/browse/OPENNLP-1307
>             Project: OpenNLP
>          Issue Type: Documentation
>          Components: Doccat
>    Affects Versions: 1.9.3
>         Environment: N/A
>            Reporter: John Slocum
>            Priority: Major
>              Labels: DocumentCategorizerME, documentation
>   Original Estimate: 2m
>  Remaining Estimate: 2m
>
> in 
> [https://opennlp.apache.org/docs/1.9.3/manual/opennlp.html#tools.doccat.classifying.api,]
> the code example feeds a String into DocumentCategorizerME.categorize(). The 
> method itself takes an array. I flagged priority as Major because this was a 
> killer - obviously it's a self-documenting bug when you run it, but I made 
> the mistake of assuming that the array actually needed would be an array of 
> documents - instead it needs to be an array of tokens from a single document, 
> i.e. one needs to split() the doc on whitespace. Lost 24 hours experimenting 
> with algos (maxent vs. naive_bayes) and params (cutoff, iterations, etc) 
> before figuring this one out.
>  
> Current(wrong) version:
>  
> {code:java}
> String inputText = ...
> DocumentCategorizerME myCategorizer = new DocumentCategorizerME(m);
> double[] outcomes = myCategorizer.categorize(inputText);
> String category = myCategorizer.getBestCategory(outcomes);
> {code}
>  
> Should be more like:
>  
> {code:java}
> String inputText = ... // sanitized document to be categorized
> DocumentCategorizerME myCategorizer = new DocumentCategorizerME(m);
> double[] outcomes = myCategorizer.categorize(inputText.split(" ");
> String category = myCategorizer.getBestCategory(outcomes);
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to