Class CodingAnnotationStudy
java.lang.Object
org.dkpro.statistics.agreement.AnnotationStudy
org.dkpro.statistics.agreement.coding.CodingAnnotationStudy
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,ICodingAnnotationStudy,IAnnotationStudy
public class CodingAnnotationStudy extends AnnotationStudy implements ICodingAnnotationStudy, java.lang.Cloneable, java.io.Serializable
Default implementation of the
ICodingAnnotationStudy interface. Instantiate this class
for representing the annotation item of a coding study (i.e., an annotation setup in which the
(human) raters are asked to code a set of given annotation items). The standard way of
representing the annotation units (i.e., the category assigned by a certain rater) of an
annotation item is using the addItem(Object...) method which allows specifying the list
of categories assigned by the raters.- Author:
- Christian M. Meyer
- See Also:
ICodingAnnotationStudy,ICodingAnnotationItem, Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<ICodingAnnotationItem>items -
Constructor Summary
Constructors Modifier Constructor Description protectedCodingAnnotationStudy()Initializes and empty annotation study for a coding task.CodingAnnotationStudy(int raterCount)Initializes and empty annotation study for a coding task with the given number of raters. -
Method Summary
Modifier and Type Method Description ICodingAnnotationItemaddItem(java.lang.Object... annotations)Creates a newCodingAnnotationItemwhich has been coded with the given annotation categories.protected voidaddItem(ICodingAnnotationItem item)Add the given annotation item to this study.ICodingAnnotationItemaddItemAsArray(java.lang.Object[] annotations)Creates a newCodingAnnotationItemwhich has been coded with the given annotation categories.voidaddMultipleItems(int times, java.lang.Object... values)Shorthand for invokingaddItem(Object...)with the same parameters multiple times.CodingAnnotationStudyclone()static java.util.Map<java.lang.Object,int[]>countAnnotationsPerCategory(ICodingAnnotationStudy study)Returns a two-dimensional map of categories and raters and the corresponding usage frequencies in the given annotation study (i.e., how often a certain rater used a certain category for coding an annotation unit).static java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Double>>countCategoryCoincidence(ICodingAnnotationItem item)Returns a two dimensional map of category pairs and their co-occurrence frequencies for the given annotation item.static java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Double>>countCategoryCoincidence(ICodingAnnotationStudy study)Returns a two dimensional map of category pairs and their co-occurrence frequencies for the given annotation study.static java.util.Map<java.lang.Object,java.lang.Integer>countTotalAnnotationsPerCategory(ICodingAnnotationItem item)Returns a map of categories and their usage frequencies (i.e., how often they are used in annotation units) within the given annotation item.static java.util.Map<java.lang.Object,java.lang.Integer>countTotalAnnotationsPerCategory(ICodingAnnotationStudy study)Returns a map of categories and their usage frequencies (i.e., how often they are used in annotation units) within the given annotation study.protected IAnnotationUnitcreateUnit(int index, int raterIdx, java.lang.Object category)CodingAnnotationStudyextractRaters(int... raters)Returns a clone of the current annotation study which contains only the annotation units of the raters with the given indexes.ICodingAnnotationItemgetItem(int index)Returns the annotation item with the given index.intgetItemCount()Returns the number of annotation items defined by the study.java.lang.Iterable<ICodingAnnotationItem>getItems()Allows iterating all annotation items of this study.intgetUnitCount()Returns the number of annotation units defined by the study.booleanhasMissingValues()Returns true if, and only if, the annotation study contains at least one item with a missing value (i.e., an annotation item containing an annotation unit with category null).CodingAnnotationStudystripCategories(java.lang.Object keepCategory, java.lang.Object nullCategory)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.Methods inherited from class org.dkpro.statistics.agreement.AnnotationStudy
addCategory, addRater, findRater, getCategories, getCategoryCount, getRaterCount, isDichotomousMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.dkpro.statistics.agreement.IAnnotationStudy
findRater, getCategories, getCategoryCount, getRaterCount, isDichotomous
-
Field Details
-
Constructor Details
-
CodingAnnotationStudy
protected CodingAnnotationStudy()Initializes and empty annotation study for a coding task. The basic setup of a coding study is assigning categories to units with fixed boundaries. -
CodingAnnotationStudy
public CodingAnnotationStudy(int raterCount)Initializes and empty annotation study for a coding task with the given number of raters. The basic setup of a coding study is assigning categories to units with fixed boundaries.
-
-
Method Details
-
addItem
Add the given annotation item to this study. The specified item should never be null. When relying on the default implementationCodingAnnotationItem, it is recommended to useaddItem(Object...)instead. -
addItem
Creates a newCodingAnnotationItemwhich 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, InvokingaddItem("A", "B", null, "A")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. The method is a shorthand foraddItemAsArray(Object[]).- Throws:
java.lang.IllegalArgumentException- if the number of annotations does not match the number of raters.
-
addItemAsArray
Creates a newCodingAnnotationItemwhich 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, InvokingaddItem(new Object[]{"A", "B", null, "A"})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.- Throws:
java.lang.IllegalArgumentException- if the number of annotations does not match the number of raters.
-
addMultipleItems
public void addMultipleItems(int times, java.lang.Object... values)Shorthand for invokingaddItem(Object...)with the same parameters multiple times. This method is useful for modeling annotation data based on a contingency table. -
createUnit
-
getItem
Description copied from interface:ICodingAnnotationStudyReturns the annotation item with the given index. The first item has index 0.- Specified by:
getItemin interfaceICodingAnnotationStudy
-
getItems
Description copied from interface:ICodingAnnotationStudyAllows iterating all annotation items of this study.- Specified by:
getItemsin interfaceICodingAnnotationStudy
-
getItemCount
public int getItemCount()Description copied from interface:ICodingAnnotationStudyReturns the number of annotation items defined by the study.- Specified by:
getItemCountin interfaceICodingAnnotationStudy
-
getUnitCount
public int getUnitCount()Description copied from interface:ICodingAnnotationStudyReturns the number of annotation units defined by the study. That is, the number of annotations coded by the raters. If there are no missing values, the unit count equals the item count multiplied with the number of raters.- Specified by:
getUnitCountin interfaceIAnnotationStudy- Specified by:
getUnitCountin interfaceICodingAnnotationStudy
-
hasMissingValues
public boolean hasMissingValues()Description copied from interface:ICodingAnnotationStudyReturns true if, and only if, the annotation study contains at least one item with a missing value (i.e., an annotation item containing an annotation unit with category null).- Specified by:
hasMissingValuesin interfaceICodingAnnotationStudy
-
clone
- Overrides:
clonein classjava.lang.Object
-
stripCategories
public CodingAnnotationStudy stripCategories(java.lang.Object keepCategory, java.lang.Object nullCategory)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. -
extractRaters
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. -
countAnnotationsPerCategory
public static java.util.Map<java.lang.Object,int[]> countAnnotationsPerCategory(ICodingAnnotationStudy study)Returns a two-dimensional map of categories and raters and the corresponding usage frequencies in the given annotation study (i.e., how often a certain rater used a certain category for coding an annotation unit). -
countTotalAnnotationsPerCategory
public static java.util.Map<java.lang.Object,java.lang.Integer> countTotalAnnotationsPerCategory(ICodingAnnotationStudy study)Returns a map of categories and their usage frequencies (i.e., how often they are used in annotation units) within the given annotation study. -
countTotalAnnotationsPerCategory
public static java.util.Map<java.lang.Object,java.lang.Integer> countTotalAnnotationsPerCategory(ICodingAnnotationItem item)Returns a map of categories and their usage frequencies (i.e., how often they are used in annotation units) within the given annotation item. -
countCategoryCoincidence
public static java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Double>> countCategoryCoincidence(ICodingAnnotationStudy study)Returns a two dimensional map of category pairs and their co-occurrence frequencies for the given annotation study. -
countCategoryCoincidence
public static java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Double>> countCategoryCoincidence(ICodingAnnotationItem item)Returns a two dimensional map of category pairs and their co-occurrence frequencies for the given annotation item.
-