// Path: src/main/java/de/tudarmstadt/ukp/dkpro/argumentation/crossdomainclaims/features/syntactic/utils/PunctuationSequenceMetaCollector.java
// public class PunctuationSequenceMetaCollector extends FreqDistBasedMetaCollector {
//     
//     public static final String PARAM_PUNCTUATION_SEQUENCE_FD_FILE = "punctSequenceFdFile";
//     @ConfigurationParameter(name = PARAM_PUNCTUATION_SEQUENCE_FD_FILE, mandatory = true)
//     private File punctSequenceFdFile;
//     
//     @Override
//     public void initialize(UimaContext context) throws ResourceInitializationException {
//         super.initialize(context);
//     }
//     
//     @Override
//     public void process(JCas jcas) throws AnalysisEngineProcessException {
//     	Collection<Sentence> sentences = JCasUtil.select(jcas, Sentence.class);
//     	for (Sentence sentence : sentences) {
//     		String sequences = createPunctuationSequence(sentence.getCoveredText());
//     		fd.addSample(sequences, 1);
// 		}
//     }
// 
//     @Override
//     public Map<String, String> getParameterKeyPairs() {
//         Map<String, String> mapping = new HashMap<String, String>();
//         mapping.put(PunctuationSequenceUFE.PARAM_PUNCTUATION_SEQUENCE_FD_FILE, PARAM_PUNCTUATION_SEQUENCE_FD_FILE);
//         return mapping;
//     }
// 
//     @Override
//     protected File getFreqDistFile() {
//         return punctSequenceFdFile;
//     }
//     
// 	public static String createPunctuationSequence(String text){
// 		// normalize quotes
// 		String normalized = text.replaceAll("'","\"");
// 		normalized = normalized.replaceAll("`", "\"");
// 		normalized = normalized.replaceAll("´", "\"");
// 		
// 		Matcher punctPattern = Pattern.compile("\\p{Punct}").matcher(normalized);
// 		StringBuilder pattern = new StringBuilder();
// 		
// 		while (punctPattern.find()) {
// 			pattern.append(normalized.charAt(punctPattern.start()));
// 		}
// 		return pattern.toString();
// 	}
// }


