This is an automated email from the ASF dual-hosted git repository.

mawiesne pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/opennlp-sandbox.git


The following commit(s) were added to refs/heads/master by this push:
     new 7633cd6  modernizes existing classes towards best practices (#96)
7633cd6 is described below

commit 7633cd644b3a90c80f60acdca826989601161821
Author: Martin Wiesner <[email protected]>
AuthorDate: Thu Apr 13 20:05:30 2023 +0200

    modernizes existing classes towards best practices (#96)
---
 .../caseditor/CorpusExplorerView.java              |  78 ++++++--------
 .../corpus_server/caseditor/TaskQueueView.java     |  30 +++---
 .../apache/opennlp/caseditor/TypeInputDialog.java  |  20 ++--
 .../ConfirmedNameDetectionFieldEditor.java         |   7 +-
 .../namefinder/EntityContentProvider.java          | 118 ++++++++++-----------
 .../caseditor/namefinder/MultiModelNameFinder.java |   2 +-
 .../namefinder/NameFinderModelFieldEditor.java     |   4 +-
 .../caseditor/namefinder/NameFinderViewPage.java   |  42 ++++----
 .../caseditor/sentdetect/SentenceDetectorJob.java  |   2 +-
 .../connector/CSCollectionReaderTest.java          |   1 -
 .../opennlp/corpus_server/CorpusServerBundle.java  |  38 ++++---
 .../corpus_server/util/TestCorpusServer.java       |   2 -
 .../corpus_server/impl/DerbyCorpusStore.java       |   1 -
 .../corpus_server/impl/LuceneSearchService.java    |  32 ++----
 .../opennlp/corpus_server/tools/CASImporter.java   |   7 +-
 .../opennlp/utils/cfg/ContextFreeGrammar.java      |   2 +-
 .../utils/cfg/ProbabilisticContextFreeGrammar.java |   2 +-
 .../java/org/apache/opennlp/utils/TestUtils.java   |   2 +-
 .../opennlp/utils/cfg/ContextFreeGrammarTest.java  |   6 +-
 .../cfg/ProbabilisticContextFreeGrammarTest.java   |  16 +--
 .../org/apache/opennlp/utils/cfg/RuleTest.java     |   2 +-
 .../tools/cmdline/coref/CoreferencerTool.java      |   2 +-
 .../java/opennlp/tools/coref/CorefTrainer.java     |   2 +-
 .../tools/coref/mention/AbstractMentionFinder.java |   2 +-
 .../opennlp/tools/coref/mention/DefaultParse.java  |   6 +-
 .../tools/coref/mention/JWNLDictionary.java        |   4 +-
 .../tools/coref/mention/MentionContext.java        |   2 +-
 .../resolver/DefaultNonReferentialResolver.java    |   6 +-
 .../tools/coref/resolver/MaxentResolver.java       |   6 +-
 .../coref/resolver/SpeechPronounResolver.java      |   8 +-
 .../main/java/opennlp/tools/coref/sim/Context.java |   7 +-
 .../java/opennlp/tools/coref/sim/GenderModel.java  |   4 +-
 .../java/opennlp/tools/coref/sim/NumberModel.java  |   4 +-
 .../opennlp/tools/coref/sim/SimilarityModel.java   |   6 +-
 .../muc/Muc6FullParseCorefSampleStreamFactory.java |   7 +-
 .../tools/formats/muc/MucCorefContentHandler.java  |   4 +-
 .../opennlp/tools/lang/english/TreebankLinker.java |   4 +-
 .../main/java/opennlp/tools/dl/NameFinderDL.java   |   2 +-
 .../apps/object_dedup/SimilarityAccessorBase.java  |   8 +-
 .../apps/relevanceVocabs/PhraseProcessor.java      |  12 +--
 .../review_builder/MachineTranslationWrapper.java  |   6 +-
 .../DocClassifierTrainingSetVerifier.java          |   4 +-
 .../jsmlearning/FeatureSpaceCoverageProcessor.java |  12 +--
 .../JSMLearnerOnLatticeWithDeduction.java          |   4 +-
 .../tools/jsmlearning/ProfileReaderWriter.java     |   1 -
 .../java/opennlp/tools/parse_thicket/Pair.java     |   3 +-
 .../opennlp/tools/parse_thicket/ParseTreeNode.java |   6 +-
 .../matching/NERPhraseGeneralizer.java             |   2 +-
 .../parse_thicket/matching/PhraseGeneralizer.java  |   2 +-
 .../opennlp/tools/similarity/apps/HitBase.java     |   4 +-
 .../apps/solr/IterativeSearchRequestHandler.java   |   3 +-
 .../solr/SearchResultsReRankerRequestHandler.java  |   4 +-
 .../apps/utils/StringDistanceMeasurer.java         |   4 +-
 .../tools/textsimilarity/ParseTreeChunk.java       |  20 ++--
 .../tools/textsimilarity/ParseTreeMatcher.java     |   8 +-
 .../tools/textsimilarity/TextProcessor.java        |  50 ++++-----
 .../pattern_structure/PhraseTest.java              |   2 +-
 .../tools/textsimilarity/SyntMatcherTest.java      |   1 -
 .../chunker2matcher/PhraseNodeTest.java            |   3 +-
 .../src/test/resources/sentence_parseObject.csv    |   2 +-
 .../tools/disambiguator/FeaturesExtractor.java     |   2 +-
 .../disambiguator/IMSWSDContextGenerator.java      |   4 +-
 .../disambiguator/OSCCWSDContextGenerator.java     |   2 +-
 .../tools/disambiguator/datareader/Paragraph.java  |   4 +-
 .../tools/disambiguator/datareader/Sentence.java   |   4 +-
 .../namefind/BratNameFinderResource.java           |   2 +-
 .../org/apache/opennlp/normalizer/Normalizer.java  |   4 +-
 67 files changed, 297 insertions(+), 376 deletions(-)

diff --git 
a/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusExplorerView.java
 
b/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusExplorerView.java
index a6b268c..352d115 100644
--- 
a/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusExplorerView.java
+++ 
b/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusExplorerView.java
@@ -112,28 +112,24 @@ public class CorpusExplorerView extends ViewPart {
       @Override
       public void done(final IJobChangeEvent event) {
         
-        Display.getDefault().asyncExec(new Runnable() {
+        Display.getDefault().asyncExec(() -> {
+          if (event.getResult().isOK()) {
 
-          @Override
-          public void run() {
-            if (event.getResult().isOK()) {
+            setMessage(null);
 
-              setMessage(null);
+            searchResultViewer.setItemCount(0);
+            JSONArray searchResult = searchJob.getSearchResult();
 
-              searchResultViewer.setItemCount(0);
-              JSONArray searchResult = searchJob.getSearchResult();
-
-              for (int i = 0; i < searchResult.length(); i++) {
-                try {
-                  searchResultViewer.add(searchResult.getString(i));
-                } catch (JSONException e) {
-                  setMessage("Error, failed to parse results.");
-                }
+            for (int i = 0; i < searchResult.length(); i++) {
+              try {
+                searchResultViewer.add(searchResult.getString(i));
+              } catch (JSONException e) {
+                setMessage("Error, failed to parse results.");
               }
             }
-            else {
-              setMessage("Fetching search results from server failed!");
-            }
+          }
+          else {
+            setMessage("Fetching search results from server failed!");
           }
         });
       }
@@ -166,13 +162,7 @@ public class CorpusExplorerView extends ViewPart {
     
     serverUrl.setText(lastUsedServer);
     
-    serverUrl.addModifyListener(new ModifyListener() {
-      
-      @Override
-      public void modifyText(ModifyEvent event) {
-        
store.setValue(CorpusServerPreferenceConstants.LAST_USED_SERVER_ADDRESS, 
serverUrl.getText());
-      }
-    });
+    serverUrl.addModifyListener(event -> 
store.setValue(CorpusServerPreferenceConstants.LAST_USED_SERVER_ADDRESS, 
serverUrl.getText()));
     
     // Search field to view content of corpus
     Label queryLabel = new Label(explorerComposite, SWT.NONE);
@@ -287,28 +277,24 @@ public class CorpusExplorerView extends ViewPart {
         return arg0.toString();
       }});
     
-    searchResultViewer.addOpenListener(new IOpenListener() {
-      
-      @Override
-      public void open(OpenEvent event) {
-        
-        IWorkbenchPage page = CorpusExplorerView.this.getSite().getPage();
-        
-        StructuredSelection selection = (StructuredSelection) 
searchResultViewer.getSelection();
-        
-        if (selection.isEmpty())
-          return;
-        
-        String selectedCAS = (String) selection.getFirstElement();
-        
-        // Hard code it for now, lets work on retrieval code first ...
-        IEditorInput input = new 
CorpusServerCasEditorInput(serverUrl.getText(), selectedCAS);
-        
-        try {
-          page.openEditor(input, "org.apache.uima.caseditor.editor");
-        } catch (PartInitException e) {
-          e.printStackTrace();
-        }
+    searchResultViewer.addOpenListener(event -> {
+
+      IWorkbenchPage page = CorpusExplorerView.this.getSite().getPage();
+
+      StructuredSelection selection = (StructuredSelection) 
searchResultViewer.getSelection();
+
+      if (selection.isEmpty())
+        return;
+
+      String selectedCAS = (String) selection.getFirstElement();
+
+      // Hard code it for now, lets work on retrieval code first ...
+      IEditorInput input = new CorpusServerCasEditorInput(serverUrl.getText(), 
selectedCAS);
+
+      try {
+        page.openEditor(input, "org.apache.uima.caseditor.editor");
+      } catch (PartInitException e) {
+        e.printStackTrace();
       }
     });
 
diff --git 
a/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/TaskQueueView.java
 
b/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/TaskQueueView.java
index 7c65546..11ba134 100644
--- 
a/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/TaskQueueView.java
+++ 
b/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/TaskQueueView.java
@@ -167,23 +167,19 @@ public class TaskQueueView extends ViewPart {
       GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
         .span(2, 1).applyTo(historyViewer.getTable());
     
-      historyViewer.addOpenListener(new IOpenListener() {
-        
-        @Override
-        public void open(OpenEvent event) {
-          
-          StructuredSelection selection = (StructuredSelection) 
event.getSelection();
-          
-          if (!selection.isEmpty()) {
-            IWorkbenchPage page = TaskQueueView.this.getSite().getPage();
-            
-            IEditorInput input = (IEditorInput) selection.getFirstElement();
-
-            try {
-              page.openEditor(input, "org.apache.uima.caseditor.editor");
-            } catch (PartInitException e) {
-              e.printStackTrace();
-            }
+      historyViewer.addOpenListener(event -> {
+
+        StructuredSelection selection = (StructuredSelection) 
event.getSelection();
+
+        if (!selection.isEmpty()) {
+          IWorkbenchPage page = TaskQueueView.this.getSite().getPage();
+
+          IEditorInput input = (IEditorInput) selection.getFirstElement();
+
+          try {
+            page.openEditor(input, "org.apache.uima.caseditor.editor");
+          } catch (PartInitException e) {
+            e.printStackTrace();
           }
         }
       });
diff --git 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/TypeInputDialog.java
 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/TypeInputDialog.java
index f9b92ec..6c37546 100644
--- 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/TypeInputDialog.java
+++ 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/TypeInputDialog.java
@@ -31,19 +31,15 @@ public class TypeInputDialog extends InputDialog {
   // TODO: Dialog should show some kind of list with existing types ...
   
   public TypeInputDialog(Shell parent, final TypeSystem ts) {
-    super(parent,"Add a type", "Type name:", "", new IInputValidator() {
-      
-      @Override
-      public String isValid(String value) {
-        
-        String result = null;
-        
-        if (ts.getType(value) == null) {
-          return "Type does not exist in type system!";
-        }
-        
-        return result;
+    super(parent,"Add a type", "Type name:", "", value -> {
+
+      String result = null;
+
+      if (ts.getType(value) == null) {
+        return "Type does not exist in type system!";
       }
+
+      return result;
     });
   }
 }
\ No newline at end of file
diff --git 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/ConfirmedNameDetectionFieldEditor.java
 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/ConfirmedNameDetectionFieldEditor.java
index 2402dc3..e70ec1a 100644
--- 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/ConfirmedNameDetectionFieldEditor.java
+++ 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/ConfirmedNameDetectionFieldEditor.java
@@ -61,12 +61,7 @@ public class ConfirmedNameDetectionFieldEditor extends 
FieldEditor {
 
     forceDetectionButton = new Button(buttonGroup, SWT.CHECK);
     forceDetectionButton.setText("Force the detection of existing names");
-    forceDetectionButton.addListener(SWT.Selection, new Listener(){
-
-      @Override
-      public void handleEvent(Event event) {
-        checkState();
-      }});
+    forceDetectionButton.addListener(SWT.Selection, event -> checkState());
 
     Composite optionButtons = new Composite(buttonGroup, SWT.NONE);
     optionButtons.setLayout(new GridLayout());
diff --git 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java
 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java
index 1335ecd..7b2a81b 100644
--- 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java
+++ 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java
@@ -209,68 +209,64 @@ public class EntityContentProvider implements 
IStructuredContentProvider {
   private class NameFinderJobListener extends JobChangeAdapter {
     public void done(final IJobChangeEvent event) {
       
-      Display.getDefault().asyncExec(new Runnable() {
-        
-        @Override
-        public void run() {
-          
-          // TODO: Check if view is still available, that might be called 
after view is disposed.
-          
-          IStatus status = event.getResult();
-          
-          if (status.isOK()) {
-            EntityContentProvider.this.nameFinderView.setMessage(null);
-            
-            List<PotentialAnnotation> detectedEntities = 
EntityContentProvider.this.nameFinder.getNames();
-            
-            // Remove all detected entities from the last run which are not 
detected anymore
-            for (Iterator<PotentialAnnotation> it = 
candidateEntities.iterator(); it.hasNext();) {
-              PotentialAnnotation entity = it.next();
-              if (searchEntity(detectedEntities, entity.getBeginIndex(),
-                  entity.getEndIndex(), entity.getType()) == null)  {
-                
-                // TODO: Create an array of entities that should be removed, 
much faster ...
-                EntityContentProvider.this.entityListViewer.remove(entity);
-                
-                // Can safely be removed, since it can only be an un-confirmed 
entity
-                it.remove();
-              }
+      Display.getDefault().asyncExec(() -> {
+
+        // TODO: Check if view is still available, that might be called after 
view is disposed.
+
+        IStatus status = event.getResult();
+
+        if (status.isOK()) {
+          EntityContentProvider.this.nameFinderView.setMessage(null);
+
+          List<PotentialAnnotation> detectedEntities = 
EntityContentProvider.this.nameFinder.getNames();
+
+          // Remove all detected entities from the last run which are not 
detected anymore
+          for (Iterator<PotentialAnnotation> it = 
candidateEntities.iterator(); it.hasNext();) {
+            PotentialAnnotation entity = it.next();
+            if (searchEntity(detectedEntities, entity.getBeginIndex(),
+                entity.getEndIndex(), entity.getType()) == null)  {
+
+              // TODO: Create an array of entities that should be removed, 
much faster ...
+              EntityContentProvider.this.entityListViewer.remove(entity);
+
+              // Can safely be removed, since it can only be an un-confirmed 
entity
+              it.remove();
             }
-            
-            // Update if entity already exist, or add it
-            for (PotentialAnnotation detectedEntity : detectedEntities) {
-              
-              // Bug: 
-              // There can be multiple entities in this span!
-              // In this case we want to keep the first, update it, and 
discard the others!
-              
-              // Case: One entity spanning two tokens replaces 
-              
-              PotentialAnnotation entity = searchEntity(candidateEntities, 
detectedEntity.getBeginIndex(),
-                  detectedEntity.getEndIndex(), detectedEntity.getType());
-              
-              // A confirmed entity already exists, update its confidence score
-              if (entity != null) {
-                  entity.setBeginIndex(detectedEntity.getBeginIndex());
-                  entity.setEndIndex(detectedEntity.getEndIndex());
-                  entity.setEntityText(detectedEntity.getEntityText());
-                  entity.setConfidence(detectedEntity.getConfidence());
-                  
-                  EntityContentProvider.this.entityListViewer.refresh(entity);
-              }
-              else {
-                // Only add if it is not a confirmed entity!
-                if (searchEntity(confirmedEntities, 
detectedEntity.getBeginIndex(),
-                  detectedEntity.getEndIndex(), detectedEntity.getType()) == 
null) {
-                  
EntityContentProvider.this.entityListViewer.add(detectedEntity);
-                  candidateEntities.add(detectedEntity);
-                }
+          }
+
+          // Update if entity already exist, or add it
+          for (PotentialAnnotation detectedEntity : detectedEntities) {
+
+            // Bug:
+            // There can be multiple entities in this span!
+            // In this case we want to keep the first, update it, and discard 
the others!
+
+            // Case: One entity spanning two tokens replaces
+
+            PotentialAnnotation entity = searchEntity(candidateEntities, 
detectedEntity.getBeginIndex(),
+                detectedEntity.getEndIndex(), detectedEntity.getType());
+
+            // A confirmed entity already exists, update its confidence score
+            if (entity != null) {
+                entity.setBeginIndex(detectedEntity.getBeginIndex());
+                entity.setEndIndex(detectedEntity.getEndIndex());
+                entity.setEntityText(detectedEntity.getEntityText());
+                entity.setConfidence(detectedEntity.getConfidence());
+
+                EntityContentProvider.this.entityListViewer.refresh(entity);
+            }
+            else {
+              // Only add if it is not a confirmed entity!
+              if (searchEntity(confirmedEntities, 
detectedEntity.getBeginIndex(),
+                detectedEntity.getEndIndex(), detectedEntity.getType()) == 
null) {
+                
EntityContentProvider.this.entityListViewer.add(detectedEntity);
+                candidateEntities.add(detectedEntity);
               }
             }
           }
-          else {
-            
EntityContentProvider.this.nameFinderView.setMessage(status.getMessage());
-          }
+        }
+        else {
+          
EntityContentProvider.this.nameFinderView.setMessage(status.getMessage());
         }
       });
     }
@@ -496,14 +492,14 @@ public class EntityContentProvider implements 
IStructuredContentProvider {
         return;
       }
       
-      nameFinder.setSentences(sentences.toArray(new Span[sentences.size()]));
+      nameFinder.setSentences(sentences.toArray(new Span[0]));
       
       if (tokens.size() == 0) {
         nameFinderView.setMessage("CAS must at least contain one token within 
a sentence!");
         return;
       }
       
-      nameFinder.setTokens(tokens.toArray(new Span[tokens.size()]));
+      nameFinder.setTokens(tokens.toArray(new Span[0]));
       nameFinder.setModelPath(modelPathes, nameTypeNames);
       
       if (!nameFinder.isSystem()) {
@@ -514,7 +510,7 @@ public class EntityContentProvider implements 
IStructuredContentProvider {
           
store.getBoolean(OpenNLPPreferenceConstants.ENABLE_CONFIRMED_NAME_DETECTION);
       
       if (isRecallBoostingEnabled) {
-        nameFinder.setVerifiedNames(nameSpans.toArray(new 
Span[nameSpans.size()]));
+        nameFinder.setVerifiedNames(nameSpans.toArray(new Span[0]));
       }
       else {
         nameFinder.setVerifiedNames(null);
diff --git 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/MultiModelNameFinder.java
 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/MultiModelNameFinder.java
index e935f2b..ff44d9f 100644
--- 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/MultiModelNameFinder.java
+++ 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/MultiModelNameFinder.java
@@ -158,6 +158,6 @@ public class MultiModelNameFinder implements 
TokenNameFinder {
     
     // TODO: Merge names here ...
     
-    return names.toArray(new ConfidenceSpan[names.size()]);
+    return names.toArray(new ConfidenceSpan[0]);
   }
 }
diff --git 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderModelFieldEditor.java
 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderModelFieldEditor.java
index 590eb79..e6bde5f 100644
--- 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderModelFieldEditor.java
+++ 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderModelFieldEditor.java
@@ -202,8 +202,8 @@ class NameFinderModelFieldEditor extends FieldEditor {
       typeNames.add(typeName);
     }
 
-    String modelPathsString = 
TypeListFieldEditor.listToString(modelPaths.toArray(new 
String[modelPaths.size()]));
-    String typeNamesString = 
TypeListFieldEditor.listToString(typeNames.toArray(new 
String[typeNames.size()]));
+    String modelPathsString = 
TypeListFieldEditor.listToString(modelPaths.toArray(new String[0]));
+    String typeNamesString = 
TypeListFieldEditor.listToString(typeNames.toArray(new String[0]));
 
     
getPreferenceStore().setValue(OpenNLPPreferenceConstants.NAME_FINDER_MODEL_PATH,
 modelPathsString);
     getPreferenceStore().setValue(OpenNLPPreferenceConstants.NAME_TYPE, 
typeNamesString);
diff --git 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java
 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java
index 570501d..1e86482 100644
--- 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java
+++ 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java
@@ -115,29 +115,25 @@ class NameFinderViewPage extends Page implements 
ISelectionListener {
     
     getSite().setSelectionProvider(entityList);
     
-    entityList.addSelectionChangedListener(new ISelectionChangedListener() {
-               
-               @Override
-               public void selectionChanged(SelectionChangedEvent event) {
-                       StructuredSelection selection = (StructuredSelection) 
event.getSelection();
-                       
-                       // There are two types of entities, confirmed and 
un-confirmed.
-                       // Confirmed entities are linked with the according 
annotation and
-                       // are selected through the entity lists selection 
provider.
-                       
-                       // Unconfirmed entities are not selected, but the span 
they are covering
-                       // is highlighted and revealed in the Annotation Editor.
-                       
-                       if (!selection.isEmpty()) {
-                         PotentialAnnotation entity = (PotentialAnnotation) 
selection.getFirstElement();
-                               
-                         if (editor instanceof AnnotationEditor) {
-                           ((AnnotationEditor) 
editor).selectAndReveal(entity.getBeginIndex(),
-                               entity.getEndIndex() - entity.getBeginIndex());
-                         }
-                       }
-               }
-       });
+    entityList.addSelectionChangedListener(event -> {
+      StructuredSelection selection = (StructuredSelection) 
event.getSelection();
+
+      // There are two types of entities, confirmed and un-confirmed.
+      // Confirmed entities are linked with the according annotation and
+      // are selected through the entity lists selection provider.
+
+      // Unconfirmed entities are not selected, but the span they are covering
+      // is highlighted and revealed in the Annotation Editor.
+
+      if (!selection.isEmpty()) {
+        PotentialAnnotation entity = (PotentialAnnotation) 
selection.getFirstElement();
+
+        if (editor instanceof AnnotationEditor) {
+          ((AnnotationEditor) editor).selectAndReveal(entity.getBeginIndex(),
+              entity.getEndIndex() - entity.getBeginIndex());
+        }
+      }
+    });
     
     // Display the messageLabel after start up
     book.showPage(messageText);
diff --git 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java
 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java
index e1c1e8c..04197b9 100644
--- 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java
+++ 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java
@@ -136,6 +136,6 @@ public class SentenceDetectorJob extends Job {
   }
 
   PotentialAnnotation[] getDetectedSentences() {
-    return detectedSentences.toArray(new 
PotentialAnnotation[detectedSentences.size()]);
+    return detectedSentences.toArray(new PotentialAnnotation[0]);
   }
 }
diff --git 
a/corpus-server/corpus-server-connector/src/test/java/org/apache/opennlp/corpus_server/connector/CSCollectionReaderTest.java
 
b/corpus-server/corpus-server-connector/src/test/java/org/apache/opennlp/corpus_server/connector/CSCollectionReaderTest.java
index e0d1caf..cef7db7 100644
--- 
a/corpus-server/corpus-server-connector/src/test/java/org/apache/opennlp/corpus_server/connector/CSCollectionReaderTest.java
+++ 
b/corpus-server/corpus-server-connector/src/test/java/org/apache/opennlp/corpus_server/connector/CSCollectionReaderTest.java
@@ -18,7 +18,6 @@
 package org.apache.opennlp.corpus_server.connector;
 
 
-import org.apache.opennlp.corpus_server.CorpusServer;
 import org.apache.opennlp.corpus_server.impl.DerbyCorporaStore;
 import org.apache.opennlp.corpus_server.store.CorporaStore;
 import org.apache.uima.UIMAFramework;
diff --git 
a/corpus-server/corpus-server-core/src/main/java/org/apache/opennlp/corpus_server/CorpusServerBundle.java
 
b/corpus-server/corpus-server-core/src/main/java/org/apache/opennlp/corpus_server/CorpusServerBundle.java
index 8db7261..01fb678 100644
--- 
a/corpus-server/corpus-server-core/src/main/java/org/apache/opennlp/corpus_server/CorpusServerBundle.java
+++ 
b/corpus-server/corpus-server-core/src/main/java/org/apache/opennlp/corpus_server/CorpusServerBundle.java
@@ -53,34 +53,32 @@ public class CorpusServerBundle implements BundleActivator {
     
     context.getServiceReference(CorpusServer.class.getName());
 
-    ServiceListener sl = new ServiceListener() {
-      public void serviceChanged(ServiceEvent ev) {
+    ServiceListener sl = ev -> {
 
-        switch (ev.getType()) {
-        case ServiceEvent.REGISTERED: {
+      switch (ev.getType()) {
+      case ServiceEvent.REGISTERED: {
 
-          if (corpusServer == null) {
-            System.out.println("Registered a Corpus Server implementation!");
+        if (corpusServer == null) {
+          System.out.println("Registered a Corpus Server implementation!");
 
-            corpusServerServiceReference = ev.getServiceReference();
-            corpusServer = (CorpusServer) context
-                .getService(corpusServerServiceReference);
-          }
+          corpusServerServiceReference = ev.getServiceReference();
+          corpusServer = (CorpusServer) context
+              .getService(corpusServerServiceReference);
         }
-          break;
-        case ServiceEvent.UNREGISTERING: {
+      }
+        break;
+      case ServiceEvent.UNREGISTERING: {
 
-          if (ev.getServiceReference().equals(corpusServerServiceReference)) {
-            System.out.println("Unregistered Corpus Server implementation!");
+        if (ev.getServiceReference().equals(corpusServerServiceReference)) {
+          System.out.println("Unregistered Corpus Server implementation!");
 
-            context.ungetService(corpusServerServiceReference);
-            corpusServerServiceReference = null;
-            corpusServer = null;
-          }
-        }
-          break;
+          context.ungetService(corpusServerServiceReference);
+          corpusServerServiceReference = null;
+          corpusServer = null;
         }
       }
+        break;
+      }
     };
 
     String filter = "(objectclass=" + CorpusServer.class.getName() + ")";
diff --git 
a/corpus-server/corpus-server-core/src/test/java/org/apache/opennlp/corpus_server/util/TestCorpusServer.java
 
b/corpus-server/corpus-server-core/src/test/java/org/apache/opennlp/corpus_server/util/TestCorpusServer.java
index da2fdf8..722a5fb 100644
--- 
a/corpus-server/corpus-server-core/src/test/java/org/apache/opennlp/corpus_server/util/TestCorpusServer.java
+++ 
b/corpus-server/corpus-server-core/src/test/java/org/apache/opennlp/corpus_server/util/TestCorpusServer.java
@@ -17,8 +17,6 @@
 
 package org.apache.opennlp.corpus_server.util;
 
-import org.apache.opennlp.corpus_server.CorpusServer;
-
 /**
  * Utility CorpusServer extension class that can be used for test purposes.
  */
diff --git 
a/corpus-server/corpus-server-impl/src/main/java/org/apache/opennlp/corpus_server/impl/DerbyCorpusStore.java
 
b/corpus-server/corpus-server-impl/src/main/java/org/apache/opennlp/corpus_server/impl/DerbyCorpusStore.java
index d287075..8e5807a 100644
--- 
a/corpus-server/corpus-server-impl/src/main/java/org/apache/opennlp/corpus_server/impl/DerbyCorpusStore.java
+++ 
b/corpus-server/corpus-server-impl/src/main/java/org/apache/opennlp/corpus_server/impl/DerbyCorpusStore.java
@@ -23,7 +23,6 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.Statement;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
diff --git 
a/corpus-server/corpus-server-impl/src/main/java/org/apache/opennlp/corpus_server/impl/LuceneSearchService.java
 
b/corpus-server/corpus-server-impl/src/main/java/org/apache/opennlp/corpus_server/impl/LuceneSearchService.java
index 8d207c1..d4b3672 100644
--- 
a/corpus-server/corpus-server-impl/src/main/java/org/apache/opennlp/corpus_server/impl/LuceneSearchService.java
+++ 
b/corpus-server/corpus-server-impl/src/main/java/org/apache/opennlp/corpus_server/impl/LuceneSearchService.java
@@ -145,23 +145,13 @@ public class LuceneSearchService implements SearchService 
{
       // and replace the index path with the index location for this corpus
       
       Properties indexWriterProperties = new Properties();
-      
-      InputStream indexWriterPropertiesIn = null;
-      try {
+
+      try (InputStream indexWriterPropertiesIn = 
LuceneSearchService.class.getResourceAsStream(
+              
"/org/apache/opennlp/corpus_server/impl/IndexWriter.properties")) {
         // TODO: Retrieve file form somewhere for this corpus
-        indexWriterPropertiesIn = 
LuceneSearchService.class.getResourceAsStream(
-            "/org/apache/opennlp/corpus_server/impl/IndexWriter.properties");
-      
+
         indexWriterProperties.load(indexWriterPropertiesIn);
       }
-      finally {
-        if (indexWriterPropertiesIn != null) {
-          try {
-            indexWriterPropertiesIn.close();
-          }
-          catch (IOException e) {}
-        }
-      }
       
       
indexWriterProperties.setProperty(IndexWriterProviderImpl.INDEX_PATH_PROPERTY,
           getIndexDirectory(corpusId).getAbsolutePath());
@@ -171,21 +161,11 @@ public class LuceneSearchService implements SearchService 
{
       
       File indexWriterTmpFile = File.createTempFile("index-writer", corpusId + 
".properties");
       indexWriterTmpFile.deleteOnExit();
-      
-      OutputStream indexPropertiesOut = null; 
-      try {
-        indexPropertiesOut = new FileOutputStream(indexWriterTmpFile);
+
+      try (OutputStream indexPropertiesOut = new 
FileOutputStream(indexWriterTmpFile)) {
         // write properties into a tmp file
         indexWriterProperties.store(indexPropertiesOut, null);
       }
-      finally {
-        if (indexPropertiesOut != null) {
-          try {
-            indexPropertiesOut.close();
-          }
-          catch (IOException e) {}
-        }
-      }
       
       FileResourceSpecifier indexWriterFileSpecifier = new 
FileResourceSpecifier_impl();
       
indexWriterFileSpecifier.setFileUrl(indexWriterTmpFile.toURI().toString());
diff --git 
a/corpus-server/corpus-server-tools/src/main/java/org/apache/opennlp/corpus_server/tools/CASImporter.java
 
b/corpus-server/corpus-server-tools/src/main/java/org/apache/opennlp/corpus_server/tools/CASImporter.java
index 68fc6c1..796432a 100644
--- 
a/corpus-server/corpus-server-tools/src/main/java/org/apache/opennlp/corpus_server/tools/CASImporter.java
+++ 
b/corpus-server/corpus-server-tools/src/main/java/org/apache/opennlp/corpus_server/tools/CASImporter.java
@@ -46,12 +46,7 @@ public class CASImporter {
     if (xmiFileOrFolder.isFile()) {
       xmiFiles = new File[] { xmiFileOrFolder };
     } else {
-      xmiFiles = xmiFileOrFolder.listFiles(new FilenameFilter() {
-        @Override
-        public boolean accept(File dir, String name) {
-          return name.toLowerCase().endsWith(".xmi");
-        }
-      });
+      xmiFiles = xmiFileOrFolder.listFiles((dir, name) -> 
name.toLowerCase().endsWith(".xmi"));
     }
 
     for (File xmiFile : xmiFiles) {
diff --git 
a/nlp-utils/src/main/java/org/apache/opennlp/utils/cfg/ContextFreeGrammar.java 
b/nlp-utils/src/main/java/org/apache/opennlp/utils/cfg/ContextFreeGrammar.java
index e3e4826..08c74ca 100644
--- 
a/nlp-utils/src/main/java/org/apache/opennlp/utils/cfg/ContextFreeGrammar.java
+++ 
b/nlp-utils/src/main/java/org/apache/opennlp/utils/cfg/ContextFreeGrammar.java
@@ -72,7 +72,7 @@ public class ContextFreeGrammar {
     for (String word : words) {
       expansion.addAll(getTerminals(word));
     }
-    return expansion.toArray(new String[expansion.size()]);
+    return expansion.toArray(new String[0]);
 
   }
 
diff --git 
a/nlp-utils/src/main/java/org/apache/opennlp/utils/cfg/ProbabilisticContextFreeGrammar.java
 
b/nlp-utils/src/main/java/org/apache/opennlp/utils/cfg/ProbabilisticContextFreeGrammar.java
index 2a9d9e0..0ca0ff6 100644
--- 
a/nlp-utils/src/main/java/org/apache/opennlp/utils/cfg/ProbabilisticContextFreeGrammar.java
+++ 
b/nlp-utils/src/main/java/org/apache/opennlp/utils/cfg/ProbabilisticContextFreeGrammar.java
@@ -93,7 +93,7 @@ public class ProbabilisticContextFreeGrammar {
     for (String word : words) {
       expansion.addAll(getTerminals(word));
     }
-    return expansion.toArray(new String[expansion.size()]);
+    return expansion.toArray(new String[0]);
   }
 
   private Collection<String> getTerminals(String word) {
diff --git a/nlp-utils/src/test/java/org/apache/opennlp/utils/TestUtils.java 
b/nlp-utils/src/test/java/org/apache/opennlp/utils/TestUtils.java
index 4b6bbdb..7b7cd40 100644
--- a/nlp-utils/src/test/java/org/apache/opennlp/utils/TestUtils.java
+++ b/nlp-utils/src/test/java/org/apache/opennlp/utils/TestUtils.java
@@ -42,7 +42,7 @@ public class TestUtils {
 
   public static Collection<String[]> generateRandomVocabulary() {
     int size = R.nextInt(1000);
-    Collection<String[]> vocabulary = new ArrayList<String[]>(size);
+    Collection<String[]> vocabulary = new ArrayList<>(size);
     for (int i = 0; i < size; i++) {
       String[] sentence = generateRandomSentence();
       vocabulary.add(sentence);
diff --git 
a/nlp-utils/src/test/java/org/apache/opennlp/utils/cfg/ContextFreeGrammarTest.java
 
b/nlp-utils/src/test/java/org/apache/opennlp/utils/cfg/ContextFreeGrammarTest.java
index afb8149..fe42c8c 100644
--- 
a/nlp-utils/src/test/java/org/apache/opennlp/utils/cfg/ContextFreeGrammarTest.java
+++ 
b/nlp-utils/src/test/java/org/apache/opennlp/utils/cfg/ContextFreeGrammarTest.java
@@ -38,7 +38,7 @@ class ContextFreeGrammarTest {
 
   @BeforeAll
   static void setUp() throws Exception {
-    nonTerminals = new LinkedList<String>();
+    nonTerminals = new LinkedList<>();
     nonTerminals.add("S");
     nonTerminals.add("NP");
     nonTerminals.add("VP");
@@ -55,7 +55,7 @@ class ContextFreeGrammarTest {
 
     startSymbol = "S";
 
-    terminals = new LinkedList<String>();
+    terminals = new LinkedList<>();
     terminals.add("works");
     terminals.add("saw");
     terminals.add("man");
@@ -76,7 +76,7 @@ class ContextFreeGrammarTest {
     terminals.add("of");
     terminals.add("for");
 
-    rules = new LinkedList<Rule>();
+    rules = new LinkedList<>();
     rules.add(new Rule("S", "NP", "VP"));
     rules.add(new Rule("P", "S", "CJ", "S"));
     rules.add(new Rule("P", "S", "DJ", "S"));
diff --git 
a/nlp-utils/src/test/java/org/apache/opennlp/utils/cfg/ProbabilisticContextFreeGrammarTest.java
 
b/nlp-utils/src/test/java/org/apache/opennlp/utils/cfg/ProbabilisticContextFreeGrammarTest.java
index 55742f9..4eb60d1 100644
--- 
a/nlp-utils/src/test/java/org/apache/opennlp/utils/cfg/ProbabilisticContextFreeGrammarTest.java
+++ 
b/nlp-utils/src/test/java/org/apache/opennlp/utils/cfg/ProbabilisticContextFreeGrammarTest.java
@@ -48,7 +48,7 @@ class ProbabilisticContextFreeGrammarTest {
 
   @BeforeAll
   static void setUp() throws Exception {
-    nonTerminals = new LinkedList<String>();
+    nonTerminals = new LinkedList<>();
     nonTerminals.add("S");
     nonTerminals.add("NP");
     nonTerminals.add("VP");
@@ -62,7 +62,7 @@ class ProbabilisticContextFreeGrammarTest {
 
     startSymbol = "S";
 
-    terminals = new LinkedList<String>();
+    terminals = new LinkedList<>();
     terminals.add("works");
     terminals.add("saw");
     terminals.add("man");
@@ -85,7 +85,7 @@ class ProbabilisticContextFreeGrammarTest {
     terminals.add("badly");
     terminals.add("nicely");
 
-    rules = new HashMap<Rule, Double>();
+    rules = new HashMap<>();
     rules.put(new Rule("S", "NP", "VP"), 1d);
     rules.put(new Rule("VP", "Vi", "Adv"), 0.3);
     rules.put(new Rule("VP", "Vt", "NP"), 0.7);
@@ -112,7 +112,7 @@ class ProbabilisticContextFreeGrammarTest {
 
   @Test
   void testIntermediateProbability() throws Exception {
-    ArrayList<String> sentence = new ArrayList<String>();
+    ArrayList<String> sentence = new ArrayList<>();
     sentence.add("the");
     sentence.add("dog");
     sentence.add("saw");
@@ -136,7 +136,7 @@ class ProbabilisticContextFreeGrammarTest {
     ProbabilisticContextFreeGrammar pcfg = new 
ProbabilisticContextFreeGrammar(nonTerminals, terminals, rules, startSymbol, 
true);
 
     // fixed sentence one
-    List<String> sentence = new ArrayList<String>();
+    List<String> sentence = new ArrayList<>();
     sentence.add("the");
     sentence.add("dog");
     sentence.add("saw");
@@ -147,7 +147,7 @@ class ProbabilisticContextFreeGrammarTest {
     check(pcfg, parseTree, sentence);
 
     // fixed sentence two
-    sentence = new ArrayList<String>();
+    sentence = new ArrayList<>();
     sentence.add("the");
     sentence.add("man");
     sentence.add("works");
@@ -184,7 +184,7 @@ class ProbabilisticContextFreeGrammarTest {
       return Arrays.asList(parseTree.getRule().getExpansion());
     }
 
-    ArrayList<String> list = new ArrayList<String>();
+    ArrayList<String> list = new ArrayList<>();
     list.addAll(getTerminals(parseTree.getLeftTree()));
     list.addAll(getTerminals(parseTree.getRightTree()));
     return list;
@@ -245,7 +245,7 @@ class ProbabilisticContextFreeGrammarTest {
     InputStream resourceAsStream = 
getClass().getResourceAsStream("/it-tb-news.txt");
     BufferedReader bufferedReader = new BufferedReader(new 
InputStreamReader(resourceAsStream));
     Collection<String> sentences = parseSentences(bufferedReader);
-    ProbabilisticContextFreeGrammar cfg = 
ProbabilisticContextFreeGrammar.parseGrammar(sentences.toArray(new 
String[sentences.size()]));
+    ProbabilisticContextFreeGrammar cfg = 
ProbabilisticContextFreeGrammar.parseGrammar(sentences.toArray(new String[0]));
     assertNotNull(cfg);
     String[] derivation = cfg.leftMostDerivation("S");
     assertNotNull(derivation);
diff --git a/nlp-utils/src/test/java/org/apache/opennlp/utils/cfg/RuleTest.java 
b/nlp-utils/src/test/java/org/apache/opennlp/utils/cfg/RuleTest.java
index 4856930..5613000 100644
--- a/nlp-utils/src/test/java/org/apache/opennlp/utils/cfg/RuleTest.java
+++ b/nlp-utils/src/test/java/org/apache/opennlp/utils/cfg/RuleTest.java
@@ -53,7 +53,7 @@ class RuleTest {
 
   @Test
   void testCompare() throws Exception {
-    TreeSet<Rule> rules = new TreeSet<Rule>();
+    TreeSet<Rule> rules = new TreeSet<>();
     Rule r1 = new Rule("NP", "DT", "NN");
     Rule r2 = new Rule("NP", "NP", "PP");
     rules.add(r1);
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/cmdline/coref/CoreferencerTool.java 
b/opennlp-coref/src/main/java/opennlp/tools/cmdline/coref/CoreferencerTool.java
index a634c10..dbd8dcc 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/cmdline/coref/CoreferencerTool.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/cmdline/coref/CoreferencerTool.java
@@ -133,7 +133,7 @@ public class CoreferencerTool extends BasicCmdLineTool {
 
           if (line.equals("")) {
             DiscourseEntity[] entities =
-                treebankLinker.getEntities(document.toArray(new 
Mention[document.size()]));
+                treebankLinker.getEntities(document.toArray(new Mention[0]));
             //showEntities(entities);
             new CorefParse(parses, entities).show();
             sentenceNumber = 0;
diff --git a/opennlp-coref/src/main/java/opennlp/tools/coref/CorefTrainer.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/CorefTrainer.java
index 9123afa..08e800a 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/CorefTrainer.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/CorefTrainer.java
@@ -81,7 +81,7 @@ public class CorefTrainer {
       mentions.addAll(Arrays.asList(extents));
     }
     
-    return mentions.toArray(new Mention[mentions.size()]);
+    return mentions.toArray(new Mention[0]);
   }
   
   public static void train(String modelDirectory, ObjectStream<CorefSample> 
samples,
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java
 
b/opennlp-coref/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java
index 43f1ce6..350c0ad 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java
@@ -304,7 +304,7 @@ public abstract class AbstractMentionFinder implements 
MentionFinder {
     }
     Collections.sort(mentions);
     removeDuplicates(mentions);
-    return mentions.toArray(new Mention[mentions.size()]);
+    return mentions.toArray(new Mention[0]);
   }
 
   /*
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/mention/DefaultParse.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/mention/DefaultParse.java
index d3566e1..0282957 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/mention/DefaultParse.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/mention/DefaultParse.java
@@ -73,7 +73,7 @@ public class DefaultParse extends AbstractParse {
         kids.addAll(Arrays.asList(p.getChildren()));
       }
     }
-    return createParses(names.toArray(new Parse[names.size()]));
+    return createParses(names.toArray(new Parse[0]));
   }
 
   @Override
@@ -92,7 +92,7 @@ public class DefaultParse extends AbstractParse {
         ci--;
       }
     }
-    return createParses(kids.toArray(new Parse[kids.size()]));
+    return createParses(kids.toArray(new Parse[0]));
   }
 
   @Override
@@ -108,7 +108,7 @@ public class DefaultParse extends AbstractParse {
         kids.addAll(0,Arrays.asList(p.getChildren()));
       }
     }
-    return createParses(tokens.toArray(new Parse[tokens.size()]));
+    return createParses(tokens.toArray(new Parse[0]));
   }
 
   @Override
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/mention/JWNLDictionary.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/mention/JWNLDictionary.java
index b6cdb79..1f27ae3 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/coref/mention/JWNLDictionary.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/coref/mention/JWNLDictionary.java
@@ -104,7 +104,7 @@ public class JWNLDictionary implements Dictionary {
         pos = POS.NOUN;
       }
       List<String> lemmas = morphy.lookupAllBaseForms(pos,word);
-      return lemmas.toArray(new String[lemmas.size()]);
+      return lemmas.toArray(new String[0]);
     }
     catch (JWNLException e) {
       e.printStackTrace();
@@ -159,7 +159,7 @@ public class JWNLDictionary implements Dictionary {
         Synset synset = iw.getSense(sense + 1);
         List<String> parents = new ArrayList<>();
         getParents(synset,parents);
-        return parents.toArray(new String[parents.size()]);
+        return parents.toArray(new String[0]);
       }
       else {
         return EMPTY;
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/mention/MentionContext.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/mention/MentionContext.java
index a359d41..610b73a 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/coref/mention/MentionContext.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/coref/mention/MentionContext.java
@@ -133,7 +133,7 @@ public class MentionContext extends Context {
     nextToken = parse.getNextToken();
     head = headFinder.getLastHead(parse);
     List<Parse> headTokens = head.getTokens();
-    tokens = headTokens.toArray(new Parse[headTokens.size()]);
+    tokens = headTokens.toArray(new Parse[0]);
     basalNextToken = head.getNextToken();
     //System.err.println("MentionContext.init: "+ent+" "+ent.getEntityId()+" 
head="+head);
     nonDescriptorStart = 0;
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/resolver/DefaultNonReferentialResolver.java
 
b/opennlp-coref/src/main/java/opennlp/tools/coref/resolver/DefaultNonReferentialResolver.java
index 6e23c3d..f6475a6 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/coref/resolver/DefaultNonReferentialResolver.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/coref/resolver/DefaultNonReferentialResolver.java
@@ -79,7 +79,7 @@ public class DefaultNonReferentialResolver implements 
NonReferentialResolver {
   @Override
   public double getNonReferentialProbability(MentionContext mention) {
     List<String> features = getFeatures(mention);
-    double r = model.eval(features.toArray(new 
String[features.size()]))[nonRefIndex];
+    double r = model.eval(features.toArray(new String[0]))[nonRefIndex];
     if (debugOn) System.err.println(this + " " + mention.toText() + " ->  null 
" + r + " " + features);
     return r;
   }
@@ -88,10 +88,10 @@ public class DefaultNonReferentialResolver implements 
NonReferentialResolver {
   public void addEvent(MentionContext ec) {
     List<String> features = getFeatures(ec);
     if (-1 == ec.getId()) {
-      events.add(new Event(MaxentResolver.SAME, features.toArray(new 
String[features.size()])));
+      events.add(new Event(MaxentResolver.SAME, features.toArray(new 
String[0])));
     }
     else {
-      events.add(new Event(MaxentResolver.DIFF, features.toArray(new 
String[features.size()])));
+      events.add(new Event(MaxentResolver.DIFF, features.toArray(new 
String[0])));
     }
   }
 
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/resolver/MaxentResolver.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/resolver/MaxentResolver.java
index 858765d..323e863 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/coref/resolver/MaxentResolver.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/coref/resolver/MaxentResolver.java
@@ -198,7 +198,7 @@ public abstract class MaxentResolver extends 
AbstractResolver {
       else {
 
         List<String> lfeatures = getFeatures(ec, de);
-        String[] features = lfeatures.toArray(new String[lfeatures.size()]);
+        String[] features = lfeatures.toArray(new String[0]);
         try {
           candProbs[ei] = model.eval(features)[sameIndex];
         }
@@ -290,7 +290,7 @@ public abstract class MaxentResolver extends 
AbstractResolver {
 
             if (mention.getId() != -1 && entityMention.getId() == 
mention.getId()) {
               referentFound = true;
-              events.add(new Event(SAME, features.toArray(new 
String[features.size()])));
+              events.add(new Event(SAME, features.toArray(new String[0])));
               de = cde;
               //System.err.println("MaxentResolver.retain: resolved at "+ei);
               // incrementing count for key 'ei'
@@ -298,7 +298,7 @@ public abstract class MaxentResolver extends 
AbstractResolver {
             }
             else if (!pairedSampleSelection || (!nonReferentFound && 
useAsDifferentExample)) {
               nonReferentFound = true;
-              events.add(new Event(DIFF, features.toArray(new 
String[features.size()])));
+              events.add(new Event(DIFF, features.toArray(new String[0])));
             }
           //}
         }
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/resolver/SpeechPronounResolver.java
 
b/opennlp-coref/src/main/java/opennlp/tools/coref/resolver/SpeechPronounResolver.java
index b853b34..f841522 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/coref/resolver/SpeechPronounResolver.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/coref/resolver/SpeechPronounResolver.java
@@ -55,16 +55,12 @@ public class SpeechPronounResolver extends MaxentResolver {
         features.add(mention.getHeadTokenText() + "," + 
cec.getHeadTokenText());
       }
       else if (mention.getHeadTokenText().startsWith("NNP")) {
-        for (String context : contexts) {
-          features.add(context);
-        }
+        features.addAll(contexts);
         features.add(mention.getNameType() + "," + cec.getHeadTokenText());
       }
       else {
         List<String> ccontexts = ResolverUtils.getContextFeatures(cec);
-        for (String ccontext : ccontexts) {
-          features.add(ccontext);
-        }
+        features.addAll(ccontexts);
         features.add(cec.getNameType() + "," + mention.getHeadTokenText());
       }
     }
diff --git a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/Context.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/Context.java
index 4ff5d0d..fa52417 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/Context.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/Context.java
@@ -17,6 +17,7 @@
 
 package opennlp.tools.coref.sim;
 
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
@@ -67,7 +68,7 @@ public class Context extends Mention {
     List<Parse> tokenList = head.getTokens();
     headTokenIndex = headFinder.getHeadIndex(head);
     Parse headToken = headFinder.getHeadToken(head);
-    tokens = tokenList.toArray(new Parse[tokenList.size()]);
+    tokens = tokenList.toArray(new Parse[0]);
     this.headTokenTag = headToken.getSyntacticType();
     this.headTokenText = headToken.toString();
     if (headTokenTag.startsWith("NN") && !headTokenTag.startsWith("NNP")) {
@@ -135,9 +136,7 @@ public class Context extends Mention {
       if (senseKey != null) {
         synsetSet.add(senseKey);
         String[] synsets = dict.getParentSenseKeys(lemma, "NN", 0);
-        for (String synset : synsets) {
-          synsetSet.add(synset);
-        }
+        synsetSet.addAll(Arrays.asList(synsets));
       }
     }
     return synsetSet;
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/GenderModel.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/GenderModel.java
index 39f3a61..ac86dd4 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/GenderModel.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/GenderModel.java
@@ -129,7 +129,7 @@ public class GenderModel implements TestGenderModel, 
TrainSimilarityModel {
 
   private void addEvent(String outcome, Context np1) {
     List<String> feats = getFeatures(np1);
-    events.add(new Event(outcome, feats.toArray(new String[feats.size()])));
+    events.add(new Event(outcome, feats.toArray(new String[0])));
   }
 
   /**
@@ -245,7 +245,7 @@ public class GenderModel implements TestGenderModel, 
TrainSimilarityModel {
   public double[] genderDistribution(Context np1) {
     List<String> features = getFeatures(np1);
     //System.err.println("GenderModel.genderDistribution: "+features);
-    return testModel.eval(features.toArray(new String[features.size()]));
+    return testModel.eval(features.toArray(new String[0]));
   }
 
   @Override
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/NumberModel.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/NumberModel.java
index d305e8e..7c98e1c 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/NumberModel.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/NumberModel.java
@@ -87,7 +87,7 @@ public class NumberModel implements TestNumberModel, 
TrainSimilarityModel {
 
   private void addEvent(String outcome, Context np1) {
     List<String> feats = getFeatures(np1);
-    events.add(new Event(outcome, feats.toArray(new String[feats.size()])));
+    events.add(new Event(outcome, feats.toArray(new String[0])));
   }
 
   public NumberEnum getNumber(Context ec) {
@@ -158,7 +158,7 @@ public class NumberModel implements TestNumberModel, 
TrainSimilarityModel {
   @Override
   public double[] numberDist(Context c) {
     List<String> feats = getFeatures(c);
-    return testModel.eval(feats.toArray(new String[feats.size()]));
+    return testModel.eval(feats.toArray(new String[0]));
   }
 
   @Override
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/SimilarityModel.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/SimilarityModel.java
index ce5ae5d..34b8472 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/SimilarityModel.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/SimilarityModel.java
@@ -84,13 +84,13 @@ public class SimilarityModel implements 
TestSimilarityModel, TrainSimilarityMode
       List<String> feats = getFeatures(np1, np2);
       //System.err.println(SAME+" "+np1.headTokenText+" ("+np1.id+") -> 
"+np2.headTokenText+"
       // ("+np2.id+") "+feats);
-      events.add(new Event(SAME, feats.toArray(new String[feats.size()])));
+      events.add(new Event(SAME, feats.toArray(new String[0])));
     }
     else {
       List<String> feats = getFeatures(np1, np2);
       //System.err.println(DIFF+" "+np1.headTokenText+" ("+np1.id+") -> 
"+np2.headTokenText+"
       // ("+np2.id+") "+feats);
-      events.add(new Event(DIFF, feats.toArray(new String[feats.size()])));
+      events.add(new Event(DIFF, feats.toArray(new String[0])));
     }
   }
 
@@ -346,7 +346,7 @@ public class SimilarityModel implements 
TestSimilarityModel, TrainSimilarityMode
   public double compatible(Context mention1, Context mention2) {
     List<String> feats = getFeatures(mention1, mention2);
     if (debugOn) System.err.println("SimilarityModel.compatible: feats=" + 
feats);
-    return (testModel.eval(feats.toArray(new 
String[feats.size()]))[SAME_INDEX]);
+    return (testModel.eval(feats.toArray(new String[0]))[SAME_INDEX]);
   }
 
   /**
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/formats/muc/Muc6FullParseCorefSampleStreamFactory.java
 
b/opennlp-coref/src/main/java/opennlp/tools/formats/muc/Muc6FullParseCorefSampleStreamFactory.java
index bb78e8c..b83c522 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/formats/muc/Muc6FullParseCorefSampleStreamFactory.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/formats/muc/Muc6FullParseCorefSampleStreamFactory.java
@@ -85,12 +85,7 @@ public class Muc6FullParseCorefSampleStreamFactory extends 
AbstractSampleStreamF
     Tokenizer tokenizer = new TokenizerME(tokenizerModel);
     
     ObjectStream<String> mucDocStream = new FileToStringSampleStream(
-        new DirectorySampleStream(params.getData(), new FileFilter() {
-          @Override
-          public boolean accept(File file) {
-            return file.getName().toLowerCase().endsWith(".sgm");
-          }
-        }, false), StandardCharsets.UTF_8);
+        new DirectorySampleStream(params.getData(), file -> 
file.getName().toLowerCase().endsWith(".sgm"), false), StandardCharsets.UTF_8);
     
     ObjectStream<RawCorefSample> rawSamples = new 
MucCorefSampleStream(tokenizer, mucDocStream);
     
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/formats/muc/MucCorefContentHandler.java
 
b/opennlp-coref/src/main/java/opennlp/tools/formats/muc/MucCorefContentHandler.java
index 83d81b1..798d319 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/formats/muc/MucCorefContentHandler.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/formats/muc/MucCorefContentHandler.java
@@ -147,8 +147,8 @@ class MucCorefContentHandler extends 
SgmlParser.ContentHandler {
     
     if (MucElementNames.CONTENT_ELEMENTS.contains(name)) {
       
-      sample.getTexts().add(text.toArray(new String[text.size()]));
-      sample.getMentions().add(mentions.toArray(new 
CorefMention[mentions.size()]));
+      sample.getTexts().add(text.toArray(new String[0]));
+      sample.getMentions().add(mentions.toArray(new CorefMention[0]));
       
       mentions.clear();
       text.clear();
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/lang/english/TreebankLinker.java 
b/opennlp-coref/src/main/java/opennlp/tools/lang/english/TreebankLinker.java
index 76d6516..adbaa17 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/lang/english/TreebankLinker.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/lang/english/TreebankLinker.java
@@ -99,7 +99,7 @@ public class TreebankLinker extends DefaultLinker {
     for (String line = in.readLine();null != line;line = in.readLine()) {
       if (line.equals("")) {
         DiscourseEntity[] entities =
-            treebankLinker.getEntities(document.toArray(new 
Mention[document.size()]));
+            treebankLinker.getEntities(document.toArray(new Mention[0]));
         //showEntities(entities);
         new CorefParse(parses,entities).show();
         sentenceNumber = 0;
@@ -127,7 +127,7 @@ public class TreebankLinker extends DefaultLinker {
       }
     }
     if (document.size() > 0) {
-      DiscourseEntity[] entities = 
treebankLinker.getEntities(document.toArray(new Mention[document.size()]));
+      DiscourseEntity[] entities = 
treebankLinker.getEntities(document.toArray(new Mention[0]));
       //showEntities(entities);
       (new CorefParse(parses, entities)).show();
     }
diff --git a/opennlp-dl/src/main/java/opennlp/tools/dl/NameFinderDL.java 
b/opennlp-dl/src/main/java/opennlp/tools/dl/NameFinderDL.java
index 8a0dc81..c5475b0 100644
--- a/opennlp-dl/src/main/java/opennlp/tools/dl/NameFinderDL.java
+++ b/opennlp-dl/src/main/java/opennlp/tools/dl/NameFinderDL.java
@@ -186,7 +186,7 @@ public class NameFinderDL implements TokenNameFinder {
     for (int i = 0; i < epochs; i++) {
       net.fit(train);
       train.reset();
-      System.out.println(String.format("Finished epoch %d", i));
+      System.out.printf("Finished epoch %d%n", i);
     }
 
     return net;
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/apps/object_dedup/SimilarityAccessorBase.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/apps/object_dedup/SimilarityAccessorBase.java
index 16d9637..a69ba08 100755
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/apps/object_dedup/SimilarityAccessorBase.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/apps/object_dedup/SimilarityAccessorBase.java
@@ -506,7 +506,7 @@ public class SimilarityAccessorBase {
                List<String> name1Tokens = 
removeVenuePart(TextProcessor.fastTokenize(name1.toLowerCase(), true));
                List<String> name2Tokens = 
removeVenuePart(TextProcessor.fastTokenize(name2.toLowerCase(), true));
                // applySubPhraseExtractionRule()
-               Boolean bSameAttrib = verifyEventAttributesPost(name1Tokens, 
name2Tokens)
+               boolean bSameAttrib = verifyEventAttributesPost(name1Tokens, 
name2Tokens)
                        && verifyEventAttributesPre(name1Tokens, name2Tokens);
                if (!bSameAttrib)
                {
@@ -668,7 +668,7 @@ public class SimilarityAccessorBase {
 
                List<String> name1Tokens = 
TextProcessor.fastTokenize(name1.toLowerCase(), true);
                List<String> name2Tokens = 
TextProcessor.fastTokenize(name2.toLowerCase(), true);
-               Boolean bSameAttrib = verifyEventAttributesPost(name1Tokens, 
name2Tokens)
+               boolean bSameAttrib = verifyEventAttributesPost(name1Tokens, 
name2Tokens)
                        && verifyEventAttributesPre(name1Tokens, name2Tokens);
                if (!bSameAttrib)
                {
@@ -709,7 +709,7 @@ public class SimilarityAccessorBase {
                        }
                }
 
-               Boolean bothSidesSuccess = applyBothSidesRule(name1, name2);
+               boolean bothSidesSuccess = applyBothSidesRule(name1, name2);
                if (!bothSidesSuccess)
                {
                        score = 1;
@@ -717,7 +717,7 @@ public class SimilarityAccessorBase {
                }
                if (score > 0)
                {
-                       Boolean bDifferentGroup = 
bDifferentGroupOneSubnameOfAnother(name1, name2);
+                       boolean bDifferentGroup = 
bDifferentGroupOneSubnameOfAnother(name1, name2);
                        if (bDifferentGroup)
                        {
                                score = 1;
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/apps/relevanceVocabs/PhraseProcessor.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/apps/relevanceVocabs/PhraseProcessor.java
index df48cce..8b00ff9 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/apps/relevanceVocabs/PhraseProcessor.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/apps/relevanceVocabs/PhraseProcessor.java
@@ -128,7 +128,7 @@ public class PhraseProcessor {
                List<ParseTreeChunk> nPhrases = groupedChunks.get(0);
 
                for (ParseTreeChunk ch : nPhrases) {
-                       String query = "";
+                       StringBuilder query = new StringBuilder();
                        int size = ch.getLemmas().size();
                        boolean phraseBeingFormed = false;
                        for (int i = 0; i < size; i++) {
@@ -136,7 +136,7 @@ public class PhraseProcessor {
                                                .startsWith("J") || 
ch.getPOSs().get(i).startsWith("CD") ) )
                                //              && 
StringUtils.isAlpha(ch.getLemmas().get(i)))
                                {
-                                       query += ch.getLemmas().get(i) + " ";
+                                       
query.append(ch.getLemmas().get(i)).append(" ");
                                        phraseBeingFormed = true;
                                } else
                                        if 
((ch.getPOSs().get(i).startsWith("PR") || ch.getPOSs().get(i).startsWith("IN") 
|| ch.getPOSs().get(i).startsWith("TO")  )
@@ -145,8 +145,8 @@ public class PhraseProcessor {
                                        else if 
(ch.getPOSs().get(i).startsWith("DT") || ch.getPOSs().get(i).startsWith("CC"))
                                        continue;
                        }
-                       query = query.trim();
-                       int len = query.split(" ").length;
+                       query = new StringBuilder(query.toString().trim());
+                       int len = query.toString().split(" ").length;
                        if (len > 5 || len < 2) // too long or too short
                                continue;
 
@@ -167,8 +167,8 @@ public class PhraseProcessor {
                         // individual word, possibly a frequent word
                        // if len==1 do nothing
 
-                       query = query.trim();
-                       queryArrayStr.add(query);
+                       query = new StringBuilder(query.toString().trim());
+                       queryArrayStr.add(query.toString());
 
                        }
                        /*
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/apps/review_builder/MachineTranslationWrapper.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/apps/review_builder/MachineTranslationWrapper.java
index a1ef482..945b96d 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/apps/review_builder/MachineTranslationWrapper.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/apps/review_builder/MachineTranslationWrapper.java
@@ -42,15 +42,15 @@ public class MachineTranslationWrapper  {
                        URLConnection connection = urlC.openConnection();
 
                        String line;
-                       String result = "";
+                       StringBuilder result = new StringBuilder();
                        BufferedReader reader = new BufferedReader(new 
InputStreamReader(connection.getInputStream()));
                        int count = 0;
                        while ((line = reader.readLine()) != null)
                        {
-                               result+=line;
+                               result.append(line);
                                count++;
                        }
-                       JSONObject rootObject = new JSONObject(result);
+                       JSONObject rootObject = new 
JSONObject(result.toString());
                        JSONObject  findObject = 
rootObject.getJSONObject("responseData");
                        String transl = findObject.getString("translatedText");
                        try {
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/doc_classifier/DocClassifierTrainingSetVerifier.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/doc_classifier/DocClassifierTrainingSetVerifier.java
index 8b29bc9..4da160a 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/doc_classifier/DocClassifierTrainingSetVerifier.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/doc_classifier/DocClassifierTrainingSetVerifier.java
@@ -97,7 +97,7 @@ public class DocClassifierTrainingSetVerifier {
 
                                //classifier.runExpressionsOnContent(content);
                                List<String> resultsClassif = 
classifier.getEntityOrClassFromText(content);
-                               Boolean bRejected = true;
+                               boolean bRejected = true;
                                if (resultsClassif.size()==1 
                                                && resultsClassif.get(0).equals(
                                                                
ClassifierTrainingSetIndexer.getCategoryFromFilePath(f.getAbsolutePath()))){
@@ -114,7 +114,7 @@ public class DocClassifierTrainingSetVerifier {
                                        fragment = content.substring(0, 
FRAGMENT_LENGTH);
                                fragment = fragment.replaceAll("\n", " 
").trim();
                                report.add(new String[] { f.getName(),  
resultsClassif.toString(), 
ClassifierTrainingSetIndexer.getCategoryFromFilePath(f.getAbsolutePath()),
-                                               (bRejected).toString(),   
+                                                               
Boolean.toString((bRejected)),
                                                fragment});
                                ProfileReaderWriter.writeReport(report,  
"DocClassifierMultiLingRpt.csv");
 
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/jsmlearning/FeatureSpaceCoverageProcessor.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/jsmlearning/FeatureSpaceCoverageProcessor.java
index 87bc3c8..c809466 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/jsmlearning/FeatureSpaceCoverageProcessor.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/jsmlearning/FeatureSpaceCoverageProcessor.java
@@ -61,12 +61,12 @@ public class FeatureSpaceCoverageProcessor {
                try {
                        int p3 = paramMap.get("Latitude");      
                        int p4 = paramMap.get("Longitude");
-                       Double latDiff = Math.abs(Double.parseDouble(seed[p3]) 
- Double.parseDouble(candidate[p3]));
-                       Double longDiff = Math.abs(Double.parseDouble(seed[p4]) 
- Double.parseDouble(candidate[p4]));
+                       double latDiff = Math.abs(Double.parseDouble(seed[p3]) 
- Double.parseDouble(candidate[p3]));
+                       double longDiff = Math.abs(Double.parseDouble(seed[p4]) 
- Double.parseDouble(candidate[p4]));
                        if (latDiff>1 || longDiff>1)
                                return 1000000f;
                        else 
-                               score+= latDiff.floatValue()/100.0f + 
longDiff.floatValue()/100.0f;
+                               score+= (float) latDiff /100.0f + (float) 
longDiff /100.0f;
                } catch (Exception e) {
                        return 1000000f;
                }
@@ -106,10 +106,10 @@ public class FeatureSpaceCoverageProcessor {
                                if (seed[p3][v].equals("") || 
seed[p4][v].equals("") 
                                                || candidate[p3].equals("") ||  
candidate[p4].equals(""))
                                        continue;
-                               Double latDiff = 
Math.abs(Double.parseDouble(seed[p3][v]) - Double.parseDouble(candidate[p3]));
-                               Double longDiff = 
Math.abs(Double.parseDouble(seed[p4][v]) - Double.parseDouble(candidate[p4]));
+                               double latDiff = 
Math.abs(Double.parseDouble(seed[p3][v]) - Double.parseDouble(candidate[p3]));
+                               double longDiff = 
Math.abs(Double.parseDouble(seed[p4][v]) - Double.parseDouble(candidate[p4]));
                                if (!(latDiff>1 || longDiff>1))
-                                       currLatLongScore = 
latDiff.floatValue()/100.0f + longDiff.floatValue()/100.0f;
+                                       currLatLongScore = (float) latDiff 
/100.0f + (float) longDiff /100.0f;
                        } catch (Exception e) {
                                //return 1000000f;
                        }
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/jsmlearning/JSMLearnerOnLatticeWithDeduction.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/jsmlearning/JSMLearnerOnLatticeWithDeduction.java
index 82efd06..03e8b1e 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/jsmlearning/JSMLearnerOnLatticeWithDeduction.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/jsmlearning/JSMLearnerOnLatticeWithDeduction.java
@@ -177,7 +177,7 @@ public class JSMLearnerOnLatticeWithDeduction extends 
JSMLearnerOnLatticeBase{
        public Pair<List<String>, List<String>>  
reGroupByOccurrenceOfSeparationKeyword(List<String> posTexts, List<String> 
negTexts, String[] keywords){
                List<String> posTextsNew = new ArrayList<>(), negTextsNew = new 
ArrayList<>();
                for(String posText:posTexts){
-                       Boolean multiwordOccurs = true;
+                       boolean multiwordOccurs = true;
                        for(String keyword: keywords){
                                if (!posText.contains(keyword))
                                        multiwordOccurs = false;
@@ -189,7 +189,7 @@ public class JSMLearnerOnLatticeWithDeduction extends 
JSMLearnerOnLatticeBase{
                                negTextsNew.add(posText);
                }
                for(String negText:negTexts){
-                       Boolean multiwordOccurs = true;
+                       boolean multiwordOccurs = true;
                        for(String keyword: keywords){
                                if (!negText.contains(keyword))
                                        multiwordOccurs = false;
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/jsmlearning/ProfileReaderWriter.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/jsmlearning/ProfileReaderWriter.java
index c509552..8453d7e 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/jsmlearning/ProfileReaderWriter.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/jsmlearning/ProfileReaderWriter.java
@@ -16,7 +16,6 @@
  */
 package opennlp.tools.jsmlearning;
 
-import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.PrintWriter;
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/Pair.java 
b/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/Pair.java
index c19f617..a1ab0ca 100644
--- a/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/Pair.java
+++ b/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/Pair.java
@@ -63,8 +63,7 @@ public class Pair<T1, T2> {
       int b = -2;
       if ( o1.second instanceof Float && o2.second instanceof Float){
         
-        b =  (((Float)o1.second > (Float)o2.second) ? -1
-          : (((Float)o1.second == (Float)o2.second) ? 0 : 1));
+        b =  (((Float) o2.second).compareTo((Float) o1.second));
       }
       return b;
     }
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/ParseTreeNode.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/ParseTreeNode.java
index 122692d..a2cb6af 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/ParseTreeNode.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/ParseTreeNode.java
@@ -176,11 +176,11 @@ public class ParseTreeNode implements 
IGeneralizer<ParseTreeNode>{
                return buf.toString().trim();
        }
        public static String toWordString(List<ParseTreeNode> chList){
-               String buf = "";
+               StringBuilder buf = new StringBuilder();
                for(ParseTreeNode ch: chList){
-                       buf+=ch.getWord()+ " ";
+                       buf.append(ch.getWord()).append(" ");
                }
-               return buf.trim();
+               return buf.toString().trim();
        }
 
        @Override
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/matching/NERPhraseGeneralizer.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/matching/NERPhraseGeneralizer.java
index ca7a799..0d6b2ad 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/matching/NERPhraseGeneralizer.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/matching/NERPhraseGeneralizer.java
@@ -141,7 +141,7 @@ public class NERPhraseGeneralizer extends PhraseGeneralizer 
{
                        List<String> commonPOS = new ArrayList<>(), 
commonLemmas = new ArrayList<>();
                        // we start two words before first word
                        int k1 = occr1.get(ov1) - 2, k2 = occr2.get(ov2) - 2;
-                       Boolean bReachedCommonWord = false;
+                       boolean bReachedCommonWord = false;
                        while (k1 < 0 || k2 < 0) {
                                k1++;
                                k2++;
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/matching/PhraseGeneralizer.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/matching/PhraseGeneralizer.java
index f2c7df1..02455a5 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/matching/PhraseGeneralizer.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/parse_thicket/matching/PhraseGeneralizer.java
@@ -156,7 +156,7 @@ public class PhraseGeneralizer implements 
IGeneralizer<ParseTreeChunk> {
                        // we start two words before first word
                        int k1 = occr1.get(ov1) - 2, k2 = occr2.get(ov2) - 2;
                        // if (k1<0) k1=0; if (k2<0) k2=0;
-                       Boolean bReachedCommonWord = false;
+                       boolean bReachedCommonWord = false;
                        while (k1 < 0 || k2 < 0) {
                                k1++;
                                k2++;
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/HitBase.java 
b/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/HitBase.java
index 2da1c05..5b1dfdd 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/HitBase.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/HitBase.java
@@ -166,7 +166,7 @@ public class HitBase {
 
        public static String toString(List<HitBase> hits) {
                StringBuilder buf = new StringBuilder();
-               Boolean pBreak = true;
+               boolean pBreak = true;
                for (HitBase hit : hits) {
                        String fragm = (hit.toString());
                        if (fragm.length() > 15) {
@@ -187,7 +187,7 @@ public class HitBase {
 
        public static String toResultantString(List<HitBase> hits) {
                StringBuilder buf = new StringBuilder();
-               Boolean pBreak = true;
+               boolean pBreak = true;
                for (HitBase hit : hits) {
                        try {
                                if (hit.getFragments()==null)   
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/solr/IterativeSearchRequestHandler.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/solr/IterativeSearchRequestHandler.java
index 6391d25..51f838f 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/solr/IterativeSearchRequestHandler.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/solr/IterativeSearchRequestHandler.java
@@ -330,8 +330,7 @@ public class IterativeSearchRequestHandler extends 
SearchHandler {
                        int b = -2;
                        if ( o1.getSecond() instanceof Float && o2.getSecond() 
instanceof Float){
 
-                               b =  (((Float)o1.getSecond()> 
(Float)o2.getSecond()) ? -1
-                                               : (((Float)o1.getSecond() == 
(Float)o2.getSecond()) ? 0 : 1));
+                               b =  (((Float) 
o2.getSecond()).compareTo((Float) o1.getSecond()));
                        }
                        return b;
                }
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/solr/SearchResultsReRankerRequestHandler.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/solr/SearchResultsReRankerRequestHandler.java
index 608731e..3e77f43 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/solr/SearchResultsReRankerRequestHandler.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/solr/SearchResultsReRankerRequestHandler.java
@@ -70,7 +70,7 @@ public class SearchResultsReRankerRequestHandler extends 
SearchHandler {
 
 
 
-               for (Integer i=0; i< MAX_SEARCH_RESULTS; i++){
+               for (int i = 0; i< MAX_SEARCH_RESULTS; i++){
                        String title = req.getParams().get("t"+i);
                        String descr = req.getParams().get("d"+i);
 
@@ -80,7 +80,7 @@ public class SearchResultsReRankerRequestHandler extends 
SearchHandler {
                        HitBase hit = new HitBase();
                        hit.setTitle(title);
                        hit.setAbstractText(descr);
-                       hit.setSource(i.toString());
+                       hit.setSource(Integer.toString(i));
                        searchResults.add(hit);
                }
 
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/utils/StringDistanceMeasurer.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/utils/StringDistanceMeasurer.java
index 4f2e17f..8424dab 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/utils/StringDistanceMeasurer.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/utils/StringDistanceMeasurer.java
@@ -46,7 +46,7 @@ public class StringDistanceMeasurer {
   protected List<String> filterWordArray(String[] strWords) {
     List<String> strList = new ArrayList<>();
     for (String w : strWords) {
-      Boolean bInteger = true;
+      boolean bInteger = true;
       try {
         Integer.parseInt(w);
       } catch (Exception e) {
@@ -72,7 +72,7 @@ public class StringDistanceMeasurer {
   protected List<String> filterWordArrayNoStem(String[] strWords) {
     List<String> strList = new ArrayList<>();
     for (String w : strWords) {
-      Boolean bInteger = true;
+      boolean bInteger = true;
       try {
         Integer.parseInt(w);
       } catch (Exception e) {
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/ParseTreeChunk.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/ParseTreeChunk.java
index e428d4e..409172b 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/ParseTreeChunk.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/ParseTreeChunk.java
@@ -291,7 +291,7 @@ public class ParseTreeChunk implements Serializable {
                                                continue; // if the words which 
have to stay do not stay, proceed to
                                                // other elements
                                        }
-                                       Boolean alreadyThere = false;
+                                       boolean alreadyThere = false;
                                        for (ParseTreeChunk chunk : 
resultComps) {
                                                if (chunk.equalsTo(chunkToAdd)) 
{
                                                        alreadyThere = true;
@@ -361,7 +361,7 @@ public class ParseTreeChunk implements Serializable {
                if (this.lemmas.size() < lems.size())
                        return false; // sub-chunk should be shorter than chunk
 
-               Boolean notSubChunkWithGivenAlignment = false, unComparable = 
false;
+               boolean notSubChunkWithGivenAlignment = false, unComparable = 
false;
                
                for (int i = 0; i < lems.size() && i < this.lemmas.size(); i++) 
{
                        // both lemma and pos are different
@@ -427,31 +427,31 @@ public class ParseTreeChunk implements Serializable {
        }
 
        public String toString() {
-               String buf = " [";
+               StringBuilder buf = new StringBuilder(" [");
                if (mainPOS != null)
-                       buf = mainPOS + " [";
+                       buf = new StringBuilder(mainPOS + " [");
                for (int i = 0; i < lemmas.size() && i < POSs.size() ; i++) {
-                       buf += POSs.get(i) + "-" + lemmas.get(i) + " ";
+                       
buf.append(POSs.get(i)).append("-").append(lemmas.get(i)).append(" ");
                        if (this.parseTreeNodes!=null){
                                Map<String, Object> attrs = 
this.parseTreeNodes.get(i).getAttributes();
                                if (attrs!=null && attrs.keySet().size()>0){
-                                       buf += attrs+ " ";
+                                       buf.append(attrs).append(" ");
                                }
                                String ner =this.parseTreeNodes.get(i).getNe();
                                if (ner!=null && ner.length()>1)
-                                       buf+="("+ner+ ") ";
+                                       buf.append("(").append(ner).append(") 
");
                        }
                }
                return buf + "]";
        }
        
        public String toWordOnlyString(){
-               String buf = "";
+               StringBuilder buf = new StringBuilder();
 
                for (String lemma : lemmas) {
-                       buf += lemma + " ";
+                       buf.append(lemma).append(" ");
                }
-               return buf.trim();
+               return buf.toString().trim();
        }
 
        public int compareTo(ParseTreeChunk o) {
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/ParseTreeMatcher.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/ParseTreeMatcher.java
index 6b81309..00dae10 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/ParseTreeMatcher.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/ParseTreeMatcher.java
@@ -41,7 +41,7 @@ public class ParseTreeMatcher {
 
     List<String> commonPOS = new ArrayList<>(), commonLemmas = new 
ArrayList<>();
     int k1 = 0, k2 = 0;
-    Boolean incrFirst = true;
+    boolean incrFirst = true;
     while (k1 < pos1.size() && k2 < pos2.size()) {
       // first check if the same POS
       String sim = posManager.similarPOS(pos1.get(k1), pos2.get(k2));
@@ -140,13 +140,13 @@ public class ParseTreeMatcher {
     // Double> ();
     int timesRepetitiveRun = NUMBER_OF_ITERATIONS;
 
-    Double globalScore = -1.0;
+    double globalScore = -1.0;
     ParseTreeChunk result = null;
 
     for (int timesRun = 0; timesRun < timesRepetitiveRun; timesRun++) {
       List<String> commonPOS = new ArrayList<>(), commonLemmas = new 
ArrayList<>();
       int k1 = 0, k2 = 0;
-      Double score;
+      double score;
       while (k1 < pos1.size() && k2 < pos2.size()) {
         // first check if the same POS
         String sim = posManager.similarPOS(pos1.get(k1), pos2.get(k2));
@@ -191,7 +191,7 @@ public class ParseTreeMatcher {
     for (int timesRun = 0; timesRun < timesRepetitiveRun; timesRun++) {
       List<String> commonPOS = new ArrayList<>(), commonLemmas = new 
ArrayList<>();
       int k1 = pos1.size() - 1, k2 = pos2.size() - 1;
-      Double score;
+      double score;
       while (k1 >= 0 && k2 >= 0) {
         // first check if the same POS
         String sim = posManager.similarPOS(pos1.get(k1), pos2.get(k2));
diff --git 
a/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/TextProcessor.java
 
b/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/TextProcessor.java
index 75d707e..55cbf04 100644
--- 
a/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/TextProcessor.java
+++ 
b/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/TextProcessor.java
@@ -215,26 +215,26 @@ public class TextProcessor {
       Pattern p = Pattern.compile(s, Pattern.MULTILINE);
       Matcher m = p.matcher(text);
       int idx = 0;
-      String cand = "";
+      StringBuilder cand = new StringBuilder();
 
       // while(m.find()){
       // System.out.println(m.group());
       // }
 
       while (m.find()) {
-        cand += " " + text.substring(idx, m.end() - 1).trim();
+        cand.append(" ").append(text.substring(idx, m.end() - 1).trim());
         boolean hasAbbrev = false;
 
         for (String abbrev : ABBREVS) {
-          if (cand.toLowerCase().endsWith(abbrev)) {
+          if (cand.toString().toLowerCase().endsWith(abbrev)) {
             hasAbbrev = true;
             break;
           }
         }
 
         if (!hasAbbrev) {
-          sentences.add(cand.trim());
-          cand = "";
+          sentences.add(cand.toString().trim());
+          cand = new StringBuilder();
         }
         idx = m.end() - 1;
       }
@@ -583,12 +583,12 @@ public class TextProcessor {
     }
 
     // now we have histogram, lets write it out
-    String hashString = "";
+    StringBuilder hashString = new StringBuilder();
     Enumeration<String> en = tokenHash.keys();
     while (en.hasMoreElements()) {
       String t = en.nextElement();
       int freq = tokenHash.get(t);
-      hashString += t + freq;
+      hashString.append(t).append(freq);
     }
 
     // log.info(hashString);
@@ -602,7 +602,7 @@ public class TextProcessor {
         LOG.severe("NoSuchAlgorithmException " + e);
         throw new Exception(e.getMessage());
       }
-      md.update(hashString.getBytes(StandardCharsets.UTF_8)); // step 3
+      md.update(hashString.toString().getBytes(StandardCharsets.UTF_8)); // 
step 3
       byte[] raw = md.digest();
       hash = null; // (new BASE64Encoder()).encode(raw);
     }
@@ -636,7 +636,7 @@ public class TextProcessor {
 
   public static String generateSummary(String txt, String title, int numChars,
       boolean truncateInSentence) {
-    String finalSummary;
+    StringBuilder finalSummary;
 
     try {
 
@@ -677,39 +677,39 @@ public class TextProcessor {
         }
       }
 
-      finalSummary = sum.toString().trim();
+      finalSummary = new StringBuilder(sum.toString().trim());
 
       if (truncateInSentence) {
-        finalSummary = truncateTextOnSpace(finalSummary, numChars);
-        int numPeriods = countTrailingPeriods(finalSummary);
+        finalSummary = new 
StringBuilder(truncateTextOnSpace(finalSummary.toString(), numChars));
+        int numPeriods = countTrailingPeriods(finalSummary.toString());
 
         if (numPeriods < 3 && finalSummary.length() > 0) {
           for (int i = 0; i < 3 - numPeriods; i++) {
-            finalSummary += ".";
+            finalSummary.append(".");
           }
         }
       } else {
         // trim final period
-        if (finalSummary.endsWith("..")) {
-          finalSummary = finalSummary.substring(0, finalSummary.length() - 2);
+        if (finalSummary.toString().endsWith("..")) {
+          finalSummary = new StringBuilder(finalSummary.substring(0, 
finalSummary.length() - 2));
         }
       }
       // check to see if we have anything, if not, return the full content
-      if (finalSummary.trim().length() < 5) {
-        finalSummary = txt;
+      if (finalSummary.toString().trim().length() < 5) {
+        finalSummary = new StringBuilder(txt);
       }
       // see if we have a punctuation character in the first 30 chars
       int highestIdx = -1;
       int sIdx = Math.min(finalSummary.length() - 1, 45);
       for (String p : puncChars) {
-        int idx = finalSummary.trim().substring(0, sIdx).lastIndexOf(p);
+        int idx = finalSummary.toString().trim().substring(0, 
sIdx).lastIndexOf(p);
         if (idx > highestIdx && idx < 45) {
           highestIdx = idx + p.length();
         }
       }
 
       if (highestIdx > -1) {
-        finalSummary = finalSummary.substring(highestIdx);
+        finalSummary = new StringBuilder(finalSummary.substring(highestIdx));
       }
 
       int closeParenIdx = finalSummary.indexOf(")");
@@ -717,23 +717,23 @@ public class TextProcessor {
       // if(closeParenIdx < )
       if (closeParenIdx != -1 && closeParenIdx < 15
           && (openParenIdx == -1 || openParenIdx > closeParenIdx)) {
-        finalSummary = finalSummary.substring(closeParenIdx + 1).trim();
+        finalSummary = new StringBuilder(finalSummary.substring(closeParenIdx 
+ 1).trim());
       }
 
-      finalSummary = trimPunctuationFromStart(finalSummary);
+      finalSummary = new 
StringBuilder(trimPunctuationFromStart(finalSummary.toString()));
 
       // check to see if we have anything, if not, return the full content
-      if (finalSummary.trim().length() < 5) {
-        finalSummary = txt;
+      if (finalSummary.toString().trim().length() < 5) {
+        finalSummary = new StringBuilder(txt);
       }
 
     } catch (Exception e) {
       LOG.severe("Problem forming summary for: " + txt);
       LOG.severe("Using full text for the summary" + e);
-      finalSummary = txt;
+      finalSummary = new StringBuilder(txt);
     }
 
-    return finalSummary.trim();
+    return finalSummary.toString().trim();
   }
 
   public static String truncateTextOnSpace(String txt, int numChars) {
diff --git 
a/opennlp-similarity/src/test/java/opennlp/tools/parse_thicket/pattern_structure/PhraseTest.java
 
b/opennlp-similarity/src/test/java/opennlp/tools/parse_thicket/pattern_structure/PhraseTest.java
index 8a86aa7..9d7eb0f 100755
--- 
a/opennlp-similarity/src/test/java/opennlp/tools/parse_thicket/pattern_structure/PhraseTest.java
+++ 
b/opennlp-similarity/src/test/java/opennlp/tools/parse_thicket/pattern_structure/PhraseTest.java
@@ -138,7 +138,7 @@ public class PhraseTest {
                                                                
.getAbstractText();
                                        
                                        LinkedHashSet<Integer> obj = null;
-                                       obj = new LinkedHashSet<Integer>();
+                                       obj = new LinkedHashSet<>();
                                        obj.add(i);
                                        chunks = 
chunk_maker.formGroupedPhrasesFromChunksForPara(text_result);
                                        ps.AddIntent(chunks,obj, 0);
diff --git 
a/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/SyntMatcherTest.java
 
b/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/SyntMatcherTest.java
index f9bcd7e..0e0def8 100644
--- 
a/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/SyntMatcherTest.java
+++ 
b/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/SyntMatcherTest.java
@@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test;
 import 
opennlp.tools.textsimilarity.chunker2matcher.ParserChunker2MatcherProcessor;
 
 import static org.junit.jupiter.api.Assertions.*;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 class SyntMatcherTest {
 
diff --git 
a/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/chunker2matcher/PhraseNodeTest.java
 
b/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/chunker2matcher/PhraseNodeTest.java
index 94b5a0d..b24c988 100644
--- 
a/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/chunker2matcher/PhraseNodeTest.java
+++ 
b/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/chunker2matcher/PhraseNodeTest.java
@@ -23,6 +23,7 @@ import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 class PhraseNodeTest {
 
@@ -53,7 +54,7 @@ class PhraseNodeTest {
       pOSlist = node.getOrderedPOSList();
       assertEquals("[WRB, VBP, PRP]", pOSlist.toString());
     } catch (Exception e) { // for run without models, where init fails
-      assertEquals(node, null);
+      assertNull(node);
     }
   }
 
diff --git a/opennlp-similarity/src/test/resources/sentence_parseObject.csv 
b/opennlp-similarity/src/test/resources/sentence_parseObject.csv
index c11ec1d..6d2d5dd 100644
--- a/opennlp-similarity/src/test/resources/sentence_parseObject.csv
+++ b/opennlp-similarity/src/test/resources/sentence_parseObject.csv
@@ -1337,4 +1337,4 @@
 "My rental profits are added to my taxable income.  "
 "B-NP","I-NP","I-NP","B-VP","I-VP","B-PP","B-NP","I-NP","I-NP"
 "PRP$","JJ","NNS","VBP","VBN","TO","PRP$","JJ","NN"
-"My","rental","profits","are","added","to","my","taxable","income"
+"My","rental","profits","are","added","to","my","taxable","income"
\ No newline at end of file
diff --git 
a/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/FeaturesExtractor.java 
b/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/FeaturesExtractor.java
index 9d202a2..d18d2e5 100644
--- 
a/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/FeaturesExtractor.java
+++ 
b/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/FeaturesExtractor.java
@@ -95,7 +95,7 @@ public class FeaturesExtractor {
       }
     }
 
-    return contextWords.toArray(new String[contextWords.size()]);
+    return contextWords.toArray(new String[0]);
   }
 
   private String[] extractLocalCollocations(WTDIMS wordToDisambiguate, int 
ngram) {
diff --git 
a/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDContextGenerator.java
 
b/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDContextGenerator.java
index 11d8f9e..79ddb6c 100644
--- 
a/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDContextGenerator.java
+++ 
b/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDContextGenerator.java
@@ -66,7 +66,7 @@ public class IMSWSDContextGenerator implements 
WSDContextGenerator {
       }
     }
 
-    return contextWords.toArray(new String[contextWords.size()]);
+    return contextWords.toArray(new String[0]);
   }
 
   private String[] extractLocalCollocations(int index, String[] sentence, int 
ngram) {
@@ -92,7 +92,7 @@ public class IMSWSDContextGenerator implements 
WSDContextGenerator {
 
     }
     String[] res;
-    res = localCollocations.toArray(new String[localCollocations.size()]);
+    res = localCollocations.toArray(new String[0]);
 
     return res;
   }
diff --git 
a/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/OSCCWSDContextGenerator.java
 
b/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/OSCCWSDContextGenerator.java
index 6e13523..b4e66a7 100644
--- 
a/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/OSCCWSDContextGenerator.java
+++ 
b/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/OSCCWSDContextGenerator.java
@@ -69,7 +69,7 @@ public class OSCCWSDContextGenerator implements 
WSDContextGenerator {
       }
     }
 
-    return contextClusters.toArray(new String[contextClusters.size()]);
+    return contextClusters.toArray(new String[0]);
 
   }
 
diff --git 
a/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/datareader/Paragraph.java
 
b/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/datareader/Paragraph.java
index d02bab8..c6d1c37 100644
--- 
a/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/datareader/Paragraph.java
+++ 
b/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/datareader/Paragraph.java
@@ -65,9 +65,9 @@ public class Paragraph {
 
   @Override
   public String toString() {
-    String paragraph = "";
+    StringBuilder paragraph = new StringBuilder();
     for (Sentence isentence : this.isentences) {
-      paragraph = paragraph + " " + isentence.toString();
+      paragraph.append(" ").append(isentence.toString());
     }
     return paragraph.substring(1, paragraph.length());
 
diff --git 
a/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/datareader/Sentence.java
 
b/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/datareader/Sentence.java
index 0de162a..b31258f 100644
--- 
a/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/datareader/Sentence.java
+++ 
b/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/datareader/Sentence.java
@@ -76,9 +76,9 @@ public class Sentence {
 
   @Override
   public String toString() {
-    String sentence = "";
+    StringBuilder sentence = new StringBuilder();
     for (Word iword : this.iwords) {
-      sentence = sentence + " " + iword.toString();
+      sentence.append(" ").append(iword.toString());
     }
     return sentence.substring(1, sentence.length());
 
diff --git 
a/tagging-server/src/main/java/org/apache/opennlp/tagging_server/namefind/BratNameFinderResource.java
 
b/tagging-server/src/main/java/org/apache/opennlp/tagging_server/namefind/BratNameFinderResource.java
index 66383b0..0d1041b 100644
--- 
a/tagging-server/src/main/java/org/apache/opennlp/tagging_server/namefind/BratNameFinderResource.java
+++ 
b/tagging-server/src/main/java/org/apache/opennlp/tagging_server/namefind/BratNameFinderResource.java
@@ -139,7 +139,7 @@ public class BratNameFinderResource {
             }
 
             NameAnn ann = new NameAnn();
-            ann.texts = textSegments.toArray(new String[textSegments.size()]);
+            ann.texts = textSegments.toArray(new String[0]);
             ann.offsets = spanSegments.toArray(new int[spanSegments.size()][]);
             ann.type = name.getType();
 
diff --git 
a/tf-ner-poc/src/main/java/org/apache/opennlp/normalizer/Normalizer.java 
b/tf-ner-poc/src/main/java/org/apache/opennlp/normalizer/Normalizer.java
index fecf8aa..281a7bf 100644
--- a/tf-ner-poc/src/main/java/org/apache/opennlp/normalizer/Normalizer.java
+++ b/tf-ner-poc/src/main/java/org/apache/opennlp/normalizer/Normalizer.java
@@ -51,7 +51,7 @@ public class Normalizer {
     try(InputStream sourceCharMapIn = new FileInputStream(
         tmpModelPath.resolve("source_char_dict.txt").toFile())) {
       sourceCharMap = loadCharMap(sourceCharMapIn).entrySet().stream()
-          .collect(Collectors.toMap(Map.Entry::getValue, c -> c.getKey()));
+          .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
     }
 
     try(InputStream targetCharMapIn = new FileInputStream(
@@ -130,7 +130,7 @@ public class Normalizer {
           normalizedTexts.add(normalizedText.toString());
         }
 
-        return normalizedTexts.toArray(new String[normalizedTexts.size()]);
+        return normalizedTexts.toArray(new String[0]);
       }
     }
   }


Reply via email to