[
https://issues.apache.org/jira/browse/OPENNLP-1594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17865886#comment-17865886
]
ASF GitHub Bot commented on OPENNLP-1594:
-----------------------------------------
mawiesne commented on code in PR #158:
URL: https://github.com/apache/opennlp-sandbox/pull/158#discussion_r1677366259
##########
summarizer/src/main/java/opennlp/summarization/lexicalchaining/LexChainingKeywordExtractor.java:
##########
@@ -22,20 +22,45 @@
import java.util.List;
/**
- * Uses the lexical chaining algorithm to extract keywords.
+ * Uses the {@link LexicalChain lexical chaining} algorithm to extract
keywords.
+ *
+ * @see LexicalChain
*/
public class LexChainingKeywordExtractor {
- // Simple logic to pull out the keyword based on longest lexical chains..
- public List<String> getKeywords(List<LexicalChain> lexicalChains, int
noOfKeywords) {
- Collections.sort(lexicalChains);
- List<String> ret = new ArrayList<>();
- for (int i = 0; i < Math.min(lexicalChains.size(), noOfKeywords); i++) {
- List<Word> words = lexicalChains.get(i).getWord();
- if (!words.isEmpty() && !ret.contains(words.get(0).getLexicon())) {
- ret.add(words.get(0).getLexicon());
+ /**
+ * Extracts keywords from a list of {@link LexicalChain lexical chains},
limited by {@code noOfKeywords}.
+ *
+ * @param lexicalChains The {@link LexicalChain lexical chains} to process.
Must not be {@code null}.
+ * @param noOfKeywords The upper limit of keywords. Must be greater than
{@code zero}.
+ *
+ * @return The extracted keywords as a list. Guaranteed to be not {@code
null}.
+ *
+ * @throws IllegalArgumentException Thrown if parameters are invalid.
+ * @implNote This operation is based on longest lexical chains.
Review Comment:
That's cool! :)
> Add stricter tests for Summarizer component
> -------------------------------------------
>
> Key: OPENNLP-1594
> URL: https://issues.apache.org/jira/browse/OPENNLP-1594
> Project: OpenNLP
> Issue Type: Test
> Affects Versions: 2.3.3
> Reporter: Martin Wiesner
> Assignee: Martin Wiesner
> Priority: Major
> Fix For: 2.4.0
>
>
> While OPENNLP-1592 and OPENNLP-1593 raised test coverage for the summarizer
> component, there are still some "dark spots" and probably inaccuracies in the
> implementation of that component. More, stricter tests shall shed light on
> the situation.
> Aims:
> * add further, stricter tests for the summarizer component
> * clarify, at API level, the semantics and constraints of parameters
> * better separate tests so that each test class has a clear responsibility
> for its class under test
> * improve / enhance the JavaDoc further
--
This message was sent by Atlassian Jira
(v8.20.10#820010)