You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by th...@apache.org on 2017/04/11 21:15:37 UTC

opennlp git commit: OPENNLP-1006: Refactor usage of tag constants in sequence validators

Repository: opennlp
Updated Branches:
  refs/heads/master 3e408074a -> e2ea53597


OPENNLP-1006: Refactor usage of tag constants in sequence validators


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

Branch: refs/heads/master
Commit: e2ea5359798ce8dc77d4b23b0f9b4df33b37f940
Parents: 3e40807
Author: Peter Thygesen <pe...@gmail.com>
Authored: Tue Mar 28 16:59:34 2017 +0200
Committer: Peter Thygesen <th...@Peters-MacBook-Pro.local>
Committed: Tue Apr 11 23:10:56 2017 +0200

----------------------------------------------------------------------
 .../src/main/java/opennlp/tools/namefind/BioCodec.java   | 10 +++++-----
 .../tools/namefind/NameFinderSequenceValidator.java      | 11 +++++++----
 2 files changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/opennlp/blob/e2ea5359/opennlp-tools/src/main/java/opennlp/tools/namefind/BioCodec.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/namefind/BioCodec.java b/opennlp-tools/src/main/java/opennlp/tools/namefind/BioCodec.java
index 2218021..c0570a5 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/namefind/BioCodec.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/namefind/BioCodec.java
@@ -118,13 +118,13 @@ public class BioCodec implements SequenceCodec<String> {
 
     for (int i = 0; i < outcomes.length; i++) {
       String outcome = outcomes[i];
-      if (outcome.endsWith(NameFinderME.START)) {
+      if (outcome.endsWith(BioCodec.START)) {
         start.add(outcome.substring(0, outcome.length()
-            - NameFinderME.START.length()));
-      } else if (outcome.endsWith(NameFinderME.CONTINUE)) {
+            - BioCodec.START.length()));
+      } else if (outcome.endsWith(BioCodec.CONTINUE)) {
         cont.add(outcome.substring(0, outcome.length()
-            - NameFinderME.CONTINUE.length()));
-      } else if (!outcome.equals(NameFinderME.OTHER)) {
+            - BioCodec.CONTINUE.length()));
+      } else if (!outcome.equals(BioCodec.OTHER)) {
         // got unexpected outcome
         return false;
       }

http://git-wip-us.apache.org/repos/asf/opennlp/blob/e2ea5359/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderSequenceValidator.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderSequenceValidator.java b/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderSequenceValidator.java
index 5143468..bb6700e 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderSequenceValidator.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderSequenceValidator.java
@@ -19,6 +19,9 @@ package opennlp.tools.namefind;
 
 import opennlp.tools.util.SequenceValidator;
 
+/**
+ * This class is created by the {@link BioCodec}.
+ */
 public class NameFinderSequenceValidator implements
     SequenceValidator<String> {
 
@@ -27,16 +30,16 @@ public class NameFinderSequenceValidator implements
 
     // outcome is formatted like "cont" or "sometype-cont", so we
     // can check if it ends with "cont".
-    if (outcome.endsWith(NameFinderME.CONTINUE)) {
+    if (outcome.endsWith(BioCodec.CONTINUE)) {
 
       int li = outcomesSequence.length - 1;
 
       if (li == -1) {
         return false;
-      } else if (outcomesSequence[li].endsWith(NameFinderME.OTHER)) {
+      } else if (outcomesSequence[li].endsWith(BioCodec.OTHER)) {
         return false;
-      } else if (outcomesSequence[li].endsWith(NameFinderME.CONTINUE) ||
-          outcomesSequence[li].endsWith(NameFinderME.START)) {
+      } else if (outcomesSequence[li].endsWith(BioCodec.CONTINUE) ||
+          outcomesSequence[li].endsWith(BioCodec.START)) {
         // if it is continue or start, we have to check if previous match was of the same type
         String previousNameType = NameFinderME.extractNameType(outcomesSequence[li]);
         String nameType = NameFinderME.extractNameType(outcome);