You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by sm...@apache.org on 2017/04/20 01:52:59 UTC

opennlp git commit: NoJira: Fix the codestyle violations in NameSampleTypeFilterTest, set severity to 'error' for indent violations; closes apache/opennlp#175

Repository: opennlp
Updated Branches:
  refs/heads/master 8fb1341ad -> 041507d3a


NoJira: Fix the codestyle violations in NameSampleTypeFilterTest, set severity to 'error' for indent violations; closes apache/opennlp#175


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

Branch: refs/heads/master
Commit: 041507d3aaf718ae536f9ab66e4eeb4065cb339d
Parents: 8fb1341
Author: smarthi <sm...@apache.org>
Authored: Wed Apr 19 21:52:46 2017 -0400
Committer: smarthi <sm...@apache.org>
Committed: Wed Apr 19 21:52:46 2017 -0400

----------------------------------------------------------------------
 checkstyle.xml                                  |  2 +-
 .../namefind/NameSampleTypeFilterTest.java      | 80 ++++++++++----------
 .../tools/util/TrainingParametersTest.java      | 31 +++-----
 3 files changed, 51 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/opennlp/blob/041507d3/checkstyle.xml
----------------------------------------------------------------------
diff --git a/checkstyle.xml b/checkstyle.xml
index 1bfe788..88e653f 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -113,7 +113,7 @@
       <property name="throwsIndent" value="4"/>
       <property name="lineWrappingIndentation" value="4"/>
       <property name="arrayInitIndent" value="2"/>
-      <property name="severity" value="warning"/>
+      <property name="severity" value="error"/>
     </module>
     <module name="EmptyCatchBlock">
       <property name="exceptionVariableName" value="expected|ignore"/>

