## gate.annotation
Class AnnotationDiff

    java.lang.Object
      |
      +--java.awt.Component
            |
            +--java.awt.Container
                  |
                  +--javax.swing.JComponent
                        |
                        +--javax.swing.JPanel
                              |
                              +--gate.creole.AbstractVisualResource
                                    |
                                    +--gate.annotation.AnnotationDiff

All Implemented Interfaces:
  Accessible, FeatureBearer, ImageObserver, MenuContainer, NameBearer, Resource, Serializable, VisualResource

public class AnnotationDiff
extends AbstractVisualResource

This class compare two annotation sets on annotation type given by the AnnotationSchema object. It also deals with graphic representation of the result.

See Also:
  Serialized Form

Inner Class Summary
`class` `AnnotationDiff.AnnotationDiffCellRenderer` This class defines a Cell renderer for the AnnotationDiff table

Inner classes inherited from class javax.swing.JComponent
`JComponent.AccessibleJComponent`

Field Summary
`static int` `CORRECT_TYPE` A correct type when all annotation are corect represented by Green color
`static int` `DEFAULT_TYPE` A default type when all annotation are the same represented by White color
`static int` `MAX_TYPES` Field designated to represent the max nr of annot types and coolors for each type
`static int` `MISSING_TYPE` A missing type when annotations in key were not present in response Represented by Yellow color
`static int` `PARTIALLY_CORRECT_TYPE` A partially correct type when all annotation are corect represented by Blue color
`static int` `SPURIOUS_TYPE` A spurious type when annotations in response were not present in key.
`static double` `weight` The weight used in F-measure (see NLP Information Extraction)

Fields inherited from class javax.swing.JComponent
`TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

Fields inherited from class java.awt.Component
`BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

Fields inherited from interface java.awt.image.ImageObserver
`ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

Constructor Summary
`AnnotationDiff()` Constructs a AnnotationDif

Method Summary
`AnnotationSchema` `getAnnotationSchema()`
`Set` `getAnnotationsOfType(int annotType)` Returns a set with all annotations of a specific type
`String` `getAnnotationTypeForFalsePositive()` Gets the annotation type needed to calculate the falsePossitive measure
`double` `getFalsePositiveAverage()`
`double` `getFalsePositiveLenient()`
`double` `getFalsePositiveStrict()`
`double` `getFMeasureAverage()`
`double` `getFMeasureLenient()`
`double` `getFMeasureStrict()`
`String` `getKeyAnnotationSetName()` Gets the keyAnnotationSetName.
`Document` `getKeyDocument()`
`Set` `getKeyFeatureNamesSet()` Gets the keyFeatureNamesSet in AnnotDiff.
`Object` `getParameterValue(String paramaterName)` Gets the value of a parameter of this resource.
`double` `getPrecisionAverage()`
`double` `getPrecisionLenient()`
`double` `getPrecisionStrict()`
`double` `getRecallAverage()`
`double` `getRecallLenient()`
`double` `getRecallStrict()`
`String` `getResponseAnnotationSetName()` gets the responseAnnotationSetName.
`String` `getResponseAnnotationSetNameFalsePoz()` gets the responseAnnotationSetNameFalsePoz.
`Resource` `init()` This method does the diff, Precision,Recall,FalsePositive calculation and so on.
`boolean` `isTextMode()` Gets the annot diff textmode.True means that the text mode is activated.
`void` `setAnnotationSchema(AnnotationSchema anAnnotationSchema)`
`void` `setAnnotationTypeForFalsePositive(String anAnnotType)` Sets the annotation type needed to calculate the falsePossitive measure
`void` `setKeyAnnotationSetName(String aKeyAnnotationSetName)` Sets the keyAnnotationSetName in AnnotDiff
`void` `setKeyDocument(Document aKeyDocument)` Sets the keyDocument in AnnotDiff
`void` `setKeyFeatureNamesSet(Set aKeyFeatureNamesSet)` Sets the keyFeatureNamesSet in AnnotDiff.
`void` `setParameterValue(String paramaterName, Object parameterValue)` Sets the value for a specified parameter.
`void` `setParameterValues(FeatureMap parameters)` Sets the values for more parameters in one step.
`void` `setResponseAnnotationSetName(String aResponseAnnotationSetName)` Sets the responseAnnotationSetName in AnnotDiff
`void` `setResponseAnnotationSetNameFalsePoz(String aResponseAnnotationSetNameFalsePoz)` Sets the responseAnnotationSetNameFalsePoz in AnnotDiff
`void` `setResponseDocument(Document aResponseDocument)`
`void` `setTextMode(Boolean aTextMode)` Sets the annot diff to work in the text mode.This would not initiate the GUI part of annot diff but it would calculate precision etc

Methods inherited from class gate.creole.AbstractVisualResource
`cleanup, getFeatures, setFeatures, setHandle, setTarget`

Methods inherited from class javax.swing.JPanel
`getAccessibleContext, getUIClassID, updateUI`

Methods inherited from class javax.swing.JComponent

`addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

