krickert commented on code in PR #1150:
URL: https://github.com/apache/opennlp/pull/1150#discussion_r3593729158


##########
opennlp-core/opennlp-runtime/src/test/java/opennlp/tools/tokenize/DefaultTokenContextGeneratorTest.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.tokenize;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import opennlp.tools.util.WhitespaceMode;
+
+/**
+ * Tests for the {@link DefaultTokenContextGenerator} class.
+ */
+public class DefaultTokenContextGeneratorTest {
+
+  private final DefaultTokenContextGenerator cg = new 
DefaultTokenContextGenerator();
+
+  /**
+   * Restores {@link WhitespaceMode} property resolution after each test, so 
no mode
+   * state leaks.
+   */
+  @AfterEach
+  void resetWhitespaceMode() {
+    WhitespaceMode.reset();
+  }
+
+  /**
+   * The {@code _ws} feature class follows the active {@link WhitespaceMode}; 
these features
+   * are part of every trained tokenizer model, so this pins the default 
behavior at the
+   * code points where the modes disagree: the next line control ({@code 
U+0085}) is
+   * classified as whitespace, the information separator ({@code U+001C}) is 
not.
+   */
+  @Test
+  void testNextLineControlProducesWhitespaceFeatureByDefault() {
+    WhitespaceMode.reset();

Review Comment:
   Missed it.  The @AfterEach already restores the mode, so the upfront reset() 
was redundant. Removed it (and the same pattern in the other test classes).



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to