<commit_before>package inpro.incremental.unit;


import inpro.synthesis.MaryAdapter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;

import org.apache.commons.lang.StringUtils;


/** 
 * an synthesizable InstallmentIU that uses phrases to structure its output.
 * phrases can be added even when the utterance is already being produced
 * (currently, phrases cannot be "revoked" from the installment as that wasn't necessary in our tasks yet)
 * @author timo
 */
public class PhraseBasedInstallmentIU extends SysInstallmentIU {
	/** counts the hesitations in this installment (which need to be accounted for when counting the continuation point of a resynthesis when appending a continuation */
	private int numHesitationsInserted = 0;
	/** keeps the list of phrases that this installment is based on */
	private final IUList<PhraseIU> phrases = new IUList<PhraseIU>();
	
	public PhraseBasedInstallmentIU(HesitationIU hesitation) {
		super("<hes>", new ArrayList<WordIU>(Collections.<WordIU>singletonList((WordIU)hesitation)));
		numHesitationsInserted++;
		phrases.add(hesitation);
	}
	
	/** create a phrase from  */
	public PhraseBasedInstallmentIU(PhraseIU phrase) {
		super(phrase.toPayLoad(), phrase.getWords());
		if (phrase.getWords() == null) {
			groundedIn = MaryAdapter.getInstance().text2IUs(tts);
		}
		phrase.groundIn(new ArrayList<IU>(groundedIn));	
		phrases.add(phrase);
	}
<commit_msg>fix  groundedIn-bookkeeping that appears when starting from a presynthesized phrase: previously, the phrase and the installment would share their grounded-in lists, breaking heavoc once more phrases are added.<commit_after>package inpro.incremental.unit;


import inpro.synthesis.MaryAdapter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;

import org.apache.commons.lang.StringUtils;


/** 
 * an synthesizable InstallmentIU that uses phrases to structure its output.
 * phrases can be added even when the utterance is already being produced
 * (currently, phrases cannot be "revoked" from the installment as that wasn't necessary in our tasks yet)
 * @author timo
 */
public class PhraseBasedInstallmentIU extends SysInstallmentIU {
	/** counts the hesitations in this installment (which need to be accounted for when counting the continuation point of a resynthesis when appending a continuation */
	private int numHesitationsInserted = 0;
	/** keeps the list of phrases that this installment is based on */
	private final IUList<PhraseIU> phrases = new IUList<PhraseIU>();
	
	public PhraseBasedInstallmentIU(HesitationIU hesitation) {
		super("<hes>", new ArrayList<WordIU>(Collections.<WordIU>singletonList((WordIU)hesitation)));
		numHesitationsInserted++;
		phrases.add(hesitation);
	}
	
	/** create a phrase from  */
	public PhraseBasedInstallmentIU(PhraseIU phrase) {
		super(phrase.toPayLoad(), phrase.getWords());
		// if the phrase that we're starting from isn't yet pre-synthesized, we have to build the IU structure
		if (phrase.getWords() == null) {
			groundedIn = MaryAdapter.getInstance().text2IUs(tts);
		} else {
			groundedIn = new ArrayList<IU>(groundedIn); // ensure that the grounded-in lists aren't shared between InstallmentIU and PhraseIU!
		}
		phrase.groundIn(groundedIn);	
		phrases.add(phrase);
	}

{'fraction_non_alphanumeric': 0.09128754088611359, 'fraction_numerical': 0.0011894142134998512, 'mean_word_length': 5.172477064220184, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4329628', 'n_tokens_mistral': 1054, 'n_tokens_neox': 928, 'n_words': 318}