<commit_before>package edu.cmu.ml.rtw.generic.data.feature.fn;

import java.util.Collection;

import edu.cmu.ml.rtw.generic.data.Context;
import edu.cmu.ml.rtw.generic.data.annotation.nlp.TokenSpan;
import edu.cmu.ml.rtw.generic.parse.AssignmentList;
import edu.cmu.ml.rtw.generic.parse.Obj;

/**
 * FnSentencePosition takes a collection of token spans and computes
 * their positions within their sentences
 * 
 * @author <NAME>
 *
 */
public class FnSentencePosition extends Fn<TokenSpan, String> {
	public enum Position {
		START,
		END,
		MIDDLE,
		ALL
	}
	
	private String[] parameterNames = {  };
	
	public FnSentencePosition() {
		
	}
	
	public FnSentencePosition(Context context) {
	}

	@Override
	public String[] getParameterNames() {
		return this.parameterNames;
	}

	@Override
	public Obj getParameterValue(String parameter) {
		return null;
	}

	@Override
	public boolean setParameterValue(String parameter, Obj parameterValue) {
		return false;
	}

	@Override
	public <C extends Collection<String>> C compute(Collection<TokenSpan> input, C output) {
		for (TokenSpan tokenSpan : input) {
			int sentenceTokenCount = tokenSpan.getDocument().getSentenceTokenCount(tokenSpan.getSentenceIndex());
			if (tokenSpan.getStartTokenIndex() == 0 
					&& tokenSpan.getEndTokenIndex() == sentenceTokenCount)
				output.add(Position.ALL.toString());
			else if (tokenSpan.getStartTokenIndex() == 0)
				output.add(Position.START.toString());
			else if (tokenSpan.getEndTokenIndex() == sentenceTokenCount)
				output.add(Position.END.toString());
			else
				output.add(Position.MIDDLE.toString());<commit_msg>Fixed bug<commit_after>package edu.cmu.ml.rtw.generic.data.feature.fn;

import java.util.Collection;

import edu.cmu.ml.rtw.generic.data.Context;
import edu.cmu.ml.rtw.generic.data.annotation.nlp.TokenSpan;
import edu.cmu.ml.rtw.generic.parse.AssignmentList;
import edu.cmu.ml.rtw.generic.parse.Obj;

/**
 * FnSentencePosition takes a collection of token spans and computes
 * their positions within their sentences
 * 
 * @author <NAME>
 *
 */
public class FnSentencePosition extends Fn<TokenSpan, String> {
	public enum Position {
		START,
		END,
		MIDDLE,
		ALL,
		NONE
	}
	
	private String[] parameterNames = {  };
	
	public FnSentencePosition() {
		
	}
	
	public FnSentencePosition(Context context) {
	}

	@Override
	public String[] getParameterNames() {
		return this.parameterNames;
	}

	@Override
	public Obj getParameterValue(String parameter) {
		return null;
	}

	@Override
	public boolean setParameterValue(String parameter, Obj parameterValue) {
		return false;
	}

	@Override
	public <C extends Collection<String>> C compute(Collection<TokenSpan> input, C output) {
		for (TokenSpan tokenSpan : input) {
			if (tokenSpan.getSentenceIndex() < 0) {
				output.add(Position.NONE.toString());
				continue;
			}
				
			int sentenceTokenCount = tokenSpan.getDocument().getSentenceTokenCount(tokenSpan.getSentenceIndex());
			if (tokenSpan.getStartTokenIndex() == 0 
					&& tokenSpan.getEndTokenIndex() == sentenceTokenCount)
				output.add(Position.ALL.toString());
			else if (tokenSpan.getStartTokenIndex() == 0)
				output.add(Position.START.toString());
			else if (tokenSpan.getEndTokenIndex() == sentenceTokenCount)
				output.add(Position.END.toString());
			else
				output.add(Position.MIDDLE.toString());
{'fraction_non_alphanumeric': 0.11807012286484866, 'fraction_numerical': 0.0014983518130056938, 'mean_word_length': 4.436482084690554, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 13, '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': '6891892', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1063, 'n_words': 218}