// Path: src/main/java/de/tudarmstadt/ukp/dkpro/argumentation/crossdomainclaims/utils/ArgUtils.java
// public class ArgUtils {
// 
// 	
// 	public static String getID(String s) {
// 		String[] tmp = s.split("/");
// 		return tmp[tmp.length-1].replace(".xmi","").replace(".bin", "");
// 	}
// 	
// 	
// 	public static String getID(File f) {
// 		return getID(f.getName());
// 	}
// 	
// 	
// 	public static boolean isClaim(Sentence s, JCas cas) {
// 		return selectOverlapping(Claim.class, s, cas).size()>0 || selectOverlapping(MajorClaim.class, s, cas).size()>0;
// 	}
// 	
// 	
// 	public static boolean isPremise(Sentence s, JCas cas) {
// 		return selectOverlapping(Premise.class, s, cas).size()>0;
// 	}
// 	
// 	
// 	public static <T extends TOP> List<T> selectOverlapping(Class<T> type,Annotation annotation, JCas jCas) {
//         Collection<T> allAnnotations = JCasUtil.select(jCas, type);
// 
//         List<T> result = new ArrayList<T>();
// 
//         for (T a : allAnnotations) {
//             if ((a instanceof Annotation) && (doOverlap(annotation, (Annotation) a))) {
//                 result.add(a);
//             }
//         }
// 
//         return result;
//     }
// 	
// 	 
// 	public static <T extends Annotation> boolean doOverlap(final T anno1, final T anno2) {
// 		return anno1.getEnd() > anno2.getBegin() && anno1.getBegin() < anno2.getEnd();
// 	}
// 	
// 	
// 	public static JCas readCas(File f) throws ResourceInitializationException, SAXException, IOException, CASException {
// 		CAS loadedCas = CasCreationUtils.createCas(TypeSystemDescriptionFactory.createTypeSystemDescription(), null, null); 
// 		FileInputStream in = new FileInputStream(f); 
// 		XmiCasDeserializer.deserialize(in, loadedCas);
// 		IOUtils.closeQuietly(in);
// 		return loadedCas.getJCas();
// 	}
// 	
// 	public static void writeFile(String fileName, String content) throws Exception {
// 		BufferedWriter br = new BufferedWriter(new FileWriter(new File(fileName)));
// 		br.write(content);
// 		br.close();
// 	}
// 	
// 	
// }


import org.apache.uima.jcas.JCas;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.*;
import de.tudarmstadt.ukp.dkpro.argumentation.crossdomainclaims.utils.ArgUtils;
import de.tudarmstadt.ukp.dkpro.argumentation.io.writer.ArgumentDumpWriter;
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence;
import de.tudarmstadt.ukp.dkpro.core.io.xmi.XmiReader;
import org.apache.commons.io.FileUtils;
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.factory.AnalysisEngineFactory;
import org.apache.uima.fit.factory.CollectionReaderFactory;
import org.apache.uima.fit.pipeline.SimplePipeline;
import org.apache.uima.fit.util.JCasUtil;
/*
 * Copyright 2017
 * Ubiquitous Knowledge Processing (UKP) Lab
 * Technische Universität Darmstadt
 *
 * Licensed 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 de.tudarmstadt.ukp.dkpro.argumentation.crossdomainclaims.statistics;



/**
 * @author Ivan Habernal
 */
