/** Creates a new {@link CodingAnnotationItem} which has been coded with * the given annotation categories. Note that the order of the categories * must correspond to the raters' indexes. Use null to represent missing * annotations, Invoking <code>addItem(new Object[]{"A", "B", null, * "A"})</code> indicates an annotation item which has been coded as * category "A" by rater 0 and 3 and as category "B" by rater 1. Rater 2 * did not assign any category to the item. */ public ICodingAnnotationItem addItemAsArray(final Object[] annotations) { int itemIdx = items.size(); CodingAnnotationItem item = new CodingAnnotationItem(raters.size()); for (int raterIdx = 0; raterIdx < annotations.length; raterIdx++) item.addUnit(createUnit(itemIdx, raterIdx, annotations[raterIdx])); items.add(item); return item; }
/** Returns a clone of the current annotation study which contains * only the annotation units of the raters with the given indexes. * All other units will be removed. This method is useful for * converting an annotation study with multiple raters into a * (pairwise) annotation study with two raters. */ public CodingAnnotationStudy extractRaters(final int... raters) { CodingAnnotationStudy result = new CodingAnnotationStudy(raters.length); for (ICodingAnnotationItem item : getItems()) { CodingAnnotationItem newItem = new CodingAnnotationItem(raters.length); for (int r = 0; r < raters.length; r++) { IAnnotationUnit unit = item.getUnit(raters[r]); newItem.addUnit(result.createUnit(result.items.size(), r, unit.getCategory())); } result.items.add(newItem); } return result; }
/** Returns a clone of the current annotation study in which all categories * are replaced by the given nullCategory except the categories matching * the specified keepCategory. */ public CodingAnnotationStudy stripCategories(final Object keepCategory, final Object nullCategory) { CodingAnnotationStudy result = new CodingAnnotationStudy(getRaterCount()); for (ICodingAnnotationItem item : getItems()) { CodingAnnotationItem newItem = new CodingAnnotationItem(raters.size()); for (IAnnotationUnit unit : item.getUnits()) { Object newCategory; if (!keepCategory.equals(unit.getCategory())) newCategory = nullCategory; else newCategory = keepCategory; newItem.addUnit(result.createUnit(result.items.size(), unit.getRaterIdx(), newCategory)); } result.items.add(newItem); } return result; }
@Override public CodingAnnotationStudy clone() { CodingAnnotationStudy result = new CodingAnnotationStudy(getRaterCount()); for (ICodingAnnotationItem item : getItems()) { CodingAnnotationItem newItem = new CodingAnnotationItem(raters.size()); for (IAnnotationUnit unit : item.getUnits()) newItem.addUnit(result.createUnit(result.items.size(), unit.getRaterIdx(), unit.getCategory())); result.items.add(newItem); } for (Object category : getCategories()) result.addCategory(category); return result; }