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/107e09cb Tree: http://git-wip-us.apache.org/repos/asf/opennlp/tree/107e09cb Diff: http://git-wip-us.apache.org/repos/asf/opennlp/diff/107e09cb Branch: refs/heads/parser_regression Commit: 107e09cb58112ccf58ca3f4d94a6bb383a2cdb0c Parents: 35f2789 Author: Peter Thygesen <[email protected]> Authored: Tue Mar 28 16:59:34 2017 +0200 Committer: Jörn Kottmann <[email protected]> Committed: Thu Apr 20 12:40:25 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/107e09cb/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/107e09cb/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);
