This is an automated email from the ASF dual-hosted git repository.

mawiesne pushed a commit to branch 
OPENNLP-1623-Add-more-test-cases-for-Coref-component
in repository https://gitbox.apache.org/repos/asf/opennlp-sandbox.git

commit 8e0f51c63832aa7c8be94f586b0ee9397a470efd
Author: Martin Wiesner <[email protected]>
AuthorDate: Mon Oct 14 09:24:17 2024 +0200

    OPENNLP-1623 Add more test cases for Coref component
---
 .../opennlp/tools/coref/CorefSampleDataStream.java |   3 +-
 .../tools/coref/CorefSampleStreamFactory.java      |  10 +-
 .../java/opennlp/tools/coref/CorefTrainer.java     |   2 -
 .../java/opennlp/tools/coref/DefaultParse.java     |  15 ++-
 .../java/opennlp/tools/coref/DiscourseElement.java |  24 ++--
 .../java/opennlp/tools/coref/DiscourseEntity.java  |  51 ++++----
 .../opennlp/tools/coref/linker/AbstractLinker.java |  50 +++----
 .../tools/coref/mention/AbstractMentionFinder.java |   8 +-
 .../java/opennlp/tools/coref/sim/GenderModel.java  |  12 +-
 .../java/opennlp/tools/coref/sim/NumberModel.java  |  12 +-
 .../opennlp/tools/coref/sim/SimilarityModel.java   |  14 +-
 .../tools/coref/sim/TrainSimilarityModel.java      |   2 +-
 .../tools/formats/muc/MucCorefContentHandler.java  |  23 ++--
 .../tools/formats/muc/MucCorefSampleStream.java    |  12 +-
 .../java/opennlp/tools/coref/CorefParseTest.java}  |  52 ++++----
 .../tools/coref/CorefSampleDataStreamTest.java}    |  55 ++++----
 .../tools/coref/CorefSampleStreamFactoryTest.java  |  59 +++++++++
 .../java/opennlp/tools/coref/CorefSampleTest.java  |  55 ++++++++
 .../java/opennlp/tools/coref/CorefTrainerTest.java |  70 ++++++++++
 .../java/opennlp/tools/coref/DefaultParseTest.java | 145 +++++++++++++++++++++
 .../models/training/coref/training-test.txt        |   7 +
 21 files changed, 508 insertions(+), 173 deletions(-)

diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleDataStream.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleDataStream.java
index cccfe3a..b586021 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleDataStream.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleDataStream.java
@@ -45,8 +45,7 @@ public class CorefSampleDataStream extends 
FilterObjectStream<String, CorefSampl
     String document = samples.read();
     if (document != null) {
       return CorefSample.parse(document);
-    }
-    else {
+    } else {
       return null;
     }
   }
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleStreamFactory.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleStreamFactory.java
index 4fd0e6d..6dbf821 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleStreamFactory.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleStreamFactory.java
@@ -21,7 +21,6 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 
 import opennlp.tools.cmdline.ArgumentParser;
-import opennlp.tools.cmdline.CmdLineUtil;
 import opennlp.tools.cmdline.ObjectStreamFactory;
 import opennlp.tools.cmdline.StreamFactoryRegistry;
 import opennlp.tools.cmdline.params.BasicFormatParams;
