You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@opennlp.apache.org by "mawiesne (via GitHub)" <gi...@apache.org> on 2023/02/06 16:25:16 UTC

[GitHub] [opennlp-sandbox] mawiesne commented on a diff in pull request #76: Update sandbox component 'summarizer' to be compatible with latest opennlp-tools release

mawiesne commented on code in PR #76:
URL: https://github.com/apache/opennlp-sandbox/pull/76#discussion_r1097617281


##########
summarizer/src/main/java/opennlp/summarization/DocProcessor.java:
##########
@@ -21,17 +21,27 @@
 
 import opennlp.tools.stemmer.Stemmer;
 
-/*
+/**
  * A document processor abstracts a lot of the underlying complexities of parsing the document and 
- * preparing it (e.g. stemming, stop word removal) from the summarization algorithm. The current package
- * supports sentence extraction based algorithms. Thus extracting Sentences from the text is the
- * first step and the basis for the algorithms.
+ * preparing it (e.g. stemming, stop word removal) from the summarization algorithm.
+ * <p>
+ * The current package supports sentence extraction based algorithms.
+ * Thus extracting Sentences from the text is the first step and the basis for the algorithms.

Review Comment:
   I beautify this in ~2-3 hours.



##########
summarizer/src/main/java/opennlp/summarization/Sentence.java:
##########
@@ -133,36 +133,36 @@ public int getWordCnt()
 	}
 
 	//Should add an article id to the sentence class.. For now returns true if the ids are the same..
+	@Override
 	public boolean equals(Object o){
 		if(! (o instanceof Sentence)) return false;
-
 		Sentence s = (Sentence)o;
-		if(s.sentId == this.sentId) return true;
-		return false;
+		return s.sentId == this.sentId;
 	}
 
-	static final String space=" ";
+	private static final String SPACE = " ";
+
 	public String stem() {
 		PorterStemmer stemmer = new PorterStemmer();
-	    StopWords sw = StopWords.getInstance();      
+		StopWords sw = StopWords.getInstance();
 
-	    BreakIterator wrdItr = BreakIterator.getWordInstance(Locale.US);
+		BreakIterator wrdItr = BreakIterator.getWordInstance(Locale.US);
 		int wrdStrt = 0;
-		StringBuffer b = new StringBuffer();
+		StringBuilder b = new StringBuilder();
 		wrdItr.setText(stringVal);	
 		for(int wrdEnd = wrdItr.next(); wrdEnd != BreakIterator.DONE; 
 				wrdStrt = wrdEnd, wrdEnd = wrdItr.next())
 		{
 			String word = this.getStringVal().substring(wrdStrt, wrdEnd);//words[i].trim();
-			word.replaceAll("\"|'","");
+			word = word.replaceAll("\"|'","");

Review Comment:
   I beautify this in ~2-3 hours.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org