Methods inherited from class java.awt.Container

`add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setLayout, validate`

Methods inherited from class java.awt.Component

`action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, contains, createImage, createImage, dispatchEvent, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface gate.util.NameBearer
`getName, setName`

Field Detail

### weight

    public static double weight

  The weight used in F-measure (see NLP Information Extraction)

### MAX_TYPES

    public static final int MAX_TYPES

  Field designated to represent the max nr of annot types and coolors for each type

### DEFAULT_TYPE

    public static final int DEFAULT_TYPE

  A default type when all annotation are the same represented by White color

### CORRECT_TYPE

    public static final int CORRECT_TYPE

  A correct type when all annotation are corect represented by Green color

### PARTIALLY_CORRECT_TYPE

    public static final int PARTIALLY_CORRECT_TYPE

  A partially correct type when all annotation are corect represented by Blue color

### SPURIOUS_TYPE

    public static final int SPURIOUS_TYPE

  A spurious type when annotations in response were not present in key. Represented by Red color

### MISSING_TYPE

    public static final int MISSING_TYPE

  A missing type when annotations in key were not present in response Represented by Yellow color

Constructor Detail

### AnnotationDiff

    public AnnotationDiff()

  Constructs a AnnotationDif

Method Detail

### setAnnotationTypeForFalsePositive

    public void setAnnotationTypeForFalsePositive(String anAnnotType)

  Sets the annotation type needed to calculate the falsePossitive measure
  Parameters:
    `anAnnotType` - is the annotation type needed to calculate a special mesure called falsePossitive. Usualy the value is "token", but it can be any other string with the same semantic.

### getAnnotationTypeForFalsePositive

    public String getAnnotationTypeForFalsePositive()

  Gets the annotation type needed to calculate the falsePossitive measure
  Returns:
    annotation type needed to calculate a special mesure called falsePossitive.

### setKeyDocument

    public void setKeyDocument(Document aKeyDocument)

  Sets the keyDocument in AnnotDiff
  Parameters:
    `aKeyDocument` - The GATE document used as a key in annotation diff.

### getKeyDocument

    public Document getKeyDocument()

  Returns:
    the keyDocument used in AnnotDiff process

### setKeyAnnotationSetName

    public void setKeyAnnotationSetName(String aKeyAnnotationSetName)

  Sets the keyAnnotationSetName in AnnotDiff
  Parameters:
    `aKeyAnnotationSetName` - The name of the annotation set from the keyDocument.If aKeyAnnotationSetName is null then the default annotation set will be used.

### getKeyAnnotationSetName

    public String getKeyAnnotationSetName()

  Gets the keyAnnotationSetName.
  Returns:
    The name of the keyAnnotationSet used in AnnotationDiff. If returns null then the the default annotation set will be used.

### setKeyFeatureNamesSet

    public void setKeyFeatureNamesSet(Set aKeyFeatureNamesSet)

  Sets the keyFeatureNamesSet in AnnotDiff.
  Parameters:
    `aKeyFeatureNamesSet` - a set containing the feature names from key that will be used in isPartiallyCompatible()

### getKeyFeatureNamesSet

    public Set getKeyFeatureNamesSet()

  Gets the keyFeatureNamesSet in AnnotDiff.
  Returns:
    A set containing the feature names from key that will be used in isPartiallyCompatible()

### setResponseAnnotationSetName

    public void setResponseAnnotationSetName(String aResponseAnnotationSetName)

  Sets the responseAnnotationSetName in AnnotDiff
  Parameters:
    `aResponseAnnotationSetName` - The name of the annotation set from the responseDocument.If aResponseAnnotationSetName is null then the default annotation set will be used.

### getResponseAnnotationSetName

    public String getResponseAnnotationSetName()

  gets the responseAnnotationSetName.
  Returns:
    The name of the responseAnnotationSet used in AnnotationDiff. If returns null then the the default annotation set will be used.

### setResponseAnnotationSetNameFalsePoz

    public void setResponseAnnotationSetNameFalsePoz(String aResponseAnnotationSetNameFalsePoz)

  Sets the responseAnnotationSetNameFalsePoz in AnnotDiff
  Parameters:
    `aResponseAnnotationSetNameFalsePoz` - The name of the annotation set from the responseDocument.If aResponseAnnotationSetName is null then the default annotation set will be used.

### getResponseAnnotationSetNameFalsePoz

    public String getResponseAnnotationSetNameFalsePoz()

  gets the responseAnnotationSetNameFalsePoz.
  Returns:
    The name of the responseAnnotationSetFalsePoz used in AnnotationDiff. If returns null then the the default annotation set will be used.

### setTextMode

    public void setTextMode(Boolean aTextMode)

  Sets the annot diff to work in the text mode.This would not initiate the GUI part of annot diff but it would calculate precision etc

### isTextMode

    public boolean isTextMode()

  Gets the annot diff textmode.True means that the text mode is activated.

### getAnnotationsOfType

    public Set getAnnotationsOfType(int annotType)

  Returns a set with all annotations of a specific type

### getParameterValue

    public Object getParameterValue(String paramaterName)
                             throws ResourceInstantiationException

  Gets the value of a parameter of this resource.
  Overrides:
    `getParameterValue` in class `AbstractVisualResource`
  Parameters:
    `paramaterName` - the name of the parameter
  Returns:
    the current value of the parameter

### setParameterValue

    public void setParameterValue(String paramaterName,
                                  Object parameterValue)
                           throws ResourceInstantiationException

  Sets the value for a specified parameter.
  Overrides:
    `setParameterValue` in class `AbstractVisualResource`
  Parameters:
    `paramaterName` - the name for the parameteer
    `parameterValue` - the value the parameter will receive

### setParameterValues

    public void setParameterValues(FeatureMap parameters)
                            throws ResourceInstantiationException

  Sets the values for more parameters in one step.
  Overrides:
    `setParameterValues` in class `AbstractVisualResource`
  Parameters:
    `parameters` - a feature map that has paramete names as keys and parameter values as values.

### getPrecisionStrict

    public double getPrecisionStrict()

  Returns:
    the precisionStrict field

### getPrecisionLenient

    public double getPrecisionLenient()

  Returns:
    the precisionLenient field

### getPrecisionAverage

    public double getPrecisionAverage()

  Returns:
    the precisionAverage field

### getFMeasureStrict

    public double getFMeasureStrict()

  Returns:
    the fMeasureStrict field

### getFMeasureLenient

    public double getFMeasureLenient()

  Returns:
    the fMeasureLenient field

### getFMeasureAverage

    public double getFMeasureAverage()

  Returns:
    the fMeasureAverage field

### getRecallStrict

    public double getRecallStrict()

  Returns:
    the recallStrict field

### getRecallLenient

    public double getRecallLenient()

  Returns:
    the recallLenient field

### getRecallAverage

    public double getRecallAverage()

  Returns:
    the recallAverage field

### getFalsePositiveStrict

    public double getFalsePositiveStrict()

  Returns:
    the falsePositiveStrict field

### getFalsePositiveLenient

    public double getFalsePositiveLenient()

  Returns:
    the falsePositiveLenient field

### getFalsePositiveAverage

    public double getFalsePositiveAverage()

  Returns:
    the falsePositiveAverage field

### setResponseDocument

    public void setResponseDocument(Document aResponseDocument)

  Parameters:
    `aResponseDocument` - the GATE response Document containing the annotation Set being compared against the annotation from the keyDocument.

### setAnnotationSchema

    public void setAnnotationSchema(AnnotationSchema anAnnotationSchema)

  Parameters:
    `anAnnotationSchema` - the annotation type being compared. This type is found in annotationSchema object as field `AnnotationSchema.getAnnotationName()`. If is null then AnnotDiff will throw an exception when it comes to do the diff.

### getAnnotationSchema

    public AnnotationSchema getAnnotationSchema()

  Returns:
    the annotation schema object used in annotation diff process

### init

    public Resource init()
                  throws ResourceInstantiationException

  This method does the diff, Precision,Recall,FalsePositive calculation and so on.
  Overrides:
    `init` in class `AbstractVisualResource`