@@ -55,16 +54,11 @@ public class CorefSampleStreamFactory extends 
AbstractSampleStreamFactory<CorefS
   public ObjectStream<CorefSample> create(String[] args) {
     Parameters params = ArgumentParser.parse(args, Parameters.class);
 
-    CmdLineUtil.checkInputFile("Data", params.getData());
-    final MarkableFileInputStreamFactory factory;
     try {
-      factory = new MarkableFileInputStreamFactory(params.getData());
+      final MarkableFileInputStreamFactory factory = new 
MarkableFileInputStreamFactory(params.getData());
+      return new CorefSampleDataStream(new ParagraphStream(new 
PlainTextByLineStream(factory, params.getEncoding())));
     } catch (FileNotFoundException e) {
       throw new RuntimeException("Error finding specified input file!", e);
-    }
-    try (ObjectStream<String> lineStream = new ParagraphStream(new 
PlainTextByLineStream(
-            factory, params.getEncoding()))) {
-      return new CorefSampleDataStream(lineStream);
     } catch (IOException e) {
       throw new RuntimeException("Error loading Coref samples from input 
data!", e);
     }
diff --git a/opennlp-coref/src/main/java/opennlp/tools/coref/CorefTrainer.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/CorefTrainer.java
index bb5480c..8f80231 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/CorefTrainer.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/CorefTrainer.java
@@ -94,8 +94,6 @@ public class CorefTrainer {
     TrainSimilarityModel genTrain = GenderModel.trainModel(modelDirectory + 
"/coref/gen");
     TrainSimilarityModel numTrain = NumberModel.trainModel(modelDirectory + 
"/coref/num");
     
-    useTreebank = true; 
-    
     Linker simLinker;
     
     if (useTreebank) {
diff --git a/opennlp-coref/src/main/java/opennlp/tools/coref/DefaultParse.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/DefaultParse.java
index 275da26..9756058 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/DefaultParse.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/DefaultParse.java
@@ -24,6 +24,9 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import opennlp.tools.parser.Parse;
 import opennlp.tools.parser.chunking.Parser;
 import opennlp.tools.util.Span;
@@ -35,9 +38,11 @@ import opennlp.tools.util.Span;
  */
 public class DefaultParse extends AbstractParse {
 
+  private static final Logger logger = 
LoggerFactory.getLogger(DefaultParse.class);
+
   public static final String[] NAME_TYPES = {"person", "organization", 
"location", "date",
       "time", "percentage", "money"};
-  
+
   private final Parse parse;
   private final int sentenceNumber;
   private static final Set<String> ENTITY_SET = new 
HashSet<>(Arrays.asList(NAME_TYPES));
@@ -163,7 +168,7 @@ public class DefaultParse extends AbstractParse {
       return null;
     }
     else {
-      return new DefaultParse(parent,sentenceNumber);
+      return new DefaultParse(parent, sentenceNumber);
     }
   }
 
@@ -171,8 +176,8 @@ public class DefaultParse extends AbstractParse {
   public boolean isNamedEntity() {
     
     // TODO: We should use here a special tag to, where
-    // the type can be extracted from. Then it just depends
-    // on the training data and not the values inside NAME_TYPES.
+    //  the type can be extracted from. Then it just depends
+    //  on the training data and not the values inside NAME_TYPES.
 
     return ENTITY_SET.contains(parse.getType());
   }
@@ -228,7 +233,7 @@ public class DefaultParse extends AbstractParse {
       if (parse.getSpan().getStart() == p.getSpan().getStart() &&
           parse.getSpan().getEnd() == p.getSpan().getEnd()) {
 
-        System.out.println("Maybe incorrect measurement!");
+        logger.trace("Maybe incorrect measurement!");
         
         // get parent and update distance
         // if match return distance
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/DiscourseElement.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/DiscourseElement.java
index 7ed7ed7..a74ae01 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/DiscourseElement.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/DiscourseElement.java
@@ -25,8 +25,7 @@ import opennlp.tools.coref.mention.MentionContext;
 import opennlp.tools.util.ReverseListIterator;
 
 /**
- * Represents an item in which can be put into a {@link DiscourseModel}.
- * Objects which are to be placed in such a model should extend this class.
+ * Abstract form of an item which can be put into a {@link DiscourseModel}.
  *
  * @see DiscourseModel
  */
@@ -48,28 +47,23 @@ public abstract class DiscourseElement {
   }
 
   /**
-   * Returns an iterator over the mentions which iterates through them
-   * based on which were most recently mentioned.
-   * @return the {@link Iterator}.
+   * @return Retrieves an {@link Iterator} over the mentions which iterates 
through them
+   * based on which were most recently mentioned..
    */
   public Iterator<MentionContext> getRecentMentions() {
     return new ReverseListIterator<>(extents);
   }
 
   /**
-   * Returns an iterator over the mentions which iterates through them based on
-   * their occurrence in the document.
-   *
-   * @return the {@link Iterator}
+   * @return Retrieves an {@link Iterator} over the mentions which iterates 
through them
+   * based on their occurrence in the document.
    */
   public Iterator<MentionContext> getMentions() {
     return extents.listIterator();
   }
 
   /**
-   * Returns the number of mentions in this element.
-   *
-   * @return number of mentions
+   * @return Retrieves the number of mentions in this element.
    */
   public int getNumMentions() {
     return extents.size();
@@ -85,7 +79,7 @@ public abstract class DiscourseElement {
   }
 
   /**
-   * Returns the last mention for this element.  For appositives this will be 
the
+   * Returns the last mention for this element. For appositives this will be 
the
    * first part of the appositive.
    * @return the last mention for this element.
    */
@@ -102,9 +96,7 @@ public abstract class DiscourseElement {
   }
 
   /**
-   * Returns the id associated with this element.
-   *
-   * @return the id associated with this element.
+   * @return Retrieves the id associated with this element.
    */
   public int getId() {
     return id;
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/DiscourseEntity.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/DiscourseEntity.java
index 193135b..47f58aa 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/DiscourseEntity.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/DiscourseEntity.java
@@ -22,8 +22,9 @@ import opennlp.tools.coref.sim.GenderEnum;
 import opennlp.tools.coref.sim.NumberEnum;
 
 /**
- * Represents an entity in a {@link DiscourseModel}.
+ * A specialized {@link DiscourseElement} representing an entity in a {@link 
DiscourseModel}.
  *
+ * @see DiscourseElement
  * @see DiscourseModel
  */
 public class DiscourseEntity extends DiscourseElement {
@@ -35,13 +36,14 @@ public class DiscourseEntity extends DiscourseElement {
   private double numberProb;
 
   /**
-   * Creates a new entity based on the specified mention and its specified 
gender and number properties.
+   * Instantiates a {@link DiscourseEntity} based on the specified mention and 
its specified gender and
+   * number properties.
    *
    * @param mention The first mention of this entity.
-   * @param gender The gender of this entity.
-   * @param genderProb The probability that the specified gender is correct.
-   * @param number The number for this entity.
-   * @param numberProb The probability that the specified number is correct.
+   * @param gender The {@link GenderEnum gender} of this entity.
+   * @param genderProb The probability that the specified gender is correct, 
in the range from {@code [0.0, ..., 1.0]}.
+   * @param number The {@link NumberEnum number} for this entity.
+   * @param numberProb The probability that the specified number is correct, 
in the range from {@code [0.0, ..., 1.0]}.
    */
   public DiscourseEntity(MentionContext mention, GenderEnum gender, double 
genderProb,
                          NumberEnum number, double numberProb) {
@@ -53,14 +55,13 @@ public class DiscourseEntity extends DiscourseElement {
   }
 
   /**
-   * Creates a new entity based on the specified mention.
+   * Instantiates a {@link DiscourseEntity} with unknown {@link GenderEnum 
gender}
+   * and {@link NumberEnum number} properties.
    *
    * @param mention The first mention of this entity.
    */
   public DiscourseEntity(MentionContext mention) {
-    super(mention);
-    gender = GenderEnum.UNKNOWN;
-    number = NumberEnum.UNKNOWN;
+    this(mention, GenderEnum.UNKNOWN, 0.0d, NumberEnum.UNKNOWN, 0.0d);
   }
 
   /**
@@ -83,43 +84,35 @@ public class DiscourseEntity extends DiscourseElement {
   }
 
   /**
-   * Returns the gender associated with this entity.
-   *
-   * @return the gender associated with this entity.
+   * @return Retrieves the {@link GenderEnum gender} associated with this 
entity.
    */
   public GenderEnum getGender() {
     return gender;
   }
 
   /**
-   * Returns the probability for the gender associated with this entity.
-   *
-   * @return the probability for the gender associated with this entity.
+   * @return Retrieves the probability for the {@link GenderEnum gender} 
associated with this entity.
    */
   public double getGenderProbability() {
     return genderProb;
   }
 
   /**
-   * Returns the number associated with this entity.
-   *
-   * @return the number associated with this entity.
+   * @return Retrieves the {@link NumberEnum number} associated with this 
entity.
    */
   public NumberEnum getNumber() {
     return number;
   }
 
   /**
-   * Returns the probability for the number associated with this entity.
-   *
-   * @return the probability for the number associated with this entity.
+   * @return Retrieves the probability for the {@link NumberEnum number} 
associated with this entity.
    */
   public double getNumberProbability() {
     return numberProb;
   }
 
   /**
-   * Specifies the gender of this entity.
+   * Specifies the {@link GenderEnum gender} of this entity.
    *
    * @param gender The gender.
    */
@@ -128,27 +121,27 @@ public class DiscourseEntity extends DiscourseElement {
   }
 
   /**
-   * Specifies the probability of the gender of this entity.
+   * Specifies the probability of the {@link GenderEnum gender} of this entity.
    *
-   * @param p the probability of the gender of this entity.
+   * @param p the probability of the gender, in the range from {@code [0.0, 
..., 1.0]}.
    */
   public void setGenderProbability(double p) {
     genderProb = p;
   }
 
   /**
-   * Specifies the number of this entity.
+   * Specifies the {@link NumberEnum number} of this entity.
    *
-   * @param number
+   * @param number The {@link NumberEnum number}.
    */
   public void setNumber(NumberEnum number) {
     this.number = number;
   }
 
   /**
-   * Specifies the probability of the number of this entity.
+   * Specifies the probability of the {@link NumberEnum number} of this entity.
    *
-   * @param p the probability of the number of this entity.
+   * @param p the probability of the number, in the range from {@code [0.0, 
..., 1.0]}.
    */
   public void setNumberProbability(double p) {
     numberProb = p;
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/linker/AbstractLinker.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/linker/AbstractLinker.java
index 7ca95b7..0338d8c 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/linker/AbstractLinker.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/linker/AbstractLinker.java
@@ -246,33 +246,35 @@ public abstract class AbstractLinker implements Linker {
     MentionContext[] contexts = new MentionContext[mentions.length];
     for (int mi = 0,mn = mentions.length;mi < mn; mi++) {
       Parse mentionParse = mentions[mi].getParse();
-      logger.debug("Constructing MentionContexts: mentionParse = {}", 
mentionParse);
       if (mentionParse == null) {
-        logger.warn("no parse for {}", mentions[mi]);
-      }
-      int sentenceIndex = mentionParse.getSentenceNumber();
-      if (sentenceIndex != prevSentenceIndex) {
-        mentionInSentenceIndex = 0;
-        prevSentenceIndex = sentenceIndex;
-        numMentionsInSentence = 0;
-        for (int msi = mi; msi < mentions.length; msi++) {
-          if (sentenceIndex != mentions[msi].getParse().getSentenceNumber()) {
-            break;
+        logger.warn("No parse for {}", mentions[mi]);
+      } else {
+        logger.debug("Constructing MentionContexts: mentionParse = {}", 
mentionParse);
+        int sentenceIndex = mentionParse.getSentenceNumber();
+        if (sentenceIndex != prevSentenceIndex) {
+          mentionInSentenceIndex = 0;
+          prevSentenceIndex = sentenceIndex;
+          numMentionsInSentence = 0;
+          for (int msi = mi; msi < mentions.length; msi++) {
+            Parse p = mentions[msi].getParse();
+            if (p != null && sentenceIndex != p.getSentenceNumber()) {
+              break;
+            }
+            numMentionsInSentence++;
           }
-          numMentionsInSentence++;
         }
-      }
-      contexts[mi] = new MentionContext(mentions[mi], mentionInSentenceIndex,
-          numMentionsInSentence, mi, sentenceIndex, getHeadFinder());
-      logger.debug("Constructing MentionContexts:: mi={} sn={} extent={} 
parse={} mc={}",
-              mi, mentionParse.getSentenceNumber(), mentions[mi], 
mentionParse.getSpan(), contexts[mi].toText());
-      contexts[mi].setId(mentions[mi].getId());
-      mentionInSentenceIndex++;
-      if (mode != LinkerMode.SIM) {
-        Gender g  = computeGender(contexts[mi]);
-        contexts[mi].setGender(g.getType(),g.getConfidence());
-        Number n = computeNumber(contexts[mi]);
-        contexts[mi].setNumber(n.getType(),n.getConfidence());
+        contexts[mi] = new MentionContext(mentions[mi], mentionInSentenceIndex,
+                numMentionsInSentence, mi, sentenceIndex, getHeadFinder());
+        logger.debug("Constructing MentionContexts:: mi={} sn={} extent={} 
parse={} mc={}",
+                mi, mentionParse.getSentenceNumber(), mentions[mi], 
mentionParse.getSpan(), contexts[mi].toText());
+        contexts[mi].setId(mentions[mi].getId());
+        mentionInSentenceIndex++;
+        if (mode != LinkerMode.SIM) {
+          Gender g  = computeGender(contexts[mi]);
+          contexts[mi].setGender(g.getType(),g.getConfidence());
+          Number n = computeNumber(contexts[mi]);
+          contexts[mi].setNumber(n.getType(),n.getConfidence());
+        }
       }
     }
     return (contexts);
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java
 
b/opennlp-coref/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java
index 8413bdf..18fa55b 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/coref/mention/AbstractMentionFinder.java
@@ -162,7 +162,7 @@ public abstract class AbstractMentionFinder implements 
MentionFinder {
           if (ti - 1 >= 0 && (npTokens.get(ti - 
1)).getSyntacticType().startsWith("NN")) {
             Span npSpan = new Span((npTokens.get(ti + 1)).getSpan().getStart(),
                 npTokens.get(lastNpTokenIndex).getSpan().getEnd());
-            Mention snpExtent = new Mention(npSpan, npSpan, tok.getEntityId(), 
null,"CNP");
+            Mention snpExtent = new Mention(npSpan, npSpan, tok.getEntityId(), 
tok, "CNP");
             entities.add(snpExtent);
             logger.debug("Adding extent for conjunction in: {} preceded by {}",
                     np, npTokens.get(ti-1).getSyntacticType());
@@ -178,7 +178,7 @@ public abstract class AbstractMentionFinder implements 
MentionFinder {
         if (lastNpTokenIndex != ti) {
           Span npSpan = new Span((npTokens.get(ti + 1)).getSpan().getStart(),
               npTokens.get(lastNpTokenIndex).getSpan().getEnd());
-          Mention snpExtent = new Mention(npSpan, npSpan, tok.getEntityId(), 
null,"CNP");
+          Mention snpExtent = new Mention(npSpan, npSpan, tok.getEntityId(), 
tok ,"CNP");
           entities.add(snpExtent);
           logger.debug("Adding extent for comma in: {}", np);
         }
@@ -187,7 +187,7 @@ public abstract class AbstractMentionFinder implements 
MentionFinder {
       else if (inCoordinatedNounPhrase && ti == 0 && lastNpTokenIndex >= 0) {
         Span npSpan = new Span((npTokens.get(ti)).getSpan().getStart(),
             npTokens.get(lastNpTokenIndex).getSpan().getEnd());
-        Mention snpExtent = new Mention(npSpan, npSpan, tok.getEntityId(), 
null,"CNP");
+        Mention snpExtent = new Mention(npSpan, npSpan, tok.getEntityId(), 
tok, "CNP");
         entities.add(snpExtent);
         logger.debug("Adding extent for start coord in: {}", np);
       }
@@ -226,7 +226,7 @@ public abstract class AbstractMentionFinder implements 
MentionFinder {
         }
         if (tok.getSyntacticType().startsWith("PRP") && 
handledPronoun(tok.toString())) {
           Mention ppExtent = new Mention(tok.getSpan(), tok.getSpan(),
-              tok.getEntityId(), null,Linker.PRONOUN_MODIFIER);
+              tok.getEntityId(), tok, Linker.PRONOUN_MODIFIER);
           logger.debug("CollectPossessivePronouns: adding possessive pronoun: 
{} {}", tok, tok.getEntityId());
           entities.add(ppExtent);
           logger.debug("Adding pos-pro: {}", ppExtent);
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/GenderModel.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/GenderModel.java
index 097a30b..6226121 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/GenderModel.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/GenderModel.java
@@ -187,11 +187,13 @@ public class GenderModel implements TestGenderModel, 
TrainSimilarityModel {
     HashMap<Integer,Context> entities = new HashMap<>();
     List<Context> singletons = new ArrayList<>();
     for (Context ec : extentContexts) {
-      logger.debug("GenderModel.setExtents: ec({}) {}", ec.getId(), ec);
-      if (ec.getId() != -1) {
-        entities.put(ec.getId(), ec);
-      } else {
-        singletons.add(ec);
+      if (ec != null) {
+        logger.debug("GenderModel.setExtents: ec({}) {}", ec.getId(), ec);
+        if (ec.getId() != -1) {
+          entities.put(ec.getId(), ec);
+        } else {
+          singletons.add(ec);
+        }
       }
     }
     List<Context> males = new ArrayList<>();
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/NumberModel.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/NumberModel.java
index 2eb08cc..8eb38b4 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/NumberModel.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/NumberModel.java
@@ -123,11 +123,13 @@ public class NumberModel implements TestNumberModel, 
TrainSimilarityModel {
     Map<Integer,Context> entities = new HashMap<>();
     List<Context> singletons = new ArrayList<>();
     for (Context ec : extentContexts) {
-      logger.debug("NumberModel.setExtents: ec({}) {}", ec.getId(), ec);
-      if (ec.getId() != -1) {
-        entities.put(ec.getId(), ec);
-      } else {
-        singletons.add(ec);
+      if (ec != null) {
+        logger.debug("NumberModel.setExtents: ec({}) {}", ec.getId(), ec);
+        if (ec.getId() != -1) {
+          entities.put(ec.getId(), ec);
+        } else {
+          singletons.add(ec);
+        }
       }
     }
     List<Context> singles = new ArrayList<>();
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/SimilarityModel.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/SimilarityModel.java
index 25648a0..453827e 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/SimilarityModel.java
+++ b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/SimilarityModel.java
@@ -283,13 +283,15 @@ public class SimilarityModel implements 
TestSimilarityModel, TrainSimilarityMode
     List<Context> allExtents = new ArrayList<>();
     // populate data structures
     for (Context ec : extentContexts) {
-      logger.debug("Set extents: ec({}) {} {}", ec.getId(), ec.getNameType(), 
ec);
-      if (ec.getId() == -1) {
-        singletons.add(ec);
-      } else {
-        entities.put(ec.getId(), ec);
+      if (ec != null) {
+        logger.debug("Set extents: ec({}) {} {}", ec.getId(), 
ec.getNameType(), ec);
+        if (ec.getId() == -1) {
+          singletons.add(ec);
+        } else {
+          entities.put(ec.getId(), ec);
+        }
+        allExtents.add(ec);
       }
-      allExtents.add(ec);
     }
 
     int axi = 0;
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/TrainSimilarityModel.java 
b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/TrainSimilarityModel.java
index f281431..88ff21a 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/coref/sim/TrainSimilarityModel.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/coref/sim/TrainSimilarityModel.java
@@ -27,7 +27,7 @@ public interface TrainSimilarityModel {
   void trainModel() throws IOException;
   /**
    * Creates similarity training pairs based on the specified extents.
-   * Extents are considered compatible is they are in the same coreference 
chain,
+   * Extents are considered compatible if they are in the same coreference 
chain,
    * have the same named-entity tag, or share a common head word.
    * <p>
    * Incompatible extents are chosen at random from the set of extents which 
don't meet these criteria.
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/formats/muc/MucCorefContentHandler.java
 
b/opennlp-coref/src/main/java/opennlp/tools/formats/muc/MucCorefContentHandler.java
index 798d319..867d2dc 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/formats/muc/MucCorefContentHandler.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/formats/muc/MucCorefContentHandler.java
@@ -31,7 +31,7 @@ import opennlp.tools.util.Span;
 // Take care for special @ sign handling (identifies a table or something else 
that should be ignored)
 class MucCorefContentHandler extends SgmlParser.ContentHandler {
 
-  static class CorefMention {
+  public static class CorefMention {
     Span span;
     int id;
     final String min;
@@ -56,32 +56,35 @@ class MucCorefContentHandler extends 
SgmlParser.ContentHandler {
   private final Map<Integer, Integer> idMap = new HashMap<>();
 
   private RawCorefSample sample;
-  
+
+  /**
+   * Initializes a {@link MucCorefContentHandler}.
+   *
+   * @param tokenizer The {@link Tokenizer} to use. Must not be {@code null}.
+   * @param samples The {@link List< RawCorefSample > samples} as input.
+   *                      Must not be {@code null}.
+   */
   MucCorefContentHandler(Tokenizer tokenizer, List<RawCorefSample> samples) {
     this.tokenizer = tokenizer;
     this.samples = samples;
   }
   
   /**
-   * Resolve an id via the references to the root id.
+   * Resolves an id via the references to the root {@code id}.
    * 
    * @param id the id or reference to be resolved
    * 
-   * @return the resolved id or -1 if id cannot be resolved
+   * @return the resolved {@code id} or {@code -1} if id cannot be resolved.
    */
   private int resolveId(int id) {
-    
     Integer refId = idMap.get(id);
-    
     if (refId != null) {
       if (id == refId) {
         return id;
-      }
-      else {
+      } else {
         return resolveId(refId);
       }
-    }
-    else {
+    } else {
       return -1;
     }
   }
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/formats/muc/MucCorefSampleStream.java
 
b/opennlp-coref/src/main/java/opennlp/tools/formats/muc/MucCorefSampleStream.java
index 26fd19d..405de86 100644
--- 
a/opennlp-coref/src/main/java/opennlp/tools/formats/muc/MucCorefSampleStream.java
+++ 
b/opennlp-coref/src/main/java/opennlp/tools/formats/muc/MucCorefSampleStream.java
@@ -31,16 +31,24 @@ public class MucCorefSampleStream extends 
FilterObjectStream<String, RawCorefSam
   private final Tokenizer tokenizer;
   
   private final List<RawCorefSample> documents = new ArrayList<>();
-  
+
+  /**
+   * Initializes a {@link MucCorefSampleStream}.
+   *
+   * @param tokenizer The {@link Tokenizer} to use. Must not be {@code null}.
+   * @param documents The {@link ObjectStream<String> documents} as input. 
Must not be {@code null}.
+   *
+   * @throws IllegalArgumentException Thrown if parameters are invalid.
+   */
   public MucCorefSampleStream(Tokenizer tokenizer, ObjectStream<String> 
documents) {
     super(new DocumentSplitterStream(documents));
     this.tokenizer = tokenizer;
   }
 
+  @Override
   public RawCorefSample read() throws IOException {
     
     if (documents.isEmpty()) {
-      
       String document = samples.read();
       
       if (document != null) {
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleDataStream.java 
b/opennlp-coref/src/test/java/opennlp/tools/coref/CorefParseTest.java
similarity index 50%
copy from 
opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleDataStream.java
copy to opennlp-coref/src/test/java/opennlp/tools/coref/CorefParseTest.java
index cccfe3a..e64ba37 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleDataStream.java
+++ b/opennlp-coref/src/test/java/opennlp/tools/coref/CorefParseTest.java
@@ -17,37 +17,33 @@
 
 package opennlp.tools.coref;
 
-import java.io.IOException;
+import opennlp.tools.cmdline.parser.ParserTool;
+import opennlp.tools.coref.linker.AbstractLinkerTest;
+import opennlp.tools.parser.Parse;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-import opennlp.tools.util.FilterObjectStream;
-import opennlp.tools.util.ObjectStream;
+import java.util.Arrays;
+import java.util.List;
 
-/**
- * A specialized {@link FilterObjectStream} implementation to process {@link 
CorefSample samples}.
- *
- * @see CorefSample
- * @see FilterObjectStream
- */
-public class CorefSampleDataStream extends FilterObjectStream<String, 
CorefSample> {
-
-  /**
-   * Initializes an {@link CorefSampleDataStream}.
-   *
-   * @param samples The {@link ObjectStream stream} of samples to filter.
-   *                Must not be {@code null}.
-   */
-  public CorefSampleDataStream(ObjectStream<String> samples) {
-    super(samples);
+public class CorefParseTest extends AbstractLinkerTest {
+
+  private static final String example = "The test may come today . ";
+  //        "(TOP (S (NP (DT The) (NN test)) (VP (MD may) (VP (VB come) (NP 
(NN today)))) (. .)))";
+
+
+  private List<Parse> parses;
+
+  @BeforeEach
+  public void setUp() {
+    parses = Arrays.stream(ParserTool.parseLine(example, parserEN, 
1)).toList();
   }
 
-  @Override
-  public CorefSample read() throws IOException {
-    String document = samples.read();
-    if (document != null) {
-      return CorefSample.parse(document);
-    }
-    else {
-      return null;
-    }
+  @Test
+  // TODO make this a solid test -> DiscourseEntity
+  void testConstruct() {
+    CorefParse cp = new CorefParse(parses, new DiscourseEntity[0]);
+    cp.show();
   }
+
 }
diff --git 
a/opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleDataStream.java 
b/opennlp-coref/src/test/java/opennlp/tools/coref/CorefSampleDataStreamTest.java
similarity index 52%
copy from 
opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleDataStream.java
copy to 
opennlp-coref/src/test/java/opennlp/tools/coref/CorefSampleDataStreamTest.java
index cccfe3a..3cef7b5 100644
--- a/opennlp-coref/src/main/java/opennlp/tools/coref/CorefSampleDataStream.java
+++ 
b/opennlp-coref/src/test/java/opennlp/tools/coref/CorefSampleDataStreamTest.java
@@ -17,37 +17,40 @@
 
 package opennlp.tools.coref;
 
+import opennlp.tools.util.ObjectStream;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
 import java.io.IOException;
 
-import opennlp.tools.util.FilterObjectStream;
-import opennlp.tools.util.ObjectStream;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-/**
- * A specialized {@link FilterObjectStream} implementation to process {@link 
CorefSample samples}.
- *
- * @see CorefSample
- * @see FilterObjectStream
- */
-public class CorefSampleDataStream extends FilterObjectStream<String, 
CorefSample> {
-
-  /**
-   * Initializes an {@link CorefSampleDataStream}.
-   *
-   * @param samples The {@link ObjectStream stream} of samples to filter.
-   *                Must not be {@code null}.
-   */
-  public CorefSampleDataStream(ObjectStream<String> samples) {
-    super(samples);
+public class CorefSampleDataStreamTest {
+
+  private CorefSampleStreamFactory streamFactory;
+
+  private String[] args;
+
+  @BeforeAll
+  public static void initEnv() {
+    CorefSampleStreamFactory.registerFactory();
   }
 
-  @Override
-  public CorefSample read() throws IOException {
-    String document = samples.read();
-    if (document != null) {
-      return CorefSample.parse(document);
-    }
-    else {
-      return null;
+  @BeforeEach
+  public void setUp() {
+    streamFactory= new CorefSampleStreamFactory();
+    args = new String[]{"-data", CorefSampleDataStreamTest.class.getResource(
+            "/models/training/coref/training-test.txt").getPath()};
+  }
+
+  @Test
+  void testRead() throws IOException {
+    try (ObjectStream<CorefSample> samples = streamFactory.create(args)) {
+      assertNotNull(samples);
+      CorefSample cs = samples.read();
+      assertNotNull(cs);
     }
   }
+
 }
diff --git 
a/opennlp-coref/src/test/java/opennlp/tools/coref/CorefSampleStreamFactoryTest.java
 
b/opennlp-coref/src/test/java/opennlp/tools/coref/CorefSampleStreamFactoryTest.java
new file mode 100644
index 0000000..1470c62
--- /dev/null
+++ 
b/opennlp-coref/src/test/java/opennlp/tools/coref/CorefSampleStreamFactoryTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.coref;
+
+import opennlp.tools.util.ObjectStream;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class CorefSampleStreamFactoryTest {
+
+  private CorefSampleStreamFactory streamFactory;
+
+  @BeforeAll
+  public static void initEnv() {
+    CorefSampleStreamFactory.registerFactory();
+  }
+
+  @BeforeEach
+  public void setUp() {
+    streamFactory= new CorefSampleStreamFactory();
+  }
+
+  @Test
+  void testCreate() {
+    String[] args = new String[]{"-data",
+            
CorefSampleStreamFactoryTest.class.getResource("/models/training/coref/training-test.txt").getPath()};
+    ObjectStream<CorefSample> samples = streamFactory.create(args);
+    assertNotNull(samples);
+  }
+
+  @Test
+  void testCreateWithEmptyParameters() {
+    assertThrows(IllegalArgumentException.class, () -> 
streamFactory.create(new String[0]));
+  }
+
+  @Test
+  void testCreateWithIncorrectParameters() {
+    assertThrows(RuntimeException.class, () -> streamFactory.create(new 
String[]{"-data","Non-Existing.txt"}));
+  }
+}
diff --git 
a/opennlp-coref/src/test/java/opennlp/tools/coref/CorefSampleTest.java 
b/opennlp-coref/src/test/java/opennlp/tools/coref/CorefSampleTest.java
new file mode 100644
index 0000000..0caeaab
--- /dev/null
+++ b/opennlp-coref/src/test/java/opennlp/tools/coref/CorefSampleTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.coref;
+
+import opennlp.tools.coref.mention.Parse;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class CorefSampleTest {
+
+  private static final String example =
+          "(TOP (S (NP-SBJ (DT The) (NN test) )(VP (MD may) (VP (VB come) 
(NP-TMP (NN today) )))(. .) ))";
+
+  @Test
+  void testGetParses() {
+    CorefSample cs = CorefSample.parse(example);
+    assertNotNull(cs);
+    List<Parse> parses = cs.getParses();
+    assertNotNull(parses);
+    assertEquals(1, parses.size());
+    Parse p = parses.get(0);
+    assertNotNull(p);
+    assertEquals("The test may come today . ", p.toString());
+  }
+
+  @Test
+  void testToString() {
+    CorefSample cs = CorefSample.parse(example);
+    assertNotNull(cs);
+    String s = cs.toString();
+    assertNotNull(s);
+    assertFalse(s.isEmpty());
+  }
+
+}
diff --git 
a/opennlp-coref/src/test/java/opennlp/tools/coref/CorefTrainerTest.java 
b/opennlp-coref/src/test/java/opennlp/tools/coref/CorefTrainerTest.java
new file mode 100644
index 0000000..95e7ecc
--- /dev/null
+++ b/opennlp-coref/src/test/java/opennlp/tools/coref/CorefTrainerTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.coref;
+
+import opennlp.tools.util.ObjectStream;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class CorefTrainerTest extends AbstractCorefTest {
+
+  private static String modelTrainingDir;
+
+  @BeforeAll
+  public static void initEnv() throws IOException, URISyntaxException {
+    final URL modelInputDirectory = 
CorefTrainerTest.class.getResource(AbstractCorefTest.MODEL_DIR);
+    URL modelTrainingDirectory = 
CorefTrainerTest.class.getResource(AbstractCorefTest.MODEL_TRAINING_DIR);
+    assertNotNull(modelInputDirectory);
+    assertNotNull(modelTrainingDirectory);
+    modelTrainingDir = 
Path.of(modelTrainingDirectory.toURI()).toAbsolutePath().toString();
+    // transfer resources to the training directory
+    modelTrainingDirectory = 
CorefTrainerTest.class.getResource(AbstractCorefTest.MODEL_TRAINING_DIR + 
"/coref/");
+    Path pOriginal = Paths.get(modelInputDirectory.toURI());
+    Path pTraining = Paths.get(modelTrainingDirectory.toURI());
+
+    Files.copy(pOriginal.resolve("gen.fem").toAbsolutePath(),
+            pTraining.resolve("gen.fem").toAbsolutePath(), 
StandardCopyOption.REPLACE_EXISTING);
+    Files.copy(pOriginal.resolve("gen.mas").toAbsolutePath(),
+            pTraining.resolve("gen.mas").toAbsolutePath(), 
StandardCopyOption.REPLACE_EXISTING);
+    Files.copy(pOriginal.resolve("acronyms").toAbsolutePath(),
+            pTraining.resolve("acronyms").toAbsolutePath(), 
StandardCopyOption.REPLACE_EXISTING);
+  }
+
+  @Disabled
+  @ParameterizedTest
+  @ValueSource(booleans = {true, false})
+  void testTrainByTreebank(Boolean withTreebank) throws IOException {
+    CorefSampleStreamFactory streamFactory = new CorefSampleStreamFactory();
+    String[] args = new String[]{"-data",
+            
CorefTrainerTest.class.getResource("/models/training/coref/training-test.txt").getPath()};
+    ObjectStream<CorefSample> samples = streamFactory.create(args);
+    CorefTrainer.train(modelTrainingDir, samples, withTreebank, false);
+  }
+}
diff --git 
a/opennlp-coref/src/test/java/opennlp/tools/coref/DefaultParseTest.java 
b/opennlp-coref/src/test/java/opennlp/tools/coref/DefaultParseTest.java
new file mode 100644
index 0000000..735169a
--- /dev/null
+++ b/opennlp-coref/src/test/java/opennlp/tools/coref/DefaultParseTest.java
@@ -0,0 +1,145 @@
+/*
+ * 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.coref;
+
+import opennlp.tools.parser.Parse;
+import opennlp.tools.util.Span;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class DefaultParseTest {
+
+  private static final String example =
+          "(TOP (S (NP (DT The) (NN test)) (VP (MD may) (VP (VB come) (NP (NN 
today)))) (. .)))";
+
+  private static final String exampleChanged =
+          "(TOP (S (NP (DT The) (NN proof)) (VP (MD may) (VP (VB come) (NP (NN 
today)))) (. .)))";
+
+  private Parse parse;
+
+  // SUT
+  private DefaultParse dp;
+
+  @BeforeEach
+  public void setUp() {
+    parse = Parse.parseParse(example);
+    /* parse = ParserTool.parseLine("The test may come today . ", parserEN, 
1)[0]; */
+    dp = new DefaultParse(parse, 1);
+  }
+
+  @Test
+  void testConstruct() {
+    assertEquals(parse, dp.getParse());
+    assertEquals(1, dp.getSentenceNumber());
+    assertTrue(dp.isSentence());
+    assertEquals(-1, dp.getEntityId());
+    assertNull(dp.getParent());
+    assertFalse(dp.isParentNAC());
+    Span s = dp.getSpan();
+    assertEquals(0, s.getStart());
+    assertEquals(26, s.getEnd());
+  }
+
+  @Test
+  void testCompareTo() {
+    DefaultParse dp2 = new DefaultParse(parse, 1);
+    assertEquals(0, dp.compareTo(dp2));
+  }
+
+  @Test
+  void testCompareToIdentity() {
+    //noinspection EqualsWithItself
+    assertEquals(0, dp.compareTo(dp));
+  }
+
+  @Test
+  void testEquals() {
+    DefaultParse dp2 = new DefaultParse(parse, 1);
+    assertEquals(dp, dp2);
+  }
+
+  @Test
+  void testEqualsIdentity() {
+    //noinspection EqualsWithItself
+    assertEquals(dp, dp);
+  }
+
+  @Test
+  void testHashCode() {
+    DefaultParse dp2 = new DefaultParse(parse, 1);
+    assertEquals(dp.hashCode(), dp2.hashCode());
+  }
+
+  @Test
+  void testHashCodeIdentity() {
+    assertEquals(dp.hashCode(), dp.hashCode());
+  }
+
+  @Test
+  void testCompareToWithDifferentParses() {
+    DefaultParse dp2 = new DefaultParse(Parse.parseParse(exampleChanged), 1);
+    assertEquals(1, dp.compareTo(dp2));
+    assertEquals(-1, dp2.compareTo(dp));
+  }
+
+  @Test
+  void testGetNamedEntities() {
+    List<opennlp.tools.coref.mention.Parse> dpNamedEntities = 
dp.getNamedEntities();
+    assertNotNull(dpNamedEntities);
+    assertTrue(dpNamedEntities.isEmpty());
+  }
+
+  @Test
+  void testGetChildren() {
+    List<opennlp.tools.coref.mention.Parse> dpChildren = dp.getChildren();
+    assertNotNull(dpChildren);
+    assertFalse(dpChildren.isEmpty());
+    assertEquals(1, dpChildren.size());
+  }
+
+  @Test
+  void testGetSyntacticChildren() {
+    List<opennlp.tools.coref.mention.Parse> dpChildren = 
dp.getSyntacticChildren();
+    assertNotNull(dpChildren);
+    assertFalse(dpChildren.isEmpty());
+    assertEquals(1, dpChildren.size());
+  }
+
+  @Test
+  void testGetSyntacticType() {
+    List<opennlp.tools.coref.mention.Parse> dpTokens = dp.getTokens();
+    assertNotNull(dpTokens);
+    assertFalse(dpTokens.isEmpty());
+    assertEquals(6, dpTokens.size());
+    assertEquals("DT", dpTokens.get(0).getSyntacticType());
+    assertEquals("NN", dpTokens.get(1).getSyntacticType());
+    assertEquals("MD", dpTokens.get(2).getSyntacticType());
+    assertEquals("VB", dpTokens.get(3).getSyntacticType());
+    assertEquals("NN", dpTokens.get(4).getSyntacticType());
+    assertEquals(".", dpTokens.get(5).getSyntacticType());
+  }
+
+}
diff --git 
a/opennlp-coref/src/test/resources/models/training/coref/training-test.txt 
b/opennlp-coref/src/test/resources/models/training/coref/training-test.txt
new file mode 100644
index 0000000..bcc267d
--- /dev/null
+++ b/opennlp-coref/src/test/resources/models/training/coref/training-test.txt
@@ -0,0 +1,7 @@
+(TOP (S (NP-SBJ (NNS People) )(VP (VBP are) (RB n't) (VP (VBG panicking) ))(. 
.) ))
+(TOP (S (NP-SBJ (DT The) (NN test) )(VP (MD may) (VP (VB come) (NP-TMP (NN 
today) )))(. .) ))
+(TOP (S (NP-SBJ (NP (NNP Friday) (POS 's) )(NN stock) (NN market) (NN 
sell-off) )(VP (VBD came) (ADVP-TMP (RB too) (RB late) (SBAR (IN for) (S 
(NP-SBJ (JJ many) (NNS investors) )(VP (TO to) (VP (VB act) ))))))(. .) ))
+(TOP (S (NP-SBJ (DT Some) (NNS shareholders) )(VP (VBP have) (VP (VBN held) 
(PRT (RP off) )(PP-TMP (IN until) (NP (NN today) ))(SBAR-PRP (IN because) (S 
(NP-SBJ (NP (DT any) (NN fund) (NNS exchanges) )(VP (VBN made) (NP (-NONE- *) 
)(PP-TMP (IN after) (NP (NP (NNP Friday) (POS 's) )(NN close) ))))(VP (MD 
would) (VP (VB take) (NP (NN place) )(PP (IN at) (NP (NP (NN today) (POS 's) 
)(NN closing) (NNS prices) ))))))))(. .) ))
+(TOP (S (NP-SBJ-1 (NN Stock) (NN fund) (NNS redemptions) )(PP-TMP (IN during) 
(NP (DT the) (CD 1987) (NN debacle) ))(VP (VBD did) (RB n't) (VP (VB begin) (S 
(NP-SBJ (-NONE- *-1) )(VP (TO to) (VP (VB snowball) )))(PP-TMP (IN until) (SBAR 
(IN after) (S (NP-SBJ (DT the) (NN market) )(VP (VBD opened) (PP-TMP (IN on) 
(NP (NNP Black) (NNP Monday) ))))))))(. .) ))
+(TOP (S (CC But) (NP-SBJ (NN fund) (NNS managers) )(VP (VBP say) (SBAR (-NONE- 
0) (S (NP-SBJ (PRP they) )(VP (VBP 're) (ADJP-PRD (JJ ready) )))))(. .) ))
+(TOP (S (NP-SBJ (JJ Many) )(VP (VBP have) (VP (VBN raised) (NP (NP (NN cash) 
(NNS levels) )(, ,) (SBAR (WHNP-1 (WDT which) )(S (NP-SBJ (-NONE- *T*-1) )(VP 
(VBP act) (PP-CLR (IN as) (NP (DT a) (NN buffer) ))(PP (IN against) (NP (JJ 
steep) (NN market) (NNS declines) ))))))))(. .) ))


Reply via email to