getAnnotatedEntities();
-
- /**
- * Call this method once you have finished using the {@link PredicateTruth},
- * and you will not use it any more.
- *
- * I.e. DON'T call it each time you are done with a sentence, but
- * only once there are no more sentences to be annotated any more.
- */
- public void cleanUp();
-}
-
-
+package eu.excitementproject.eop.transformations.biu.en.predicatetruth;
+
+import java.util.List;
+
+import eu.excitementproject.eop.lap.biu.ner.NamedEntityRecognizerException;
+import eu.excitementproject.eop.transformations.generic.truthteller.conll.ConllConverterException;
+import eu.excitementproject.eop.transformations.representation.ExtendedNode;
+
+/**
+ * An interface for Truth annotations components
+ *
+ * @author Gabi Stanovsky
+ * @since Aug 2014
+ */
+
+public interface PredicateTruth {
+
+ /**
+ * Call this method only once.
+ *
+ * Call the method to initialize the {@linkplain PredicateTruth}
+ *
+ * Don't call other methods of this interface before calling {@linkplain #init()} method.
+ * @throws ConllConverterException
+ * @throws NamedEntityRecognizerException An error occured while trying to initialize.
+ */
+ public void init() throws PredicateTruthException;
+
+ /**
+ * Set a sentence to the {@linkplain PredicateTruth}.
+ * */
+ public void setSentence(ExtendedNode annotatedSentence);
+
+ /**
+ * Assigns truth value to the words in the sentence.
+ * Assigns null for words which don't have truth values.
+ * @throws PredicateTruthException on Any error
+ * @throws ConllConverterException
+ */
+ public void annotate() throws PredicateTruthException;
+
+ /**
+ *
Call this method only after calling {@link #annotate()} method.
+ * @return a List of corresponding to truth values according to the position of the token in the sentence
+ * as assigned by the truth annotator (by the {@link #annotate} method).
+ */
+ public List getAnnotatedEntities();
+
+ /**
+ * Call this method once you have finished using the {@link PredicateTruth},
+ * and you will not use it any more.
+ *
+ * I.e. DON'T call it each time you are done with a sentence, but
+ * only once there are no more sentences to be annotated any more.
+ */
+ public void cleanUp();
+}
+
+
diff --git a/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/PredicateTruthException.java b/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/PredicateTruthException.java
index 3cefc67b..a7eb4e3f 100644
--- a/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/PredicateTruthException.java
+++ b/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/PredicateTruthException.java
@@ -1,23 +1,23 @@
-package eu.excitementproject.eop.transformations.biu.en.predicatetruth;
-
-
-/**
- * Exception class thrown by {@link PredicateTruth} in any error case.
- * @author Gabi Stanovsky
- * @since Aug 2014
- */
-public class PredicateTruthException extends Exception
-{
- private static final long serialVersionUID = 1L;
-
- public PredicateTruthException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public PredicateTruthException(String message)
- {
- super(message);
- }
-
-}
+package eu.excitementproject.eop.transformations.biu.en.predicatetruth;
+
+
+/**
+ * Exception class thrown by {@link PredicateTruth} in any error case.
+ * @author Gabi Stanovsky
+ * @since Aug 2014
+ */
+public class PredicateTruthException extends Exception
+{
+ private static final long serialVersionUID = 1L;
+
+ public PredicateTruthException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public PredicateTruthException(String message)
+ {
+ super(message);
+ }
+
+}
diff --git a/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/SingleTokenTruthAnnotation.java b/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/SingleTokenTruthAnnotation.java
index b8840dcd..dcb74851 100644
--- a/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/SingleTokenTruthAnnotation.java
+++ b/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/SingleTokenTruthAnnotation.java
@@ -1,89 +1,89 @@
-package eu.excitementproject.eop.transformations.biu.en.predicatetruth;
-
-import java.util.List;
-
-import eu.excitementproject.eop.transformations.representation.ExtendedNode;
-import eu.excitementproject.eop.transformations.representation.annotations.ClauseTruth;
-import eu.excitementproject.eop.transformations.representation.annotations.NegationAndUncertainty;
-import eu.excitementproject.eop.transformations.representation.annotations.PredTruth;
-import eu.excitementproject.eop.transformations.representation.annotations.PredicateSignature;
-
-/**
- * A container for the result of truth annotation on a single token
- * contains Predicate Truth, Clause Truth, Negation and Uncertainty, and Predicate Signature
- * If any of these is missing, an empty string is expected.
- * @author Gabi Stanovsky
- * @since Aug 2014
- */
-
-public class SingleTokenTruthAnnotation {
-
- private PredTruth predicateTruthValue;
- private ClauseTruth clauseTruthValue;
- private NegationAndUncertainty nuValue;
- private PredicateSignature predicateSignatureValue;
-
- private List subtree;
- private Integer subtreeMinimalIndex,subtreeMaximalIndex;
-
- public SingleTokenTruthAnnotation(PredTruth pt,ClauseTruth ct, NegationAndUncertainty nu, PredicateSignature sig, List sub){
- predicateTruthValue = pt;
- clauseTruthValue = ct;
- nuValue = nu;
- predicateSignatureValue = sig;
- subtree=sub;
- subtreeMaximalIndex = null;
- subtreeMinimalIndex = null;
- }
-
- public SingleTokenTruthAnnotation(PredTruth pt,ClauseTruth ct, NegationAndUncertainty nu, PredicateSignature sig){
- this(pt,ct,nu,sig,null);
- }
-
-
-
- public int getSubtreeMinimalIndex() {
- return subtreeMinimalIndex;
- }
-
- public void setSubtreeMinimalIndex(int subtreeMinimalIndex) {
- this.subtreeMinimalIndex = subtreeMinimalIndex;
- }
-
- public int getSubtreeMaximalIndex() {
- return subtreeMaximalIndex;
- }
-
- public void setSubtreeMaximalIndex(int subtreeMaximalIndex) {
- this.subtreeMaximalIndex = subtreeMaximalIndex;
- }
-
- public PredTruth getPredicateTruthValue() {
- return predicateTruthValue;
- }
-
- public ClauseTruth getClauseTruthValue() {
- return clauseTruthValue;
- }
-
- public NegationAndUncertainty getNuValue() {
- return nuValue;
- }
-
- public PredicateSignature getPredicateSignatureValue() {
- return predicateSignatureValue;
- }
-
- public List getSubtree() {
- return subtree;
- }
-
-
- public void setSubtree(List subtree) {
- this.subtree = subtree;
- }
-
-
-
-
-}
+package eu.excitementproject.eop.transformations.biu.en.predicatetruth;
+
+import java.util.List;
+
+import eu.excitementproject.eop.transformations.representation.ExtendedNode;
+import eu.excitementproject.eop.transformations.representation.annotations.ClauseTruth;
+import eu.excitementproject.eop.transformations.representation.annotations.NegationAndUncertainty;
+import eu.excitementproject.eop.transformations.representation.annotations.PredTruth;
+import eu.excitementproject.eop.transformations.representation.annotations.PredicateSignature;
+
+/**
+ * A container for the result of truth annotation on a single token
+ * contains Predicate Truth, Clause Truth, Negation and Uncertainty, and Predicate Signature
+ * If any of these is missing, an empty string is expected.
+ * @author Gabi Stanovsky
+ * @since Aug 2014
+ */
+
+public class SingleTokenTruthAnnotation {
+
+ private PredTruth predicateTruthValue;
+ private ClauseTruth clauseTruthValue;
+ private NegationAndUncertainty nuValue;
+ private PredicateSignature predicateSignatureValue;
+
+ private List subtree;
+ private Integer subtreeMinimalIndex,subtreeMaximalIndex;
+
+ public SingleTokenTruthAnnotation(PredTruth pt,ClauseTruth ct, NegationAndUncertainty nu, PredicateSignature sig, List sub){
+ predicateTruthValue = pt;
+ clauseTruthValue = ct;
+ nuValue = nu;
+ predicateSignatureValue = sig;
+ subtree=sub;
+ subtreeMaximalIndex = null;
+ subtreeMinimalIndex = null;
+ }
+
+ public SingleTokenTruthAnnotation(PredTruth pt,ClauseTruth ct, NegationAndUncertainty nu, PredicateSignature sig){
+ this(pt,ct,nu,sig,null);
+ }
+
+
+
+ public int getSubtreeMinimalIndex() {
+ return subtreeMinimalIndex;
+ }
+
+ public void setSubtreeMinimalIndex(int subtreeMinimalIndex) {
+ this.subtreeMinimalIndex = subtreeMinimalIndex;
+ }
+
+ public int getSubtreeMaximalIndex() {
+ return subtreeMaximalIndex;
+ }
+
+ public void setSubtreeMaximalIndex(int subtreeMaximalIndex) {
+ this.subtreeMaximalIndex = subtreeMaximalIndex;
+ }
+
+ public PredTruth getPredicateTruthValue() {
+ return predicateTruthValue;
+ }
+
+ public ClauseTruth getClauseTruthValue() {
+ return clauseTruthValue;
+ }
+
+ public NegationAndUncertainty getNuValue() {
+ return nuValue;
+ }
+
+ public PredicateSignature getPredicateSignatureValue() {
+ return predicateSignatureValue;
+ }
+
+ public List getSubtree() {
+ return subtree;
+ }
+
+
+ public void setSubtree(List subtree) {
+ this.subtree = subtree;
+ }
+
+
+
+
+}
diff --git a/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/TruthTellerAnnotator.java b/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/TruthTellerAnnotator.java
index 1cea1874..44332bfc 100644
--- a/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/TruthTellerAnnotator.java
+++ b/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/TruthTellerAnnotator.java
@@ -1,128 +1,128 @@
-package eu.excitementproject.eop.transformations.biu.en.predicatetruth;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import eu.excitementproject.eop.common.representation.parse.tree.AbstractNodeUtils;
-import eu.excitementproject.eop.transformations.generic.truthteller.AnnotatorException;
-import eu.excitementproject.eop.transformations.generic.truthteller.DefaultSentenceAnnotator;
-import eu.excitementproject.eop.transformations.representation.AdditionalNodeInformation;
-import eu.excitementproject.eop.transformations.representation.ExtendedNode;
-
-/**
- * An implementation of the "inner tool" of the analysis engine,
- * serves a wrapper for the TruthTeller calls.
- * @author Gabi Stanovsky
- * @since Aug 2014
- */
-
-public class TruthTellerAnnotator implements PredicateTruth {
-
-
- private DefaultSentenceAnnotator annotator;
- private File annotationRulesFile;
- private ExtendedNode annotatedSentence;
- private List annotationResult;
-
- /**
- * Constructor which receives the annotation rules file
- * @param IannotationRulesFile
- * @throws PredicateTruthException
- */
- public TruthTellerAnnotator(File annotationRulesFile) throws PredicateTruthException{
- this.annotationRulesFile = annotationRulesFile;
- annotatedSentence = null;
- }
-
- @Override
- public void init() throws PredicateTruthException {
- try {
- annotator = new DefaultSentenceAnnotator(annotationRulesFile);
- } catch (AnnotatorException e) {
- throw new PredicateTruthException(e.getMessage(),e);
- }
- }
-
- @Override
- public void setSentence(ExtendedNode annotatedSentence) {
- this.annotatedSentence = annotatedSentence;
- // clear annotation result
- annotationResult = new ArrayList();
- }
-
- @Override
- public void annotate() throws PredicateTruthException {
- try {
- // verify that setSentence was run before calling this function
- if (annotatedSentence == null){
- throw new PredicateTruthException("annotate was called without first calling setSentence");
- }
- // run TruthTeller
- annotator.setTree(annotatedSentence);
- annotator.annotate();
- ExtendedNode ttResult = annotator.getAnnotatedTree();
- Map annotationMap = new HashMap(); //needed since truth annotations won't be read in the sentence order
-
- // iterate over nodes and extract annotations to UIMA format
- List nodes = AbstractNodeUtils.treeToList(ttResult);
-
- for (ExtendedNode node : nodes){
- int serial = node.getInfo().getNodeInfo().getSerial()-1; // this node's id in the original sentence
- AdditionalNodeInformation info = node.getInfo().getAdditionalNodeInformation();
- // store result from info, according to index in the original sentence
- SingleTokenTruthAnnotation singleTokenAnnotation =new SingleTokenTruthAnnotation(info.getPredTruth(),info.getClauseTruth(),info.getNegationAndUncertainty(),info.getPredicateSignature());
-
- if (singleTokenAnnotation.getClauseTruthValue() !=null){
- // get a list of all subtree tokens, by getting the deep antecedent of all
- // the subtree, and storing in the set - thus obtaining a unique copy of all "real" tokens
- int minimalIndex = -1,maximalIndex = -1; // variables to store the boundaries of the subtree
- Set subtree = new HashSet();
- for (ExtendedNode child : AbstractNodeUtils.treeToList(node)){
- ExtendedNode toAdd =AbstractNodeUtils.getDeepAntecedentOf(child);
- int curId = node.getInfo().getNodeInfo().getSerial()-1;
- subtree.add(toAdd);
- // calculate boundaries
- if ((minimalIndex == -1)||(curId < minimalIndex)){
- minimalIndex = curId;
- }
- if ((maximalIndex == -1)||(curId > maximalIndex)){
- maximalIndex = curId;
- }
- }
-
- // store the subtree and its boundaries
- singleTokenAnnotation.setSubtree(new ArrayList(subtree));
- singleTokenAnnotation.setSubtreeMinimalIndex(minimalIndex);
- singleTokenAnnotation.setSubtreeMaximalIndex(maximalIndex);
- }
- annotationMap.put(serial,singleTokenAnnotation);
-
- }
-
- //convert the map into a list - assumes there's a truth annotation for each token index
- for (int i=0; i < annotationMap.size();i++){
- annotationResult.add(annotationMap.get(i));
- }
-
- } catch (AnnotatorException e) {
- throw new PredicateTruthException(e.getMessage(),e);
- }
- }
-
- @Override
- public List getAnnotatedEntities() {
- return annotationResult;
- }
-
- @Override
- public void cleanUp() {
- // stub - nothing to do to close TruthTeller
-
- }
-
-}
+package eu.excitementproject.eop.transformations.biu.en.predicatetruth;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import eu.excitementproject.eop.common.representation.parse.tree.AbstractNodeUtils;
+import eu.excitementproject.eop.transformations.generic.truthteller.AnnotatorException;
+import eu.excitementproject.eop.transformations.generic.truthteller.DefaultSentenceAnnotator;
+import eu.excitementproject.eop.transformations.representation.AdditionalNodeInformation;
+import eu.excitementproject.eop.transformations.representation.ExtendedNode;
+
+/**
+ * An implementation of the "inner tool" of the analysis engine,
+ * serves a wrapper for the TruthTeller calls.
+ * @author Gabi Stanovsky
+ * @since Aug 2014
+ */
+
+public class TruthTellerAnnotator implements PredicateTruth {
+
+
+ private DefaultSentenceAnnotator annotator;
+ private File annotationRulesFile;
+ private ExtendedNode annotatedSentence;
+ private List annotationResult;
+
+ /**
+ * Constructor which receives the annotation rules file
+ * @param IannotationRulesFile
+ * @throws PredicateTruthException
+ */
+ public TruthTellerAnnotator(File annotationRulesFile) throws PredicateTruthException{
+ this.annotationRulesFile = annotationRulesFile;
+ annotatedSentence = null;
+ }
+
+ @Override
+ public void init() throws PredicateTruthException {
+ try {
+ annotator = new DefaultSentenceAnnotator(annotationRulesFile);
+ } catch (AnnotatorException e) {
+ throw new PredicateTruthException(e.getMessage(),e);
+ }
+ }
+
+ @Override
+ public void setSentence(ExtendedNode annotatedSentence) {
+ this.annotatedSentence = annotatedSentence;
+ // clear annotation result
+ annotationResult = new ArrayList();
+ }
+
+ @Override
+ public void annotate() throws PredicateTruthException {
+ try {
+ // verify that setSentence was run before calling this function
+ if (annotatedSentence == null){
+ throw new PredicateTruthException("annotate was called without first calling setSentence");
+ }
+ // run TruthTeller
+ annotator.setTree(annotatedSentence);
+ annotator.annotate();
+ ExtendedNode ttResult = annotator.getAnnotatedTree();
+ Map annotationMap = new HashMap(); //needed since truth annotations won't be read in the sentence order
+
+ // iterate over nodes and extract annotations to UIMA format
+ List nodes = AbstractNodeUtils.treeToList(ttResult);
+
+ for (ExtendedNode node : nodes){
+ int serial = node.getInfo().getNodeInfo().getSerial()-1; // this node's id in the original sentence
+ AdditionalNodeInformation info = node.getInfo().getAdditionalNodeInformation();
+ // store result from info, according to index in the original sentence
+ SingleTokenTruthAnnotation singleTokenAnnotation =new SingleTokenTruthAnnotation(info.getPredTruth(),info.getClauseTruth(),info.getNegationAndUncertainty(),info.getPredicateSignature());
+
+ if (singleTokenAnnotation.getClauseTruthValue() !=null){
+ // get a list of all subtree tokens, by getting the deep antecedent of all
+ // the subtree, and storing in the set - thus obtaining a unique copy of all "real" tokens
+ int minimalIndex = -1,maximalIndex = -1; // variables to store the boundaries of the subtree
+ Set subtree = new HashSet();
+ for (ExtendedNode child : AbstractNodeUtils.treeToList(node)){
+ ExtendedNode toAdd =AbstractNodeUtils.getDeepAntecedentOf(child);
+ int curId = node.getInfo().getNodeInfo().getSerial()-1;
+ subtree.add(toAdd);
+ // calculate boundaries
+ if ((minimalIndex == -1)||(curId < minimalIndex)){
+ minimalIndex = curId;
+ }
+ if ((maximalIndex == -1)||(curId > maximalIndex)){
+ maximalIndex = curId;
+ }
+ }
+
+ // store the subtree and its boundaries
+ singleTokenAnnotation.setSubtree(new ArrayList(subtree));
+ singleTokenAnnotation.setSubtreeMinimalIndex(minimalIndex);
+ singleTokenAnnotation.setSubtreeMaximalIndex(maximalIndex);
+ }
+ annotationMap.put(serial,singleTokenAnnotation);
+
+ }
+
+ //convert the map into a list - assumes there's a truth annotation for each token index
+ for (int i=0; i < annotationMap.size();i++){
+ annotationResult.add(annotationMap.get(i));
+ }
+
+ } catch (AnnotatorException e) {
+ throw new PredicateTruthException(e.getMessage(),e);
+ }
+ }
+
+ @Override
+ public List getAnnotatedEntities() {
+ return annotationResult;
+ }
+
+ @Override
+ public void cleanUp() {
+ // stub - nothing to do to close TruthTeller
+
+ }
+
+}
diff --git a/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/TruthTellerAnnotatorAE.java b/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/TruthTellerAnnotatorAE.java
index 3a80fc1d..f7ed6016 100644
--- a/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/TruthTellerAnnotatorAE.java
+++ b/transformations/src/main/java/eu/excitementproject/eop/transformations/biu/en/predicatetruth/TruthTellerAnnotatorAE.java
@@ -1,38 +1,38 @@
-package eu.excitementproject.eop.transformations.biu.en.predicatetruth;
-
-import java.io.File;
-
-import org.uimafit.descriptor.ConfigurationParameter;
-
-import eu.excitementproject.eop.common.datastructures.Envelope;
-import eu.excitementproject.eop.transformations.uima.ae.truthteller.PredicateTruthAE;
-
-/**
- * Inherits truth annotations, and makes specific calls for Truth Teller's wrapper
- * @author Gabi Stanovsky
- * @since Aug 2014
- */
-
-public class TruthTellerAnnotatorAE extends PredicateTruthAE {
-
-
- // get the configuration parameter
- public static final String PARAM_CONFIG = "annotationRulesFile";
- @ConfigurationParameter(name = PARAM_CONFIG, mandatory = true)
- private File annotationRulesFile;
-
-
- @Override
- protected TruthTellerAnnotator buildInnerTool() throws Exception {
- TruthTellerAnnotator ret = new TruthTellerAnnotator(annotationRulesFile);
- ret.init();
- return ret;
- }
-
- @Override
- protected final Envelope getEnvelope(){return envelope;}
-
-
- private static Envelope envelope = new Envelope();
-
-}
+package eu.excitementproject.eop.transformations.biu.en.predicatetruth;
+
+import java.io.File;
+
+import org.uimafit.descriptor.ConfigurationParameter;
+
+import eu.excitementproject.eop.common.datastructures.Envelope;
+import eu.excitementproject.eop.transformations.uima.ae.truthteller.PredicateTruthAE;
+
+/**
+ * Inherits truth annotations, and makes specific calls for Truth Teller's wrapper
+ * @author Gabi Stanovsky
+ * @since Aug 2014
+ */
+
+public class TruthTellerAnnotatorAE extends PredicateTruthAE {
+
+
+ // get the configuration parameter
+ public static final String PARAM_CONFIG = "annotationRulesFile";
+ @ConfigurationParameter(name = PARAM_CONFIG, mandatory = true)
+ private File annotationRulesFile;
+
+
+ @Override
+ protected TruthTellerAnnotator buildInnerTool() throws Exception {
+ TruthTellerAnnotator ret = new TruthTellerAnnotator(annotationRulesFile);
+ ret.init();
+ return ret;
+ }
+
+ @Override
+ protected final Envelope getEnvelope(){return envelope;}
+
+
+ private static Envelope envelope = new Envelope();
+
+}
diff --git a/transformations/src/main/java/eu/excitementproject/eop/transformations/component/alignment/predicatetruthlink/PredicateTruthAligner.java b/transformations/src/main/java/eu/excitementproject/eop/transformations/component/alignment/predicatetruthlink/PredicateTruthAligner.java
index 954ddfbb..983ef040 100644
--- a/transformations/src/main/java/eu/excitementproject/eop/transformations/component/alignment/predicatetruthlink/PredicateTruthAligner.java
+++ b/transformations/src/main/java/eu/excitementproject/eop/transformations/component/alignment/predicatetruthlink/PredicateTruthAligner.java
@@ -1,310 +1,310 @@
-package eu.excitementproject.eop.transformations.component.alignment.predicatetruthlink;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.uima.cas.CASException;
-import org.apache.uima.jcas.JCas;
-import org.apache.uima.jcas.cas.EmptyStringList;
-import org.apache.uima.jcas.cas.FSArray;
-import org.apache.uima.jcas.cas.NonEmptyStringList;
-import org.apache.uima.jcas.cas.StringList;
-import org.apache.uima.jcas.tcas.Annotation;
-import org.uimafit.util.JCasUtil;
-
-import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token;
-import eu.excitement.type.alignment.Link;
-import eu.excitement.type.alignment.Link.Direction;
-import eu.excitement.type.alignment.Target;
-import eu.excitement.type.predicatetruth.PredicateTruth;
-import eu.excitement.type.predicatetruth.PredicateTruthNegative;
-import eu.excitement.type.predicatetruth.PredicateTruthPositive;
-import eu.excitement.type.predicatetruth.PredicateTruthUncertain;
-import eu.excitementproject.eop.common.component.alignment.AlignmentComponent;
-import eu.excitementproject.eop.common.component.alignment.AlignmentComponentException;
-import eu.excitementproject.eop.common.component.alignment.PairAnnotatorComponentException;
-import eu.excitementproject.eop.common.utilities.uima.UimaUtils;
-import eu.excitementproject.eop.lap.implbase.LAP_ImplBase;
-
-
-
-/**
- * Produces alignment links between the text and the hypothesis,
- * based on the predicate truth annotations
- *
- * Usage: align a sentence pair by calling the annotate method.
- * When the {@linkplain Aligner} object is no longer to be used, the
- * {@link #cleanUp()} method should be called.
- *
- * @author Gabi Stanovsky
- * @since Aug 2014
- */
-
-
-public class PredicateTruthAligner implements AlignmentComponent {
-
- private JCas textView, hypoView;
-
- //constant values used for aligner description
- public static final String ALIGNER_ID = "PredicateTruth";
- public static final String ALIGNER_VERSION = "TruthTeller_1.0";
- public static final String ALIGNEMNT_TYPE_AGREEING_POSITIVE = "Agreeing_Positive_Predicate_Truth";
- public static final String ALIGNEMNT_TYPE_AGREEING_NEGATIVE = "Agreeing_Negative_Predicate_Truth";
- public static final String ALIGNEMNT_TYPE_DISAGREEING = "Disagreeing_Predicate_Truth";
- public static final String ALIGNEMNT_TYPE_NON_MATCHING = "Non_Matching_Predicate_Truth";
- //group labels
- public static final String GROUP_LABEL_OPPOSITE_PREDICATE_TRUTH = "OPPOSITE_PREDICATE_TRUTH";
- public static final String GROUP_LABEL_SAME_PREDICATE_TRUTH = "SAME_PREDICATE_TRUTH";
- public static final String GROUP_LABEL_LOCAL_CONTRADICTION = "LOCAL_CONTRADICTION";
- public static final String GROUP_LABEL_LOCAL_ENTAILMENT = "LOCAL_ENTAILMENT";
-
- //(currently) constant values used for alignment links
- private static final double ALIGNER_CONFIDENCE = 1.0;
- private static final Direction ALIGNER_DIRECTION = Direction.Bidirection;
-
- //store the annotations of predicate truth, for memoization
- private Map,Collection extends Annotation>> memoTextAnnots;
- private Map,Collection extends Annotation>> memoHypoAnnots;
- private static final List> ptTypes = new ArrayList>(){
- private static final long serialVersionUID = 8489900798036315449L;
-
- {
- add(PredicateTruthPositive.class);
- add(PredicateTruthNegative.class);
- add(PredicateTruthUncertain.class);
- }};
-
-
-
- /**
- * default constructor
- * set all members to null
- */
- public PredicateTruthAligner(){
- textView = null;
- hypoView = null;
- }
-
- @Override
- public void annotate(JCas aJCas) throws PairAnnotatorComponentException {
- try {
- // create possible group labels instances for this jcas
- StringList localEntailment = createStringList(aJCas, new ArrayList() {
- private static final long serialVersionUID = 1L;
-
- {
- add(GROUP_LABEL_SAME_PREDICATE_TRUTH);
- add(GROUP_LABEL_LOCAL_ENTAILMENT);
- }});
-
- StringList localContradiction = createStringList(aJCas, new ArrayList() {
- private static final long serialVersionUID = 1L;
-
- {
- add(GROUP_LABEL_OPPOSITE_PREDICATE_TRUTH);
- add(GROUP_LABEL_LOCAL_CONTRADICTION);
- }});
-
- StringList emptyGroupLabel = new EmptyStringList(aJCas);
-
-
- // Get the text and hypothesis views
- textView = aJCas.getView(LAP_ImplBase.TEXTVIEW);
- hypoView = aJCas.getView(LAP_ImplBase.HYPOTHESISVIEW);
-
- // Record annotations
- memoTextAnnots = new HashMap,Collection extends Annotation>>();
- memoHypoAnnots = new HashMap,Collection extends Annotation>>();
-
- for (Class extends PredicateTruth> ptType : ptTypes){
- memoTextAnnots.put(ptType, JCasUtil.select(textView, ptType));
- memoHypoAnnots.put(ptType, JCasUtil.select(hypoView, ptType));
- }
-
-
- // add alignment links
- // Agreeing Positive Predicate Truth
- // PT+ <-> PT+
- createPredicateTruthLinks(PredicateTruthPositive.class,PredicateTruthPositive.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_AGREEING_POSITIVE,localEntailment);
-
- // Agreeing Negative Predicate Truth
- // PT- <-> PT-
- createPredicateTruthLinks(PredicateTruthNegative.class,PredicateTruthNegative.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_AGREEING_NEGATIVE,localEntailment);
-
- // Disagreeing Predicate Truth
- // PT+ <-> PT-
- createPredicateTruthLinks(PredicateTruthPositive.class,PredicateTruthNegative.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_DISAGREEING,localContradiction);
- // PT- <-> PT+
- createPredicateTruthLinks(PredicateTruthNegative.class,PredicateTruthPositive.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_DISAGREEING,localContradiction);
-
- // Non Matching Predicate Truth
- // PT+ <-> PT?
- createPredicateTruthLinks(PredicateTruthPositive.class,PredicateTruthUncertain.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_NON_MATCHING,emptyGroupLabel);
- // PT- <-> PT?
- createPredicateTruthLinks(PredicateTruthNegative.class,PredicateTruthUncertain.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_NON_MATCHING,emptyGroupLabel);
- // PT? <-> PT+
- createPredicateTruthLinks(PredicateTruthUncertain.class,PredicateTruthPositive.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_NON_MATCHING,emptyGroupLabel);
- // PT? <-> PT-
- createPredicateTruthLinks(PredicateTruthUncertain.class,PredicateTruthNegative.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_NON_MATCHING,emptyGroupLabel);
-
- }
- catch (CASException e) {
- throw new PairAnnotatorComponentException(e);
- }
- }
-
-
-
- @Override
- public String getComponentName() {
- // Name of this component that is used to identify the related configuration section
- return this.getClass().getName();
- }
-
- @Override
- public String getInstanceName() {
- // This component does not support instance configuration
- return null;
- }
-
- @Override
- public void close() throws AlignmentComponentException
- {
-
- }
-
-
- /**
- * Draw bidirectional links between all predicate truth annotation of type (TextType) in text and truth annotation of type (hypoType) in Hypothesis
- * @param textType
- * @param hypoType
- * @param confidence
- * @param linkDirection
- * @param linkInfo
- * @throws CASException
- */
- private void createPredicateTruthLinks(Class extends PredicateTruth> textType, Class extends Annotation> hypoType, double confidence,Direction linkDirection,String linkInfo,StringList linkGroupLabel) throws CASException{
-
- // get relevant annotations from text and hypothesis - use pre-recorded annotations
- Collection extends Annotation> textAnnotations = memoTextAnnots.get(textType);
- Collection extends Annotation> hypoAnnotations = memoHypoAnnots.get(hypoType);
-
- // mark links between all of the found types
- for (Annotation tAnno : textAnnotations){
- for (Annotation hAnno : hypoAnnotations){
- Token tToken = UimaUtils.selectCoveredSingle(textView, Token.class, tAnno);
- Token hToken = UimaUtils.selectCoveredSingle(hypoView, Token.class, hAnno);
- addAlignmentAnnotations(tToken,hToken, confidence, linkDirection, linkInfo, linkGroupLabel);
- }
- }
-
- }
-
- /**
- * Add an alignment link from T to H, based on the rule t->h
- * in which t is a phrase in T from index textStart to textEnd of the tokens,
- * and h is a phrase in H from index hypoStart to hypoEnd of the tokens,
- * @param textToken Token in TextView to annotate
- * @param hypoToken Token in HypoView to annotate
- * @param confidence The confidence of the rule
- * @param linkDirection The direction of the link (t to h, h to t or bidirectional).
- * @param linkInfo The relation of the rule (Wordnet synonym, Wikipedia redirect etc).
- * @param linkGroupLabel
- * @throws CASException
- */
- private void addAlignmentAnnotations(Token textToken, Token hypoToken,
- double confidence,
- Direction linkDirection,
- String linkInfo, StringList linkGroupLabel)
- throws CASException {
-
-
- // Prepare the Target instances
- Target textTarget = new Target(textView);
- Target hypoTarget = new Target(hypoView);
-
-
- // Prepare an FSArray instance and put the target annotations in it
- FSArray textAnnots = new FSArray(textView, 1);
- FSArray hypoAnnots = new FSArray(hypoView, 1);
-
- textAnnots.set(0, textToken);
- hypoAnnots.set(0, hypoToken);
-
- textTarget.setTargetAnnotations(textAnnots);
- hypoTarget.setTargetAnnotations(hypoAnnots);
-
- // Set begin and end value of the Target annotations
- textTarget.setBegin(textToken.getBegin());
- textTarget.setEnd(textToken.getEnd());
- hypoTarget.setBegin(hypoToken.getBegin());
- hypoTarget.setEnd(hypoToken.getEnd());
-
- // Add the targets to the indices
- textTarget.addToIndexes();
- hypoTarget.addToIndexes();
-
- // Mark an alignment.Link and add it to the hypothesis view
- Link link = new Link(hypoView);
- link.setTSideTarget(textTarget);
- link.setHSideTarget(hypoTarget);
-
- // Set the link direction
- link.setDirection(linkDirection);
-
- // Set strength
- link.setStrength(confidence);
-
- // Set Group label
- link.setGroupLabel(linkGroupLabel);
-
-
- // Add the link information
- link.setAlignerID(ALIGNER_ID);
- link.setAlignerVersion(ALIGNER_VERSION);
- link.setLinkInfo(linkInfo);
-
- // Mark begin and end according to the hypothesis target
- link.setBegin(hypoTarget.getBegin());
- link.setEnd(hypoTarget.getEnd());
-
- // Add to index
- link.addToIndexes();
- }
-
- /**
- * Converts a collection of string into a a Uima Stringlist
- * @param aJCas - Jcas to which to attach the string list?
- * @param aCollection - the collection to be converted
- * @return a Uima Stringlist, consisting of all the elements in aCollection
- */
- private static StringList createStringList(JCas aJCas,
- Collection aCollection)
- {
- if (aCollection.size() == 0) {
- return new EmptyStringList(aJCas);
- }
-
- NonEmptyStringList head = new NonEmptyStringList(aJCas);
- NonEmptyStringList list = head;
- Iterator i = aCollection.iterator();
- while (i.hasNext()) {
- head.setHead(i.next());
- if (i.hasNext()) {
- head.setTail(new NonEmptyStringList(aJCas));
- head = (NonEmptyStringList) head.getTail();
- }
- else {
- head.setTail(new EmptyStringList(aJCas));
- }
- }
-
- return list;
- }
-
-
-}
+package eu.excitementproject.eop.transformations.component.alignment.predicatetruthlink;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.uima.cas.CASException;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.cas.EmptyStringList;
+import org.apache.uima.jcas.cas.FSArray;
+import org.apache.uima.jcas.cas.NonEmptyStringList;
+import org.apache.uima.jcas.cas.StringList;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.uimafit.util.JCasUtil;
+
+import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token;
+import eu.excitement.type.alignment.Link;
+import eu.excitement.type.alignment.Link.Direction;
+import eu.excitement.type.alignment.Target;
+import eu.excitement.type.predicatetruth.PredicateTruth;
+import eu.excitement.type.predicatetruth.PredicateTruthNegative;
+import eu.excitement.type.predicatetruth.PredicateTruthPositive;
+import eu.excitement.type.predicatetruth.PredicateTruthUncertain;
+import eu.excitementproject.eop.common.component.alignment.AlignmentComponent;
+import eu.excitementproject.eop.common.component.alignment.AlignmentComponentException;
+import eu.excitementproject.eop.common.component.alignment.PairAnnotatorComponentException;
+import eu.excitementproject.eop.common.utilities.uima.UimaUtils;
+import eu.excitementproject.eop.lap.implbase.LAP_ImplBase;
+
+
+
+/**
+ * Produces alignment links between the text and the hypothesis,
+ * based on the predicate truth annotations
+ *
+ * Usage: align a sentence pair by calling the annotate method.
+ * When the {@linkplain Aligner} object is no longer to be used, the
+ * {@link #cleanUp()} method should be called.
+ *
+ * @author Gabi Stanovsky
+ * @since Aug 2014
+ */
+
+
+public class PredicateTruthAligner implements AlignmentComponent {
+
+ private JCas textView, hypoView;
+
+ //constant values used for aligner description
+ public static final String ALIGNER_ID = "PredicateTruth";
+ public static final String ALIGNER_VERSION = "TruthTeller_1.0";
+ public static final String ALIGNEMNT_TYPE_AGREEING_POSITIVE = "Agreeing_Positive_Predicate_Truth";
+ public static final String ALIGNEMNT_TYPE_AGREEING_NEGATIVE = "Agreeing_Negative_Predicate_Truth";
+ public static final String ALIGNEMNT_TYPE_DISAGREEING = "Disagreeing_Predicate_Truth";
+ public static final String ALIGNEMNT_TYPE_NON_MATCHING = "Non_Matching_Predicate_Truth";
+ //group labels
+ public static final String GROUP_LABEL_OPPOSITE_PREDICATE_TRUTH = "OPPOSITE_PREDICATE_TRUTH";
+ public static final String GROUP_LABEL_SAME_PREDICATE_TRUTH = "SAME_PREDICATE_TRUTH";
+ public static final String GROUP_LABEL_LOCAL_CONTRADICTION = "LOCAL_CONTRADICTION";
+ public static final String GROUP_LABEL_LOCAL_ENTAILMENT = "LOCAL_ENTAILMENT";
+
+ //(currently) constant values used for alignment links
+ private static final double ALIGNER_CONFIDENCE = 1.0;
+ private static final Direction ALIGNER_DIRECTION = Direction.Bidirection;
+
+ //store the annotations of predicate truth, for memoization
+ private Map,Collection extends Annotation>> memoTextAnnots;
+ private Map,Collection extends Annotation>> memoHypoAnnots;
+ private static final List> ptTypes = new ArrayList>(){
+ private static final long serialVersionUID = 8489900798036315449L;
+
+ {
+ add(PredicateTruthPositive.class);
+ add(PredicateTruthNegative.class);
+ add(PredicateTruthUncertain.class);
+ }};
+
+
+
+ /**
+ * default constructor
+ * set all members to null
+ */
+ public PredicateTruthAligner(){
+ textView = null;
+ hypoView = null;
+ }
+
+ @Override
+ public void annotate(JCas aJCas) throws PairAnnotatorComponentException {
+ try {
+ // create possible group labels instances for this jcas
+ StringList localEntailment = createStringList(aJCas, new ArrayList() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ add(GROUP_LABEL_SAME_PREDICATE_TRUTH);
+ add(GROUP_LABEL_LOCAL_ENTAILMENT);
+ }});
+
+ StringList localContradiction = createStringList(aJCas, new ArrayList() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ add(GROUP_LABEL_OPPOSITE_PREDICATE_TRUTH);
+ add(GROUP_LABEL_LOCAL_CONTRADICTION);
+ }});
+
+ StringList emptyGroupLabel = new EmptyStringList(aJCas);
+
+
+ // Get the text and hypothesis views
+ textView = aJCas.getView(LAP_ImplBase.TEXTVIEW);
+ hypoView = aJCas.getView(LAP_ImplBase.HYPOTHESISVIEW);
+
+ // Record annotations
+ memoTextAnnots = new HashMap,Collection extends Annotation>>();
+ memoHypoAnnots = new HashMap,Collection extends Annotation>>();
+
+ for (Class extends PredicateTruth> ptType : ptTypes){
+ memoTextAnnots.put(ptType, JCasUtil.select(textView, ptType));
+ memoHypoAnnots.put(ptType, JCasUtil.select(hypoView, ptType));
+ }
+
+
+ // add alignment links
+ // Agreeing Positive Predicate Truth
+ // PT+ <-> PT+
+ createPredicateTruthLinks(PredicateTruthPositive.class,PredicateTruthPositive.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_AGREEING_POSITIVE,localEntailment);
+
+ // Agreeing Negative Predicate Truth
+ // PT- <-> PT-
+ createPredicateTruthLinks(PredicateTruthNegative.class,PredicateTruthNegative.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_AGREEING_NEGATIVE,localEntailment);
+
+ // Disagreeing Predicate Truth
+ // PT+ <-> PT-
+ createPredicateTruthLinks(PredicateTruthPositive.class,PredicateTruthNegative.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_DISAGREEING,localContradiction);
+ // PT- <-> PT+
+ createPredicateTruthLinks(PredicateTruthNegative.class,PredicateTruthPositive.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_DISAGREEING,localContradiction);
+
+ // Non Matching Predicate Truth
+ // PT+ <-> PT?
+ createPredicateTruthLinks(PredicateTruthPositive.class,PredicateTruthUncertain.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_NON_MATCHING,emptyGroupLabel);
+ // PT- <-> PT?
+ createPredicateTruthLinks(PredicateTruthNegative.class,PredicateTruthUncertain.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_NON_MATCHING,emptyGroupLabel);
+ // PT? <-> PT+
+ createPredicateTruthLinks(PredicateTruthUncertain.class,PredicateTruthPositive.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_NON_MATCHING,emptyGroupLabel);
+ // PT? <-> PT-
+ createPredicateTruthLinks(PredicateTruthUncertain.class,PredicateTruthNegative.class, ALIGNER_CONFIDENCE, ALIGNER_DIRECTION,ALIGNEMNT_TYPE_NON_MATCHING,emptyGroupLabel);
+
+ }
+ catch (CASException e) {
+ throw new PairAnnotatorComponentException(e);
+ }
+ }
+
+
+
+ @Override
+ public String getComponentName() {
+ // Name of this component that is used to identify the related configuration section
+ return this.getClass().getName();
+ }
+
+ @Override
+ public String getInstanceName() {
+ // This component does not support instance configuration
+ return null;
+ }
+
+ @Override
+ public void close() throws AlignmentComponentException
+ {
+
+ }
+
+
+ /**
+ * Draw bidirectional links between all predicate truth annotation of type (TextType) in text and truth annotation of type (hypoType) in Hypothesis
+ * @param textType
+ * @param hypoType
+ * @param confidence
+ * @param linkDirection
+ * @param linkInfo
+ * @throws CASException
+ */
+ private void createPredicateTruthLinks(Class extends PredicateTruth> textType, Class extends Annotation> hypoType, double confidence,Direction linkDirection,String linkInfo,StringList linkGroupLabel) throws CASException{
+
+ // get relevant annotations from text and hypothesis - use pre-recorded annotations
+ Collection extends Annotation> textAnnotations = memoTextAnnots.get(textType);
+ Collection extends Annotation> hypoAnnotations = memoHypoAnnots.get(hypoType);
+
+ // mark links between all of the found types
+ for (Annotation tAnno : textAnnotations){
+ for (Annotation hAnno : hypoAnnotations){
+ Token tToken = UimaUtils.selectCoveredSingle(textView, Token.class, tAnno);
+ Token hToken = UimaUtils.selectCoveredSingle(hypoView, Token.class, hAnno);
+ addAlignmentAnnotations(tToken,hToken, confidence, linkDirection, linkInfo, linkGroupLabel);
+ }
+ }
+
+ }
+
+ /**
+ * Add an alignment link from T to H, based on the rule t->h
+ * in which t is a phrase in T from index textStart to textEnd of the tokens,
+ * and h is a phrase in H from index hypoStart to hypoEnd of the tokens,
+ * @param textToken Token in TextView to annotate
+ * @param hypoToken Token in HypoView to annotate
+ * @param confidence The confidence of the rule
+ * @param linkDirection The direction of the link (t to h, h to t or bidirectional).
+ * @param linkInfo The relation of the rule (Wordnet synonym, Wikipedia redirect etc).
+ * @param linkGroupLabel
+ * @throws CASException
+ */
+ private void addAlignmentAnnotations(Token textToken, Token hypoToken,
+ double confidence,
+ Direction linkDirection,
+ String linkInfo, StringList linkGroupLabel)
+ throws CASException {
+
+
+ // Prepare the Target instances
+ Target textTarget = new Target(textView);
+ Target hypoTarget = new Target(hypoView);
+
+
+ // Prepare an FSArray instance and put the target annotations in it
+ FSArray textAnnots = new FSArray(textView, 1);
+ FSArray hypoAnnots = new FSArray(hypoView, 1);
+
+ textAnnots.set(0, textToken);
+ hypoAnnots.set(0, hypoToken);
+
+ textTarget.setTargetAnnotations(textAnnots);
+ hypoTarget.setTargetAnnotations(hypoAnnots);
+
+ // Set begin and end value of the Target annotations
+ textTarget.setBegin(textToken.getBegin());
+ textTarget.setEnd(textToken.getEnd());
+ hypoTarget.setBegin(hypoToken.getBegin());
+ hypoTarget.setEnd(hypoToken.getEnd());
+
+ // Add the targets to the indices
+ textTarget.addToIndexes();
+ hypoTarget.addToIndexes();
+
+ // Mark an alignment.Link and add it to the hypothesis view
+ Link link = new Link(hypoView);
+ link.setTSideTarget(textTarget);
+ link.setHSideTarget(hypoTarget);
+
+ // Set the link direction
+ link.setDirection(linkDirection);
+
+ // Set strength
+ link.setStrength(confidence);
+
+ // Set Group label
+ link.setGroupLabel(linkGroupLabel);
+
+
+ // Add the link information
+ link.setAlignerID(ALIGNER_ID);
+ link.setAlignerVersion(ALIGNER_VERSION);
+ link.setLinkInfo(linkInfo);
+
+ // Mark begin and end according to the hypothesis target
+ link.setBegin(hypoTarget.getBegin());
+ link.setEnd(hypoTarget.getEnd());
+
+ // Add to index
+ link.addToIndexes();
+ }
+
+ /**
+ * Converts a collection of string into a a Uima Stringlist
+ * @param aJCas - Jcas to which to attach the string list?
+ * @param aCollection - the collection to be converted
+ * @return a Uima Stringlist, consisting of all the elements in aCollection
+ */
+ private static StringList createStringList(JCas aJCas,
+ Collection aCollection)
+ {
+ if (aCollection.size() == 0) {
+ return new EmptyStringList(aJCas);
+ }
+
+ NonEmptyStringList head = new NonEmptyStringList(aJCas);
+ NonEmptyStringList list = head;
+ Iterator i = aCollection.iterator();
+ while (i.hasNext()) {
+ head.setHead(i.next());
+ if (i.hasNext()) {
+ head.setTail(new NonEmptyStringList(aJCas));
+ head = (NonEmptyStringList) head.getTail();
+ }
+ else {
+ head.setTail(new EmptyStringList(aJCas));
+ }
+ }
+
+ return list;
+ }
+
+
+}
diff --git a/transformations/src/main/java/eu/excitementproject/eop/transformations/generic/truthteller/conll/AnnotateSentenceToConll.java b/transformations/src/main/java/eu/excitementproject/eop/transformations/generic/truthteller/conll/AnnotateSentenceToConll.java
index 68b1d09b..9d9e4443 100644
--- a/transformations/src/main/java/eu/excitementproject/eop/transformations/generic/truthteller/conll/AnnotateSentenceToConll.java
+++ b/transformations/src/main/java/eu/excitementproject/eop/transformations/generic/truthteller/conll/AnnotateSentenceToConll.java
@@ -1,250 +1,250 @@
-/**
- *
- */
-package eu.excitementproject.eop.transformations.generic.truthteller.conll;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Vector;
-
-import org.apache.log4j.BasicConfigurator;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-
-import eu.excitementproject.eop.common.representation.parse.tree.dependency.basic.BasicNode;
-import eu.excitementproject.eop.common.utilities.Utils;
-import eu.excitementproject.eop.common.utilities.configuration.ConfigurationException;
-import eu.excitementproject.eop.common.utilities.configuration.ConfigurationFile;
-import eu.excitementproject.eop.common.utilities.configuration.ConfigurationFileDuplicateKeyException;
-import eu.excitementproject.eop.common.utilities.configuration.ConfigurationParams;
-import eu.excitementproject.eop.lap.biu.en.parser.ParserRunException;
-import eu.excitementproject.eop.lap.biu.en.parser.easyfirst.EasyFirstParser;
-import eu.excitementproject.eop.lap.biu.en.sentencesplit.LingPipeSentenceSplitter;
-import eu.excitementproject.eop.lap.biu.sentencesplit.SentenceSplitter;
-import eu.excitementproject.eop.lap.biu.sentencesplit.SentenceSplitterException;
-import eu.excitementproject.eop.transformations.generic.truthteller.AnnotatorException;
-import eu.excitementproject.eop.transformations.generic.truthteller.DefaultSentenceAnnotator;
-import eu.excitementproject.eop.transformations.representation.ExtendedNode;
-import eu.excitementproject.eop.transformations.utilities.TransformationsConfigurationParametersNames;
-import eu.excitementproject.eop.transformations.utilities.parsetreeutils.TreeUtilities;
-
-/**
- * @author Amnon Lotan
- *
- * @since Jul 18, 2012
- */
-public class AnnotateSentenceToConll {
-
- public static final String INPUT_FILE_INDICATOR = "-f";
-
- private static Logger logger = null;
-
- private static AnnotatedConllStringConverter CONLL_CONVERTER = new AnnotatedConllStringConverter();
- private static SentenceSplitter SENTENCE_SPLITTER = new LingPipeSentenceSplitter();
- private EasyFirstParser parser;
- private DefaultSentenceAnnotator annotator;
- private final File conllOutputFolder;
-
- private ConfigurationParams annotationParams = null;
-
- /**
- * Ctor
- * @throws ConfigurationException
- * @throws ConllConverterException
- */
- public AnnotateSentenceToConll(ConfigurationFile confFile) throws ConfigurationException, ConllConverterException {
-
- confFile.setExpandingEnvironmentVariables(true);
- annotationParams = confFile.getModuleConfiguration(TransformationsConfigurationParametersNames.TRUTH_TELLER_MODULE_NAME);
-
- try {
- annotator = new DefaultSentenceAnnotator(annotationParams);
-
- String posTaggerString = annotationParams.get(TransformationsConfigurationParametersNames.PREPROCESS_EASYFIRST);
- String easyFirstHost = annotationParams.get(TransformationsConfigurationParametersNames.PREPROCESS_EASYFIRST_HOST);
- int easyFirstPort = annotationParams.getInt(TransformationsConfigurationParametersNames.PREPROCESS_EASYFIRST_PORT);
- parser = new EasyFirstParser(easyFirstHost, easyFirstPort, posTaggerString);
- parser.init();
- } catch (Exception e) {
- throw new ConllConverterException("see nested", e);
- }
-
- String conllOutputFolderPath = annotationParams.get(TransformationsConfigurationParametersNames.CONLL_FORMAT_OUTPUT_DIRECTORY);
- conllOutputFolder = new File(conllOutputFolderPath);
- conllOutputFolder.mkdirs();
- }
-
-
- /**
- * Get some text, sentence split it, and return
- * @param sentence
- * @return
- * @throws ConllConverterException
- */
- public String textToAnnotatedConllFiles(String sentence) throws ConllConverterException
- {
- ExtendedNode annotatedSentece = annotateSentece(sentence);
- String conllString = AnnotatedTreeToConllCoverter.treeToConll(annotatedSentece , CONLL_CONVERTER);
- return conllString;
- }
-
- /**
- * Get a single sentence, annotate it, and return its string CoNLL representation.
- * @param sentence
- * @return
- * @throws ConllConverterException
- */
- public String sentenceToAnnotatedConllString(String sentence) throws ConllConverterException
- {
- ExtendedNode annotatedSentece = annotateSentece(sentence);
- String conllString = AnnotatedTreeToConllCoverter.treeToConll(annotatedSentece , CONLL_CONVERTER);
- return conllString;
- }
-
-
- public List getSentencesToAnnotate(String inputFileName) throws ConfigurationException, FileNotFoundException, IOException
- {
- List sentences = new LinkedList