// Path: germaner/src/main/java/de/tu/darmstadt/lt/ner/types/GoldNamedEntity.java
// public class GoldNamedEntity extends Annotation {
//   /** @generated
//    * @ordered 
//    */
//   @SuppressWarnings ("hiding")
//   public final static int typeIndexID = JCasRegistry.register(GoldNamedEntity.class);
//   /** @generated
//    * @ordered 
//    */
//   @SuppressWarnings ("hiding")
//   public final static int type = typeIndexID;
//   /** @generated
//    * @return index of the type  
//    */
//   @Override
//   public              int getTypeIndexID() {return typeIndexID;}
//  
//   /** Never called.  Disable default constructor
//    * @generated */
//   protected GoldNamedEntity() {/* intentionally empty block */}
//     
//   /** Internal - constructor used by generator 
//    * @generated
//    * @param addr low level Feature Structure reference
//    * @param type the type of this Feature Structure 
//    */
//   public GoldNamedEntity(int addr, TOP_Type type) {
//     super(addr, type);
//     readObject();
//   }
//   
//   /** @generated
//    * @param jcas JCas to which this Feature Structure belongs 
//    */
//   public GoldNamedEntity(JCas jcas) {
//     super(jcas);
//     readObject();   
//   } 
// 
//   /** @generated
//    * @param jcas JCas to which this Feature Structure belongs
//    * @param begin offset to the begin spot in the SofA
//    * @param end offset to the end spot in the SofA 
//   */  
//   public GoldNamedEntity(JCas jcas, int begin, int end) {
//     super(jcas);
//     setBegin(begin);
//     setEnd(end);
//     readObject();
//   }   
// 
//   /** 
//    * <!-- begin-user-doc -->
//    * Write your own initialization here
//    * <!-- end-user-doc -->
//    *
//    * @generated modifiable 
//    */
//   private void readObject() {/*default - does nothing empty block */}
//      
//  
//     
//   //*--------------*
//   //* Feature: NamedEntityType
// 
//   /** getter for NamedEntityType - gets 
//    * @generated
//    * @return value of the feature 
//    */
//   public String getNamedEntityType() {
//     if (GoldNamedEntity_Type.featOkTst && ((GoldNamedEntity_Type)jcasType).casFeat_NamedEntityType == null)
//       jcasType.jcas.throwFeatMissing("NamedEntityType", "de.tu.darmstadt.lt.ner.types.GoldNamedEntity");
//     return jcasType.ll_cas.ll_getStringValue(addr, ((GoldNamedEntity_Type)jcasType).casFeatCode_NamedEntityType);}
//     
//   /** setter for NamedEntityType - sets  
//    * @generated
//    * @param v value to set into the feature 
//    */
//   public void setNamedEntityType(String v) {
//     if (GoldNamedEntity_Type.featOkTst && ((GoldNamedEntity_Type)jcasType).casFeat_NamedEntityType == null)
//       jcasType.jcas.throwFeatMissing("NamedEntityType", "de.tu.darmstadt.lt.ner.types.GoldNamedEntity");
//     jcasType.ll_cas.ll_setStringValue(addr, ((GoldNamedEntity_Type)jcasType).casFeatCode_NamedEntityType, v);}    
//   }