public class ClaimExamplesExplorer
        extends JCasConsumer_ImplBase
{
    public static final String PARAM_RANDOM_CLAIMS_COUNT = "randomClaimsCount";
    @ConfigurationParameter(name = PARAM_RANDOM_CLAIMS_COUNT, defaultValue = "50")
    int randomClaimsCount;

    public static final String PARAM_OUTPUT_FILE = "outputFile";
    @ConfigurationParameter(name = PARAM_OUTPUT_FILE)
    File outputFile;

    /**
     * Random for reproducibility
     */
    Random random = new Random(1234);

    SortedSet<String> allClaims = new TreeSet<>();

    @Override
    public void process(JCas aJCas)
            throws AnalysisEngineProcessException
    {
        for (Sentence sentence : JCasUtil.select(aJCas, Sentence.class)) {
// Path: src/main/java/de/tudarmstadt/ukp/dkpro/argumentation/crossdomainclaims/utils/ArgUtils.java
// public class ArgUtils {
// 
// 	
// 	public static String getID(String s) {
// 		String[] tmp = s.split("/");
// 		return tmp[tmp.length-1].replace(".xmi","").replace(".bin", "");
// 	}
// 	
// 	
// 	public static String getID(File f) {
// 		return getID(f.getName());
// 	}
// 	
// 	
// 	public static boolean isClaim(Sentence s, JCas cas) {
// 		return selectOverlapping(Claim.class, s, cas).size()>0 || selectOverlapping(MajorClaim.class, s, cas).size()>0;
// 	}
// 	
// 	
// 	public static boolean isPremise(Sentence s, JCas cas) {
// 		return selectOverlapping(Premise.class, s, cas).size()>0;
// 	}
// 	
// 	
// 	public static <T extends TOP> List<T> selectOverlapping(Class<T> type,Annotation annotation, JCas jCas) {
//         Collection<T> allAnnotations = JCasUtil.select(jCas, type);
// 
//         List<T> result = new ArrayList<T>();
// 
//         for (T a : allAnnotations) {
//             if ((a instanceof Annotation) && (doOverlap(annotation, (Annotation) a))) {
//                 result.add(a);
//             }
//         }
// 
//         return result;
//     }
// 	
// 	 
// 	public static <T extends Annotation> boolean doOverlap(final T anno1, final T anno2) {
// 		return anno1.getEnd() > anno2.getBegin() && anno1.getBegin() < anno2.getEnd();
// 	}
// 	
// 	
// 	public static JCas readCas(File f) throws ResourceInitializationException, SAXException, IOException, CASException {
// 		CAS loadedCas = CasCreationUtils.createCas(TypeSystemDescriptionFactory.createTypeSystemDescription(), null, null); 
// 		FileInputStream in = new FileInputStream(f); 
// 		XmiCasDeserializer.deserialize(in, loadedCas);
// 		IOUtils.closeQuietly(in);
// 		return loadedCas.getJCas();
// 	}
// 	
// 	public static void writeFile(String fileName, String content) throws Exception {
// 		BufferedWriter br = new BufferedWriter(new FileWriter(new File(fileName)));
// 		br.write(content);
// 		br.close();
// 	}
// 	
// 	
// }


// Path: src/main/java/de/tudarmstadt/ukp/dkpro/argumentation/crossdomainclaims/statistics/ClaimExamplesExplorer.java
import org.apache.uima.jcas.JCas;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.*;
import de.tudarmstadt.ukp.dkpro.argumentation.crossdomainclaims.utils.ArgUtils;
import de.tudarmstadt.ukp.dkpro.argumentation.io.writer.ArgumentDumpWriter;
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence;
import de.tudarmstadt.ukp.dkpro.core.io.xmi.XmiReader;
import org.apache.commons.io.FileUtils;
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.factory.AnalysisEngineFactory;
import org.apache.uima.fit.factory.CollectionReaderFactory;
import org.apache.uima.fit.pipeline.SimplePipeline;
import org.apache.uima.fit.util.JCasUtil;

/*
 * Copyright 2017
 * Ubiquitous Knowledge Processing (UKP) Lab
 * Technische Universität Darmstadt
 *
 * Licensed 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 de.tudarmstadt.ukp.dkpro.argumentation.crossdomainclaims.statistics;



/**
 * @author Ivan Habernal
 */
public class ClaimExamplesExplorer
        extends JCasConsumer_ImplBase
{
    public static final String PARAM_RANDOM_CLAIMS_COUNT = "randomClaimsCount";
    @ConfigurationParameter(name = PARAM_RANDOM_CLAIMS_COUNT, defaultValue = "50")
    int randomClaimsCount;

    public static final String PARAM_OUTPUT_FILE = "outputFile";
    @ConfigurationParameter(name = PARAM_OUTPUT_FILE)
    File outputFile;

    /**
     * Random for reproducibility
     */
    Random random = new Random(1234);

    SortedSet<String> allClaims = new TreeSet<>();

    @Override
    public void process(JCas aJCas)
            throws AnalysisEngineProcessException
    {
        for (Sentence sentence : JCasUtil.select(aJCas, Sentence.class)) {
            if (ArgUtils.isClaim(sentence, aJCas)) {