// group by session if info is available
// TODO make this an option
@Override
	public void operate(OpContext context) throws ProcessingException {
		final TableDataSource table = (TableDataSource)context.get(tableInput);
		int ipaTidx = super.getColumnIndex(table, SystemTierType.IPATarget.getName());
		if(ipaTidx < 0) {
			throw new ProcessingException(null, "Table has no " + SystemTierType.IPATarget.getName() + " column.");
		}
		int ipaAidx = super.getColumnIndex(table, SystemTierType.IPAActual.getName());
		if(ipaAidx < 0) {
			throw new ProcessingException(null, "Table has no " + SystemTierType.IPAActual.getName() + " column.");
		}
		// group by session if info is available
		// TODO make this an option
		int sessionIdx = super.getColumnIndex(table, "Session");
		boolean ignoreDiacritics = isIgnoreDiacritics();
		if(context.containsKey("ignoreDiacritics")) {
			ignoreDiacritics = (boolean)context.get("ignoreDiacritics");
		}
		final Map<GroupKey, IpaTernaryTree<List<IPATranscript>>> tokenCounts =
				new LinkedHashMap<>();
		for(int row = 0; row < table.getRowCount(); row++) {
			checkCanceled();
			final Object groupVal =
					(sessionIdx >= 0 ? table.getValueAt(row, sessionIdx) : "*");
			final GroupKey groupKey = new GroupKey(groupVal, ignoreDiacritics);
			IpaTernaryTree<List<IPATranscript>> tokenCount =
					tokenCounts.get(groupKey);
			if(tokenCount == null) {
				tokenCount = new IpaTernaryTree<>();
				tokenCounts.put(groupKey, tokenCount);
			}
			IPATranscript ipaT =
					IPATranscript.class.cast(table.getValueAt(row, ipaTidx));
			IPATranscript ipaA =
					IPATranscript.class.cast(table.getValueAt(row, ipaAidx));
			if(ignoreDiacritics) {
				ipaT = ipaT.removePunctuation().stripDiacritics();
				ipaA = ipaA.removePunctuation().stripDiacritics();
			}
			List<IPATranscript> productions = tokenCount.get(ipaT);
			if(productions == null) {
				productions = new ArrayList<>();
				tokenCount.put(ipaT, productions);
			}
			productions.add(ipaA);
		}
		final DefaultTableDataSource outputTable = new DefaultTableDataSource();
		for(GroupKey groupKey:tokenCounts.keySet()) {
			final Object[] rowData = new Object[7];
			// produce table
			int numRepatedWords = 0;
			int numAllCorrect = 0;
			int numOneOrMoreCorrect = 0;
			int numSameError = 0;
			int numDifferentErrors = 0;
			float sumOfAvgDistances = 0;
			final IpaTernaryTree<List<IPATranscript>> tokenCount = tokenCounts.get(groupKey);
			final List<IPATranscript> repeatedTokens =
					tokenCount.keySet().stream()
						.filter( (ipa) -> tokenCount.get(ipa).size() > 1 )
						.collect(Collectors.toList());
			numRepatedWords = repeatedTokens.size();
			for(IPATranscript ipa:repeatedTokens) {
				checkCanceled();
				int numCorrect = 0;
				final List<IPATranscript> productions = tokenCount.get(ipa);
				final Set<IPATranscript> distinctProductions = new LinkedHashSet<>(productions);
				for(IPATranscript production:tokenCount.get(ipa)) {
					if(TableUtils.checkEquals(ipa, production, false, ignoreDiacritics)) {
						++numCorrect;
					}
				}
				if(numCorrect == productions.size()) {
					++numAllCorrect;
				} else {
					if(numCorrect > 0 && numCorrect < productions.size()) {
						++numOneOrMoreCorrect;
					}
					distinctProductions.remove(ipa);
					if(distinctProductions.size() == 1) {
						++numSameError;
					} else {
						++numDifferentErrors;
					}
					int totalDistance = 0;
					for(IPATranscript production:productions) {
						totalDistance += LevenshteinDistance.distance(ipa, production);
					}
					float avg = ((float)totalDistance)/((float)productions.size());
					sumOfAvgDistances += avg;
				}
			}
			// append row to table
			rowData[0] = groupKey.key;
			rowData[1] = numRepatedWords;
			rowData[2] = numAllCorrect;
			rowData[3] = numOneOrMoreCorrect;
			rowData[4] = numSameError;
			rowData[5] = numDifferentErrors;
			rowData[6] = sumOfAvgDistances / numRepatedWords;
			outputTable.addRow(rowData);
		}
		outputTable.setColumnTitle(0, "Session");
		outputTable.setColumnTitle(1, "# Repeated IPA Target");
		outputTable.setColumnTitle(2, "# All Correct");
		outputTable.setColumnTitle(3, "# One or More Correct");
		outputTable.setColumnTitle(4, "# Same Error");
		outputTable.setColumnTitle(5, "# Different Errors");
		outputTable.setColumnTitle(6, "Avg Distance");
		context.put(tableOutput, outputTable);
	}