http://git-wip-us.apache.org/repos/asf/opennlp/blob/041507d3/opennlp-tools/src/test/java/opennlp/tools/namefind/NameSampleTypeFilterTest.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/test/java/opennlp/tools/namefind/NameSampleTypeFilterTest.java b/opennlp-tools/src/test/java/opennlp/tools/namefind/NameSampleTypeFilterTest.java
index 24ecc9f..6e6095e 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/namefind/NameSampleTypeFilterTest.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/namefind/NameSampleTypeFilterTest.java
@@ -6,7 +6,7 @@
  * (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -35,68 +35,68 @@ import opennlp.tools.util.Span;
 
 public class NameSampleTypeFilterTest {
 
-    private static NameSampleTypeFilter filter;
+  private static NameSampleTypeFilter filter;
 
-    private static final String text = "<START:organization> NATO <END> Secretary - General " +
-            "<START:person> Anders Fogh Rasmussen <END> made clear that despite an intensifying " +
-            "insurgency and uncertainty over whether <START:location> U . S . <END> President " +
-            "<START:person> Barack Obama <END> will send more troops , <START:location> NATO <END> " +
-            "will remain in <START:location> Afghanistan <END> .";
+  private static final String text = "<START:organization> NATO <END> Secretary - General " +
+      "<START:person> Anders Fogh Rasmussen <END> made clear that despite an intensifying " +
+      "insurgency and uncertainty over whether <START:location> U . S . <END> President " +
+      "<START:person> Barack Obama <END> will send more troops , <START:location> NATO <END> " +
+      "will remain in <START:location> Afghanistan <END> .";
 
-    private static final String person = "person";
-    private static final String organization = "organization";
+  private static final String person = "person";
+  private static final String organization = "organization";
 
-    @Test
-    public void testNoFilter() throws IOException {
+  @Test
+  public void testNoFilter() throws IOException {
 
-        final String[] types = new String[] {};
+    final String[] types = new String[] {};
 
-        filter = new NameSampleTypeFilter(types, sampleStream(text));
+    filter = new NameSampleTypeFilter(types, sampleStream(text));
 
-        NameSample ns = filter.read();
+    NameSample ns = filter.read();
 
-        Assert.assertEquals(0, ns.getNames().length);
+    Assert.assertEquals(0, ns.getNames().length);
 
-    }
+  }
 
-    @Test
-    public void testSingleFilter() throws IOException {
+  @Test
+  public void testSingleFilter() throws IOException {
 
-        final String[] types = new String[] {organization};
+    final String[] types = new String[] {organization};
 
-        filter = new NameSampleTypeFilter(types, sampleStream(text));
+    filter = new NameSampleTypeFilter(types, sampleStream(text));
 
-        NameSample ns = filter.read();
+    NameSample ns = filter.read();
 
-        Assert.assertEquals(1, ns.getNames().length);
-        Assert.assertEquals(organization, ns.getNames()[0].getType());
+    Assert.assertEquals(1, ns.getNames().length);
+    Assert.assertEquals(organization, ns.getNames()[0].getType());
 
-    }
+  }
 
-    @Test
-    public void testMultiFilter() throws IOException {
+  @Test
+  public void testMultiFilter() throws IOException {
 
-        final String[] types = new String[] {person, organization};
+    final String[] types = new String[] {person, organization};
 
-        filter = new NameSampleTypeFilter(types, sampleStream(text));
+    filter = new NameSampleTypeFilter(types, sampleStream(text));
 
-        NameSample ns = filter.read();
+    NameSample ns = filter.read();
 
-        Map<String, List<Span>> collect = Arrays.stream(ns.getNames())
-                .collect(Collectors.groupingBy(Span::getType));
-        Assert.assertEquals(2, collect.size());
-        Assert.assertEquals(2, collect.get(person).size());
-        Assert.assertEquals(1, collect.get(organization).size());
+    Map<String, List<Span>> collect = Arrays.stream(ns.getNames())
+        .collect(Collectors.groupingBy(Span::getType));
+    Assert.assertEquals(2, collect.size());
+    Assert.assertEquals(2, collect.get(person).size());
+    Assert.assertEquals(1, collect.get(organization).size());
 
-    }
+  }
 
-    private ObjectStream<NameSample> sampleStream(String sampleText) throws IOException {
+  private ObjectStream<NameSample> sampleStream(String sampleText) throws IOException {
 
-        InputStreamFactory in = () -> new ByteArrayInputStream(sampleText.getBytes(StandardCharsets.UTF_8));
+    InputStreamFactory in = () -> new ByteArrayInputStream(sampleText.getBytes(StandardCharsets.UTF_8));
 
-        return new NameSampleDataStream(
-                new PlainTextByLineStream(in, StandardCharsets.UTF_8));
+    return new NameSampleDataStream(
+        new PlainTextByLineStream(in, StandardCharsets.UTF_8));
 
-    }
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/opennlp/blob/041507d3/opennlp-tools/src/test/java/opennlp/tools/util/TrainingParametersTest.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/test/java/opennlp/tools/util/TrainingParametersTest.java b/opennlp-tools/src/test/java/opennlp/tools/util/TrainingParametersTest.java
index 27e1695..294dff8 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/util/TrainingParametersTest.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/util/TrainingParametersTest.java
@@ -34,21 +34,11 @@ public class TrainingParametersTest {
         new TrainingParameters(build("key1=val1,key2=val2,key3=val3"));
 
     TrainingParameters tp2 = new TrainingParameters(
-      new ByteArrayInputStream("key1=val1\nkey2=val2\nkey3=val3\n".getBytes())
+        new ByteArrayInputStream("key1=val1\nkey2=val2\nkey3=val3\n".getBytes())
     );
 
     TrainingParameters tp3 = new TrainingParameters(tp2);
 
-    /*
-    Assert.assertEquals(3, tp1.getSettings().size());
-    Assert.assertEquals(3, tp3.getSettings().size());
-    Assert.assertEquals(tp1.getStringParameter("key1", "v11"),
-            tp3.getStringParameter("key1", "v22"));   // use different defaults
-    Assert.assertEquals(tp1.getStringParameter("key2", "v11"),
-            tp3.getStringParameter("key2", "v22"));   // use different defaults
-    Assert.assertEquals(tp1.getStringParameter("key2", "v11"),
-            tp3.getStringParameter("key2", "v22"));   // use different defaults
-            */
     assertEquals(tp1, tp2);
     assertEquals(tp2, tp3);
   }
@@ -60,14 +50,14 @@ public class TrainingParametersTest {
     Assert.assertEquals(4, tr.getSettings().size());
     Assert.assertEquals("MAXENT", tr.algorithm());
     Assert.assertEquals(EventTrainer.EVENT_VALUE,
-            tr.getStringParameter(TrainingParameters.TRAINER_TYPE_PARAM,
-                    "v11"));  // use different defaults
+        tr.getStringParameter(TrainingParameters.TRAINER_TYPE_PARAM,
+            "v11"));  // use different defaults
     Assert.assertEquals(100,
-            tr.getIntParameter(TrainingParameters.ITERATIONS_PARAM,
-                    200));  // use different defaults
+        tr.getIntParameter(TrainingParameters.ITERATIONS_PARAM,
+            200));  // use different defaults
     Assert.assertEquals(5,
-            tr.getIntParameter(TrainingParameters.CUTOFF_PARAM,
-                    200));  // use different defaults
+        tr.getIntParameter(TrainingParameters.CUTOFF_PARAM,
+            200));  // use different defaults
   }
 
   @Test
@@ -131,7 +121,7 @@ public class TrainingParametersTest {
   private static Map<String, String> buildMap(String str) {
     String[] pairs = str.split(",");
     Map<String, String> map = new HashMap<>(pairs.length);
-    for (String pair: pairs) {
+    for (String pair : pairs) {
       String[] keyValue = pair.split("=");
       map.put(keyValue[0], keyValue[1]);
     }
@@ -148,7 +138,7 @@ public class TrainingParametersTest {
     Assert.assertNotNull(map1);
     Assert.assertNotNull(map2);
     Assert.assertEquals(map1.size(), map2.size());
-    for (String key: map1.keySet()) {
+    for (String key : map1.keySet()) {
       Assert.assertEquals(map1.get(key), map2.get(key));
     }
   }
@@ -161,8 +151,7 @@ public class TrainingParametersTest {
   private static void assertEquals(TrainingParameters expected, TrainingParameters actual) {
     if (expected == null) {
       Assert.assertNull(actual);
-    }
-    else {
+    } else {
       assertEquals(expected.getSettings(), actual);
     }
   }