package org.cocolab.inpro.incremental.unit;

public class TextualWordIU extends WordIU {

	public static final TextualWordIU FIRST_ATOMIC_WORD_IU = new TextualWordIU(""); 
	public int counter;
	
	/* a word that hides any and all grounded-in hierarchy */
	/* and instead bases timing on word count */
	
	public TextualWordIU(String word, TextualWordIU sll, int counter) {
		super(word, null, sll, null);
		this.counter = counter;
	}
	
	public TextualWordIU(String word, TextualWordIU sll) {
		this(word, sll, (sll != null) ? sll.counter + 1 : 1);
	}
	
	private TextualWordIU(String word) {
		this(word, null);
	}
	
	@Override
	public double endTime() {
		return counter;
	}
	
	@Override
	public double startTime() {
		return (sameLevelLink == null) ? Double.NaN : sameLevelLink.endTime();
	}
	
	/**
	 * AtomicWordIUs have prosody if they end in either + or -
	 */
	@Override
	public boolean hasProsody() {
		return super.getWord().matches("[\\+\\-]$");
	}
	
	/**
	 * @precondition: only call this if hasProsody()
	 */
	@Override
	public boolean pitchIsRising() {
		assert hasProsody();
		return super.getWord().matches("\\+$");
	}
	
	@Override
	public String getWord() {
		return super.getWord().replaceAll("[\\+\\-]$", "");
	}
	
}

@@ -932,23 +932,25 @@
 atches(%22
+.*
 %5B%5C%5C
-+%5C%5C-
+-%5C%5C+
 %5D$%22);%0A%09%7D
@@ -1114,16 +1114,18 @@
 atches(%22
+.*
 %5C%5C+$%22);%0A

fix java regexps for proper +-prosody marks on words