You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by ra...@apache.org on 2017/02/07 22:12:52 UTC

opennlp git commit: OPENNLP-904 change PR following comments

Repository: opennlp
Updated Branches:
  refs/heads/904 0e7c49aeb -> 177a63f10


OPENNLP-904 change PR following comments


Project: http://git-wip-us.apache.org/repos/asf/opennlp/repo
Commit: http://git-wip-us.apache.org/repos/asf/opennlp/commit/177a63f1
Tree: http://git-wip-us.apache.org/repos/asf/opennlp/tree/177a63f1
Diff: http://git-wip-us.apache.org/repos/asf/opennlp/diff/177a63f1

Branch: refs/heads/904
Commit: 177a63f10db7d2686a69bf8b6e9a5dd96a3b3cbd
Parents: 0e7c49a
Author: Rodrigo Agerri <ra...@apache.org>
Authored: Tue Feb 7 23:12:35 2017 +0100
Committer: Rodrigo Agerri <ra...@apache.org>
Committed: Tue Feb 7 23:12:35 2017 +0100

----------------------------------------------------------------------
 .../tools/lemmatizer/DictionaryLemmatizer.java      | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/opennlp/blob/177a63f1/opennlp-tools/src/main/java/opennlp/tools/lemmatizer/DictionaryLemmatizer.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/lemmatizer/DictionaryLemmatizer.java b/opennlp-tools/src/main/java/opennlp/tools/lemmatizer/DictionaryLemmatizer.java
index 260f98a..7d31119 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/lemmatizer/DictionaryLemmatizer.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/lemmatizer/DictionaryLemmatizer.java
@@ -18,7 +18,6 @@
 package opennlp.tools.lemmatizer;
 
 import java.io.BufferedReader;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
@@ -52,19 +51,14 @@ public class DictionaryLemmatizer implements Lemmatizer {
   // 1. We could get every lemma for a word,pos pair in the key
   // 2. We could get every pos,lemma for a word in the key
   // Crucially, both keys and values need to be collections, probably lists
-  public DictionaryLemmatizer(final InputStream dictionary) {
+  public DictionaryLemmatizer(final InputStream dictionary) throws java.io.IOException {
     this.dictMap = new HashMap<>();
     final BufferedReader breader = new BufferedReader(
         new InputStreamReader(dictionary));
     String line;
-    try {
-      while ((line = breader.readLine()) != null) {
-        final String[] elems = line.split("\t");
-        this.dictMap.put(Arrays.asList(elems[0], elems[1]),
-            Arrays.asList(elems[2]));
-      }
-    } catch (final IOException e) {
-      e.printStackTrace();
+    while ((line = breader.readLine()) != null) {
+      final String[] elems = line.split("\t");
+      this.dictMap.put(Arrays.asList(elems[0], elems[1]), Arrays.asList(elems[2]));
     }
   }
 
@@ -103,7 +97,7 @@ public class DictionaryLemmatizer implements Lemmatizer {
   }
 
   public List<List<String>> lemmatize(final List<String> tokens, final List<String> posTags) {
-    List<List<String>> allLemmas = new ArrayList<List<String>>();
+    List<List<String>> allLemmas = new ArrayList<>();
     for (int i = 0; i < tokens.size(); i++) {
       allLemmas.add(this.getAllLemmas(tokens.get(i), posTags.get(i)));
     }