[ 
https://issues.apache.org/jira/browse/OPENNLP-1448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17692817#comment-17692817
 ] 

ASF GitHub Bot commented on OPENNLP-1448:
-----------------------------------------

mawiesne commented on code in PR #492:
URL: https://github.com/apache/opennlp/pull/492#discussion_r1116010408


##########
opennlp-tools/src/main/java/opennlp/tools/formats/masc/MascDocumentStream.java:
##########
@@ -140,8 +143,7 @@ public MascDocumentStream(File mascCorpusDirectory,
               documents.add(MascDocument.parseDocument(hdrFilePath, f_primary, 
f_seg,
                   f_penn, f_s, f_ne));
             } catch (IOException e) {
-              System.err.println("Failed to parse the file: " + hdrFilePath);
-              System.err.println('\t' + e.getMessage());
+              logger.warn("Failed to parse the file: {}", hdrFilePath, e);

Review Comment:
   This might be a `logger.error(...)` statement, even though it's inside a 
loop here. 
   Reason: exception (handling) involved. Open for other thoughts.



##########
opennlp-tools/src/main/java/opennlp/tools/formats/masc/MascDocument.java:
##########
@@ -353,7 +353,7 @@ private void addPennTags(Map<String, Map<Integer, ?>> 
tagMaps) throws IOExceptio
       //Check that all tokens have at least one quark.
       for (Map.Entry<Integer, int[]> token : tokenToQuarks.entrySet()) {
         if (token.getValue().length == 0) {
-          System.err.println("[ERROR] Token without quarks: " + 
token.getKey());
+          logger.error("Token without quarks: {}", token.getKey());

Review Comment:
   This should better be a `logger.warn(...)` statement, I guess. Text has 
informative character and no exception has occurred.



##########
opennlp-tools/src/main/java/opennlp/tools/log/LogPrintStream.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package opennlp.tools.log;
+
+import java.io.PrintStream;
+import java.util.Objects;
+
+import org.slf4j.Logger;
+import org.slf4j.event.Level;
+
+import opennlp.tools.commons.Internal;
+
+/**
+ * This class serves as an adapter for a {@link Logger} used within a {@link 
PrintStream}.
+ */
+@Internal
+public class LogPrintStream extends PrintStream {
+
+  private final Logger logger;
+  private final Level level;
+
+  /**
+   * Creates a {@link LogPrintStream} for the given {@link Logger}

Review Comment:
   Please add a `.` at the end of the sentence.



##########
opennlp-distr/pom.xml:
##########
@@ -54,6 +54,17 @@
             <groupId>org.apache.opennlp</groupId>
             <artifactId>opennlp-brat-annotator</artifactId>
         </dependency>
+               <!

> Introduce SLF4J in OpenNLP
> --------------------------
>
>                 Key: OPENNLP-1448
>                 URL: https://issues.apache.org/jira/browse/OPENNLP-1448
>             Project: OpenNLP
>          Issue Type: Sub-task
>            Reporter: Richard Zowalla
>            Assignee: Richard Zowalla
>            Priority: Major
>
> This will be the first step regarding OPENNLP-1447.
> Goal is to replace System.err / System.out calls with logger output, which is 
> configurable.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to