<commit_before>package de.unistuttgart.quadrama.core;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;

import de.unistuttgart.ims.drama.api.Figure;
import de.unistuttgart.ims.drama.api.Speaker;
import de.unistuttgart.ims.drama.api.Speech;
import de.unistuttgart.ims.drama.api.Utterance;

public class DramaUtil {
	public static Collection<Speech> getSpeeches(JCas jcas, Figure figure) {
		List<Speech> ret = new LinkedList<Speech>();
		for (Utterance u : JCasUtil.select(jcas, Utterance.class)) {
			Speaker sp;
			try {
				sp = JCasUtil.selectCovered(jcas, Speaker.class, u).get(0);
			} catch (Exception e) {
				continue;
			}
			if (sp != null && sp.getFigure() == figure) {
				ret.addAll(JCasUtil.selectCovered(jcas, Speech.class, u));
			}
		}
		return ret;
	}

	public static Collection<Utterance> selectFullUtterances(JCas jcas) {
		final Iterator<Utterance> baseIterator = JCasUtil.iterator(jcas, Utterance.class);

		List<Utterance> fullUtterances = new ArrayList<Utterance>();
		while (baseIterator.hasNext()) {
			Utterance utt = baseIterator.next();
			if (!JCasUtil.selectCovered(jcas, Speaker.class, utt).isEmpty()
					&& JCasUtil.selectCovered(jcas, Speaker.class, utt).get(0).getFigure() != null)
				fullUtterances.add(utt);
		}
		return fullUtterances;

	}
}<commit_msg>added method to retrieve the speaker in an utterance<commit_after>package de.unistuttgart.quadrama.core;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;

import de.unistuttgart.ims.drama.api.Figure;
import de.unistuttgart.ims.drama.api.Speaker;
import de.unistuttgart.ims.drama.api.Speech;
import de.unistuttgart.ims.drama.api.Utterance;

public class DramaUtil {
	public static Collection<Speech> getSpeeches(JCas jcas, Figure figure) {
		List<Speech> ret = new LinkedList<Speech>();
		for (Utterance u : JCasUtil.select(jcas, Utterance.class)) {
			Speaker sp;
			try {
				sp = JCasUtil.selectCovered(jcas, Speaker.class, u).get(0);
			} catch (Exception e) {
				continue;
			}
			if (sp != null && sp.getFigure() == figure) {
				ret.addAll(JCasUtil.selectCovered(jcas, Speech.class, u));
			}
		}
		return ret;
	}

	public static Speaker getSpeaker(Utterance utterance) {
		try {
			return JCasUtil.selectCovered(Speaker.class, utterance).get(0);
		} catch (Exception e) {
			return null;
		}
	}

	public static Collection<Utterance> selectFullUtterances(JCas jcas) {
		final Iterator<Utterance> baseIterator = JCasUtil.iterator(jcas, Utterance.class);

		List<Utterance> fullUtterances = new ArrayList<Utterance>();
		while (baseIterator.hasNext()) {
			Utterance utt = baseIterator.next();
			if (!JCasUtil.selectCovered(jcas, Speaker.class, utt).isEmpty()
					&& JCasUtil.selectCovered(jcas, Speaker.class, utt).get(0).getFigure() != null)
				fullUtterances.add(utt);
		}
		return fullUtterances;

	}
}
{'fraction_non_alphanumeric': 0.1306981192221868, 'fraction_numerical': 0.0015938795027095952, 'mean_word_length': 4.593582887700535, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '144576', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1123, 'n_words': 210}