[ https://issues.apache.org/jira/browse/OPENNLP-789?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17907362#comment-17907362 ]
ASF GitHub Bot commented on OPENNLP-789: ---------------------------------------- mawiesne commented on code in PR #200: URL: https://github.com/apache/opennlp-sandbox/pull/200#discussion_r1893846337 ########## opennlp-wsd/src/main/java/opennlp/tools/disambiguator/FeaturesExtractor.java: ########## @@ -155,31 +158,43 @@ public List<String> extractTrainingSurroundingWords(List<WTDIMS> trainingData) { } /** - * This method generates the different set of features related to the IMS - * approach and store them in the corresponding attributes of the {@link WTDIMS}. + * Generates the different set of features related to the IMS + * approach and puts them in the corresponding attributes of + * the {@link WTDIMS word to disambiguate} object. * * @param wtd The {@link WTDIMS word to disambiguate}. * @param windowSize The parameter required to generate the features qualified of * "PoS of Surrounding Words". * @param ngram The parameter required to generate the features qualified of * "Local Collocations". + * + * @throws IllegalArgumentException Thrown if parameters were invalid. */ public void extractIMSFeatures(WTDIMS wtd, int windowSize, int ngram) { + if (wtd == null) { + throw new IllegalArgumentException("WTD must not be null"); + } wtd.setPosOfSurroundingWords(extractPosOfSurroundingWords(wtd, windowSize)); wtd.setSurroundingWords(extractSurroundingWords(wtd)); wtd.setLocalCollocations(extractLocalCollocations(wtd, ngram)); } /** - * This generates the context of IMS. It supposes that the features have - * already been extracted and stored in the {@link WTDIMS} object, therefore it - * doesn't require any parameters. + * Generates the context for the {@link WTDIMS word to disambiguate}. + * + * @implNote It is assumed that the features have already been extracted and + * wrapped in the {@link WTDIMS word to disambiguate}. + * Therefore, it doesn't require any parameters. * - * @param wtd The {@link WTDIMS wtd to disambiguate}. + * @param wtd The {@link WTDIMS word to disambiguate}. * @param listSurrWords The full list of surrounding words of the training data. + * + * @throws IllegalArgumentException Thrown if parameters were invalid. */ public void serializeIMSFeatures(WTDIMS wtd, List<String> listSurrWords) { - + if (wtd == null) { Review Comment: @rzo1 FYI: https://issues.apache.org/jira/browse/OPENNLP-1676 ########## opennlp-wsd/src/main/java/opennlp/tools/disambiguator/Disambiguator.java: ########## @@ -24,21 +24,29 @@ import java.util.List; /** - * A word sense disambiguator that determines which sense of a word is meant in - * a particular context. It is a classification task, where the classes are the - * different senses of the ambiguous word. Disambiguation can be achieved in - * either supervised or un-supervised approaches. A {@link Disambiguator} returns - * a sense ID. + * Describes a word sense disambiguator that determines which sense of a word is + * meant in a particular context. + * It is a classification task, where the classes are the different senses of + * the ambiguous word. Disambiguation can be achieved in either supervised or + * un-supervised approaches. A {@link Disambiguator} returns a sense ID. * <p> * <b>How it works:</b><br/> - * Just supply the context as an array of tokens and the - * index of the target word to the disambiguate method. + * Just supply the {@code context} as an array of tokens and the index of the + * {@code target word} to the disambiguate method. * <p> - * Otherwise, for multiple words, you can set a word span instead of simply one - * index. For the moment the source of sense definitions is from WordNet. + * Otherwise, for multiple words, you can set a word {@link Span} instead of + * a single target index. */ public interface Disambiguator { + /** + * Conducts disambiguation for a {@link WSDSample} context. + * + * @param sample The {@link WSDSample} containing the word and POS tags to use. Review Comment: @rzo1 FYI: https://issues.apache.org/jira/browse/OPENNLP-1676 > Extend JavaDoc for WSD component > -------------------------------- > > Key: OPENNLP-789 > URL: https://issues.apache.org/jira/browse/OPENNLP-789 > Project: OpenNLP > Issue Type: Improvement > Components: wsd > Reporter: Jörn Kottmann > Assignee: Martin Wiesner > Priority: Major > Labels: wsd > Fix For: 2.5.2 > > > The WSDisambiguator is the main interface for the wsd component. It should > have much more javadocs explaining what it does and what wsd is. > Additionally add at least short javadocs to each class and method in the > disambiguator package. One sentence is the minimum here. -- This message was sent by Atlassian Jira (v8.20.10#820010)