Beispiel #1
0
autoConfusion Categories_to_Confusion (Categories me, Categories thee) {
	try {
		if (my size != thy size) {
			Melder_throw (U"Categories_to_Confusion: dimensions do not agree.");
		}

		autoCategories ul1 = Categories_selectUniqueItems (me);
		autoCategories ul2 = Categories_selectUniqueItems (thee);
		autoConfusion him = Confusion_create (ul1->size, ul2->size);

		for (long i = 1; i <= ul1->size; i ++) {
			SimpleString s = ul1->at [i];
			TableOfReal_setRowLabel (him.get(), i, s -> string);
		}
		for (long i = 1; i <= ul2->size; i ++) {
			SimpleString s = ul2->at [i];
			TableOfReal_setColumnLabel (him.get(), i, s -> string);
		}
		for (long i = 1; i <= my size; i ++) {
			SimpleString myi = my at [i], thyi = thy at [i];
			Confusion_increase (him.get(), SimpleString_c (myi), SimpleString_c (thyi));
		}
		return him;
	} catch (MelderError) {
		Melder_throw (me, U": no Confusion created.");
	}
}
Beispiel #2
0
void Confusion_and_ClassificationTable_increase (Confusion me, ClassificationTable thee) {
	if (my numberOfColumns != thy numberOfColumns) {
		Melder_throw (U"The number of columns must be equal.");
	}
	for (long irow = 1; irow <= thy numberOfRows; irow++) {
		long index = TableOfReal_getColumnIndexAtMaximumInRow (thee, irow);
		Confusion_increase (me, thy rowLabels[irow], my columnLabels[index]);
	}
}