throw new ProcessingException(null, "Table has no " + SystemTierType.IPAActual.getName() + " column.");
}
// group by session if info is available
// TODO make this an option
int sessionIdx = super.getColumnIndex(table, "Session");
boolean ignoreDiacritics = isIgnoreDiacritics();
public void operate(OpContext context) throws ProcessingException {
final TableDataSource table = (TableDataSource)context.get(tableInput);
int ipaTidx = super.getColumnIndex(table, SystemTierType.IPATarget.getName());
if(ipaTidx < 0) {
throw new ProcessingException(null, "Table has no " + SystemTierType.IPATarget.getName() + " column.");
}
int ipaAidx = super.getColumnIndex(table, SystemTierType.IPAActual.getName());
if(ipaAidx < 0) {
throw new ProcessingException(null, "Table has no " + SystemTierType.IPAActual.getName() + " column.");
}
// group by session if info is available
// TODO make this an option
int sessionIdx = super.getColumnIndex(table, "Session");
boolean ignoreDiacritics = isIgnoreDiacritics();
if(context.containsKey("ignoreDiacritics")) {
ignoreDiacritics = (boolean)context.get("ignoreDiacritics");
}
final Map<GroupKey, IpaTernaryTree<List<IPATranscript>>> tokenCounts =
new LinkedHashMap<>();
for(int row = 0; row < table.getRowCount(); row++) {
checkCanceled();
final Object groupVal =
@Override
public void operate(OpContext context) throws ProcessingException {
final TableDataSource table = (TableDataSource)context.get(tableInput);
int ipaTidx = super.getColumnIndex(table, SystemTierType.IPATarget.getName());
if(ipaTidx < 0) {
throw new ProcessingException(null, "Table has no " + SystemTierType.IPATarget.getName() + " column.");
}
int ipaAidx = super.getColumnIndex(table, SystemTierType.IPAActual.getName());
if(ipaAidx < 0) {
throw new ProcessingException(null, "Table has no " + SystemTierType.IPAActual.getName() + " column.");
}
// group by session if info is available
// TODO make this an option
int sessionIdx = super.getColumnIndex(table, "Session");
boolean ignoreDiacritics = isIgnoreDiacritics();
if(context.containsKey("ignoreDiacritics")) {
ignoreDiacritics = (boolean)context.get("ignoreDiacritics");
}
final Map<GroupKey, IpaTernaryTree<List<IPATranscript>>> tokenCounts =
new LinkedHashMap<>();
for(int row = 0; row < table.getRowCount(); row++) {
checkCanceled();
final Object groupVal =
(sessionIdx >= 0 ? table.getValueAt(row, sessionIdx) : "*");
final GroupKey groupKey = new GroupKey(groupVal, ignoreDiacritics);
IpaTernaryTree<List<IPATranscript>> tokenCount =
tokenCounts.get(groupKey);
if(tokenCount == null) {
tokenCount = new IpaTernaryTree<>();
tokenCounts.put(groupKey, tokenCount);
}
IPATranscript ipaT =
IPATranscript.class.cast(table.getValueAt(row, ipaTidx));