import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.fit.component.JCasConsumer_ImplBase;
import org.apache.uima.fit.descriptor.ConfigurationParameter;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;
import org.apache.uima.util.Level;
import de.tu.darmstadt.lt.ner.types.GoldNamedEntity;
import de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity;
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence;

                nodOutputWriter = new FileWriter(nodOutputFile);
            }
            int sentenceIndex = 0;

            List<Sentence> sentences = new ArrayList<Sentence>(sentencesNER.keySet());
            // sort sentences by sentence
            Collections.sort(sentences, new Comparator<Sentence>()
            {
                @Override
                public int compare(Sentence arg0, Sentence arg1)
                {
                    return arg0.getBegin() - arg1.getBegin();
                }
            });
            for (Sentence sentence : sentences) {

                List<String> personSb = new ArrayList<String>();
                List<String> orgSb = new ArrayList<String>();
                String prevNeType = "O";
                String namedEntity = "";

                for (NamedEntity neAnnotation : sentencesNER.get(sentence)) {

                    String text = neAnnotation.getCoveredText().replace(" ", "");
                    String neType = neAnnotation.getValue();

                    StringBuilder sb = new StringBuilder();
                    sb.append(text);
                    sb.append(" ");
                    if (isGold) {

// Path: germaner/src/main/java/de/tu/darmstadt/lt/ner/types/GoldNamedEntity.java
// public class GoldNamedEntity extends Annotation {
//   /** @generated
//    * @ordered 
//    */
//   @SuppressWarnings ("hiding")
//   public final static int typeIndexID = JCasRegistry.register(GoldNamedEntity.class);
//   /** @generated
//    * @ordered 
//    */
//   @SuppressWarnings ("hiding")
//   public final static int type = typeIndexID;
//   /** @generated
//    * @return index of the type  
//    */
//   @Override
//   public              int getTypeIndexID() {return typeIndexID;}
//  
//   /** Never called.  Disable default constructor
//    * @generated */
//   protected GoldNamedEntity() {/* intentionally empty block */}
//     
//   /** Internal - constructor used by generator 
//    * @generated
//    * @param addr low level Feature Structure reference
//    * @param type the type of this Feature Structure 
//    */
//   public GoldNamedEntity(int addr, TOP_Type type) {
//     super(addr, type);
//     readObject();
//   }
//   
//   /** @generated
//    * @param jcas JCas to which this Feature Structure belongs 
//    */
//   public GoldNamedEntity(JCas jcas) {
//     super(jcas);
//     readObject();   
//   } 
// 
//   /** @generated
//    * @param jcas JCas to which this Feature Structure belongs
//    * @param begin offset to the begin spot in the SofA
//    * @param end offset to the end spot in the SofA 
//   */  
//   public GoldNamedEntity(JCas jcas, int begin, int end) {
//     super(jcas);
//     setBegin(begin);
//     setEnd(end);
//     readObject();
//   }   
// 
//   /** 
//    * <!-- begin-user-doc -->
//    * Write your own initialization here
//    * <!-- end-user-doc -->
//    *
//    * @generated modifiable 
//    */
//   private void readObject() {/*default - does nothing empty block */}
//      
//  
//     
//   //*--------------*
//   //* Feature: NamedEntityType
// 
//   /** getter for NamedEntityType - gets 
//    * @generated
//    * @return value of the feature 
//    */
//   public String getNamedEntityType() {
//     if (GoldNamedEntity_Type.featOkTst && ((GoldNamedEntity_Type)jcasType).casFeat_NamedEntityType == null)
//       jcasType.jcas.throwFeatMissing("NamedEntityType", "de.tu.darmstadt.lt.ner.types.GoldNamedEntity");
//     return jcasType.ll_cas.ll_getStringValue(addr, ((GoldNamedEntity_Type)jcasType).casFeatCode_NamedEntityType);}
//     
//   /** setter for NamedEntityType - sets  
//    * @generated
//    * @param v value to set into the feature 
//    */
//   public void setNamedEntityType(String v) {
//     if (GoldNamedEntity_Type.featOkTst && ((GoldNamedEntity_Type)jcasType).casFeat_NamedEntityType == null)
//       jcasType.jcas.throwFeatMissing("NamedEntityType", "de.tu.darmstadt.lt.ner.types.GoldNamedEntity");
//     jcasType.ll_cas.ll_setStringValue(addr, ((GoldNamedEntity_Type)jcasType).casFeatCode_NamedEntityType, v);}    
//   }


// Path: germaner/src/main/java/de/tu/darmstadt/lt/ner/writer/EvaluatedNERWriter.java
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.fit.component.JCasConsumer_ImplBase;
import org.apache.uima.fit.descriptor.ConfigurationParameter;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;
import org.apache.uima.util.Level;
import de.tu.darmstadt.lt.ner.types.GoldNamedEntity;
import de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity;
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence;

                nodOutputWriter = new FileWriter(nodOutputFile);
            }
            int sentenceIndex = 0;

            List<Sentence> sentences = new ArrayList<Sentence>(sentencesNER.keySet());
            // sort sentences by sentence
            Collections.sort(sentences, new Comparator<Sentence>()
            {
                @Override
                public int compare(Sentence arg0, Sentence arg1)
                {
                    return arg0.getBegin() - arg1.getBegin();
                }
            });
            for (Sentence sentence : sentences) {

                List<String> personSb = new ArrayList<String>();
                List<String> orgSb = new ArrayList<String>();
                String prevNeType = "O";
                String namedEntity = "";

                for (NamedEntity neAnnotation : sentencesNER.get(sentence)) {

                    String text = neAnnotation.getCoveredText().replace(" ", "");
                    String neType = neAnnotation.getValue();

                    StringBuilder sb = new StringBuilder();
                    sb.append(text);
                    sb.append(" ");
                    if (isGold) {

                        sb.append(JCasUtil.selectCovered(jCas, GoldNamedEntity.class, neAnnotation)