import org.apache.uima.resource.ResourceSpecifier;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import de.tudarmstadt.ukp.dkpro.argumentation.crossdomainclaims.features.syntactic.utils.PunctuationSequenceMetaCollector;
import de.tudarmstadt.ukp.dkpro.core.api.frequency.util.FrequencyDistribution;
import de.tudarmstadt.ukp.dkpro.tc.api.exception.TextClassificationException;
import de.tudarmstadt.ukp.dkpro.tc.api.features.ClassificationUnitFeatureExtractor;
import de.tudarmstadt.ukp.dkpro.tc.api.features.Feature;
import de.tudarmstadt.ukp.dkpro.tc.api.features.FeatureExtractorResource_ImplBase;
import de.tudarmstadt.ukp.dkpro.tc.api.features.meta.MetaCollector;
import de.tudarmstadt.ukp.dkpro.tc.api.features.meta.MetaDependent;
import de.tudarmstadt.ukp.dkpro.tc.api.type.TextClassificationUnit;
import org.apache.uima.fit.descriptor.ConfigurationParameter;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceInitializationException;
    @Override
    public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationException {
    	if (!super.initialize(aSpecifier, aAdditionalParams)) {
            return false;
        }
    	
    	FrequencyDistribution<String> trainingFD;
    	try {
            trainingFD = new FrequencyDistribution<String>();
            trainingFD.load(new File(punctSequenceFdFile));
        } catch (Exception e) {
            throw new ResourceInitializationException(e);
        }
        
    	topKPunctuationSequences = new FrequencyDistribution<String>();
   
		for (String sample : trainingFD.getKeys()) {
			topKPunctuationSequences.addSample(sample, trainingFD.getCount(sample));
		}
    	
    	getLogger().info("Loaded " + topKPunctuationSequences.getKeys().size() + " punctuation sequences.");
    	return true;
    }

	@Override
	public List<Feature> extract(JCas view, TextClassificationUnit classificationUnit)
			throws TextClassificationException {
	    
		String text = classificationUnit.getCoveredText();
		List<Feature> features = new ArrayList<Feature>();
// Path: src/main/java/de/tudarmstadt/ukp/dkpro/argumentation/crossdomainclaims/features/syntactic/utils/PunctuationSequenceMetaCollector.java
// public class PunctuationSequenceMetaCollector extends FreqDistBasedMetaCollector {
//     
//     public static final String PARAM_PUNCTUATION_SEQUENCE_FD_FILE = "punctSequenceFdFile";
//     @ConfigurationParameter(name = PARAM_PUNCTUATION_SEQUENCE_FD_FILE, mandatory = true)
//     private File punctSequenceFdFile;
//     
//     @Override
//     public void initialize(UimaContext context) throws ResourceInitializationException {
//         super.initialize(context);
//     }
//     
//     @Override
//     public void process(JCas jcas) throws AnalysisEngineProcessException {
//     	Collection<Sentence> sentences = JCasUtil.select(jcas, Sentence.class);
//     	for (Sentence sentence : sentences) {
//     		String sequences = createPunctuationSequence(sentence.getCoveredText());
//     		fd.addSample(sequences, 1);
// 		}
//     }
// 
//     @Override
//     public Map<String, String> getParameterKeyPairs() {
//         Map<String, String> mapping = new HashMap<String, String>();
//         mapping.put(PunctuationSequenceUFE.PARAM_PUNCTUATION_SEQUENCE_FD_FILE, PARAM_PUNCTUATION_SEQUENCE_FD_FILE);
//         return mapping;
//     }
// 
//     @Override
//     protected File getFreqDistFile() {
//         return punctSequenceFdFile;
//     }
//     
// 	public static String createPunctuationSequence(String text){
// 		// normalize quotes
// 		String normalized = text.replaceAll("'","\"");
// 		normalized = normalized.replaceAll("`", "\"");
// 		normalized = normalized.replaceAll("´", "\"");
// 		
// 		Matcher punctPattern = Pattern.compile("\\p{Punct}").matcher(normalized);
// 		StringBuilder pattern = new StringBuilder();
// 		
// 		while (punctPattern.find()) {
// 			pattern.append(normalized.charAt(punctPattern.start()));
// 		}
// 		return pattern.toString();
// 	}
// }


// Path: src/main/java/de/tudarmstadt/ukp/dkpro/argumentation/crossdomainclaims/features/syntactic/PunctuationSequenceUFE.java
import org.apache.uima.resource.ResourceSpecifier;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import de.tudarmstadt.ukp.dkpro.argumentation.crossdomainclaims.features.syntactic.utils.PunctuationSequenceMetaCollector;
import de.tudarmstadt.ukp.dkpro.core.api.frequency.util.FrequencyDistribution;
import de.tudarmstadt.ukp.dkpro.tc.api.exception.TextClassificationException;
import de.tudarmstadt.ukp.dkpro.tc.api.features.ClassificationUnitFeatureExtractor;
import de.tudarmstadt.ukp.dkpro.tc.api.features.Feature;
import de.tudarmstadt.ukp.dkpro.tc.api.features.FeatureExtractorResource_ImplBase;
import de.tudarmstadt.ukp.dkpro.tc.api.features.meta.MetaCollector;
import de.tudarmstadt.ukp.dkpro.tc.api.features.meta.MetaDependent;
import de.tudarmstadt.ukp.dkpro.tc.api.type.TextClassificationUnit;
import org.apache.uima.fit.descriptor.ConfigurationParameter;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceInitializationException;

    @Override
    public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationException {
    	if (!super.initialize(aSpecifier, aAdditionalParams)) {
            return false;
        }
    	
    	FrequencyDistribution<String> trainingFD;
    	try {
            trainingFD = new FrequencyDistribution<String>();
            trainingFD.load(new File(punctSequenceFdFile));
        } catch (Exception e) {
            throw new ResourceInitializationException(e);
        }
        
    	topKPunctuationSequences = new FrequencyDistribution<String>();
   
		for (String sample : trainingFD.getKeys()) {
			topKPunctuationSequences.addSample(sample, trainingFD.getCount(sample));
		}
    	
    	getLogger().info("Loaded " + topKPunctuationSequences.getKeys().size() + " punctuation sequences.");
    	return true;
    }

	@Override
	public List<Feature> extract(JCas view, TextClassificationUnit classificationUnit)
			throws TextClassificationException {
	    
		String text = classificationUnit.getCoveredText();
		List<Feature> features = new ArrayList<Feature>();
		String unitSequence = PunctuationSequenceMetaCollector.createPunctuationSequence(text);