OCDM_Annotation Class Reference

OCDM_Annotation class gathers together every function having to do with the use and manipulation of an Annotation.

#include <OCDM.h>

Inheritance diagram for OCDM_Annotation:

OCDM_Object List of all members.

Public Member Functions

 OCDM_Annotation ()
 OCDM_Annotation (const CDM_Object obj)
 OCDM_Annotation (const class OCDM_Annotation &obj)
 OCDM_Annotation (const char *type, const OCDM_SpanSet &Spans, const OCDM_AttributeSet &Attributes)
 OCDM_Annotation (const char *type, const long start, const long end, const OCDM_AttributeSet &Attributes)
OCDM_Annotationoperator= (const class OCDM_Object &obj)
 This is the default assignment operator.
OCDM_BOOL AnnotationContainsPosition (const long Position) const
 This function will check if the Annotation contains in any of its spans the specified position.
OCDM_BOOL AnnotationMatchesRange (const long Start, const long End) const
 This function will check if the Annotation contains a span that has the specified start and end offsets.
OCDM_BOOL AttributeExists (const char *name) const
 This function will return true if an Attribute with the specified name exists in the Annotation object.
int CompareAnnotations (const OCDM_Annotation &Ann) const
 This function will compare the Annotation in use and the Annotation defined.
void DisplaceAnnotation (const long offset, const long displacement)
 This function displases or "moves" the specified Annotation by "displacement" characters.
 OCDM_REF (OCDM_Attribute) GetAttribute(const char *name) const
 OCDM_REF (OCDM_AttributeSet) GetAttributes(void) const
 OCDM_REF (OCDM_Span) GetFirstSpan(void) const
int GetFirstSpanOffsets (long &start, long &end) const
 OCDM_REF (OCDM_SpanSet) GetSpans(void) const
void PutAttribute (const OCDM_Attribute &Attr)
 This function adds a new Attribute in the Annotation object we are currently use.
const char * GetType (void) const
void ReconstructAnnotation (void) const
 This function will construct a new Annotation object an replace the Annotation object in use with the new one.
void RemoveAttribute (const char *name)
 This function will remove the Attribute having as name the value of the "Name" parameter from the Annotation object in use, if such an Attribute exists.
void AddSpan (const OCDM_Span &span)
void RemoveSpan (const long start, const long end)
long GetId (void) const
 This function will return the Id of the Annotation object in use.
const char * objectType (void) const

Constructor & Destructor Documentation

OCDM_Annotation  )  [inline]
 

OCDM_Annotation const CDM_Object  obj  )  [inline]
 

OCDM_Annotation const class OCDM_Annotation obj  )  [inline]
 

OCDM_Annotation const char *  type,
const OCDM_SpanSet Spans,
const OCDM_AttributeSet Attributes
 

/brief This is the constructor function fo the OCDM_Annotation class.

Description:
This is the constructor function fo the OCDM_Annotation class. It will create a new Annotation object. The newly created Annotation object will not have an empty Annotation Id and the Annotation type, Span set and Annotation set will be set to the values provided by the caller through the corresponding parameters. This function will always use the provided Span set object in the returned Annotation object. However, this function may or may not use the provided Attribute set object: this function will internally increment the reference count of the provided Attribute set object. If the reference count of the provided Attribute set object equals 0 (i.e. the Attribute set object has been created with a call to OCDM_CreateAttribute), this function may free the object. As a result, if the caller wants to ensure that the provided Attribute set object is valid after calling this function, he should increment its reference count with Tcl_IncrRefCount.
Arguments:
  • type: Annotation types are textual values that are used to classify annotations into categories
  • Spans: This is a set of pairs of two byte offsets that denote the range(s) of the annotated textual data.
  • Attributes: These attributes usually contain the necessary linguistic information.

OCDM_Annotation const char *  type,
const long  start,
const long  end,
const OCDM_AttributeSet Attributes
 

/brief This is the constructor function fo the OCDM_Annotation class.

Description:
This constructor can be used in order to create an Annotation object which will have only one span (although the number of Spans can be increased later) and we don't want to create an OCDM_Span object. This constructor can be more efficient, especially if the Annotation will always have only one Span object (a quite common situation).
Arguments:
  • type: Annotation types are textual values that are used to classify annotations into categories
  • start: This is the start character offset to be placed in the Span of the Annotation.
  • end: This is the end character offset to be placed in the Span of the Annotation.
  • Attributes: These attributes usually contain the necessary linguistic information. (Can be also NULL)


Member Function Documentation

void AddSpan const OCDM_Span span  ) 
 

Description:
This function will add the provided Span object to the Annotation object in use. The altered Annotation will replace the one in use. In the case of an error an Exception of type OCDM_Exception will be thrown
Arguments:
  • span: The Span object that should be added.

int AnnotationContainsPosition const long  Position  )  const
 

Description:
This function will check if the Annotation contains in any of its spans the specified position.
Arguments:
  • Position: The position to me checked.

int AnnotationMatchesRange const long  Start,
const long  End
const
 

Description:
This function will check if the Annotation contains a span that has the specified start and end offsets.
Arguments:
  • Start: The span start to me matched.
  • End: The span end to me matched.

OCDM_BOOL AttributeExists const char *  name  )  const
 

Arguments:
  • name: The Attribute name to be found.
Note:
In case of an Error an Exception of type OCDM_Exception will be thrown.

int CompareAnnotations const OCDM_Annotation Ann  )  const
 

Description:
This function will compare the Annotation in use and the Annotation defined in the parameter Ann, according to their Span sets.
Arguments:
  • Ann: The Annotation to be compared with the annotation object in use.
Note:
This function returns -1 if the Annotation in use is lower than Ann. If Ann has the same text ranges as the Annotation in use then a zero is returned. Finally, 1 is returned if the current Annotation is greater than Ann In case of an error an Exception of type OCDM_Exception will be thrown

void DisplaceAnnotation const long  offset,
const long  displacement
 

Description:
This function will iterate over all spans contained in the Annotation. For each span all the offsets contained in it (either start or end) will be examined:
Arguments:
  • offset: The function checks whether any of this offsets is equal or greater than the value specified through the "offset" parameter,
  • displacement: If any of this offsets is equal or greater than the value specified through the "offset" parameter, then the value of the "displacement" parameter will be added to it.

int GetFirstSpanOffsets long &  start,
long &  end
const
 

Returns:
This function will place the values of both span start and end of the Annotation's first span in the two specified long integer pointers.

long GetId void   )  const
 

Description:
This function will return the Id of the Annotation object in use. The Id of an Annotation is a unique integer (of type long) that unambigiously specifies an Annotation object inside a Document. CDM ensures that each Annotation of the Annotations contained in a Document will have a unique Id.

const char * GetType void   )  const
 

Returns:
This function returns the type of the Annotation object in use. The return value will be of type char*
Note:
The returned value will be encoded using the UTF-8 encoding.

const char* objectType void   )  const [inline, virtual]
 

This method returns the type of the object as a string.

Reimplemented from OCDM_Object.

OCDM_REF OCDM_SpanSet   )  const
 

OCDM_REF OCDM_Span   )  const
 

OCDM_REF OCDM_AttributeSet   )  const
 

OCDM_REF OCDM_Attribute   )  const
 

class OCDM_Annotation& operator= const class OCDM_Object obj  )  [inline, virtual]
 

Description: This is the default sssignment operator. Note that under
languages that do not support operator overloading (i.e. Java, Perl, Python) this operator appears as a plain method named as "set".
Arguments:
  • obj: the object to be copied.
Returns:
This method returns a reference to the current object.

Reimplemented from OCDM_Object.

void PutAttribute const OCDM_Attribute Attr  ) 
 

Note:
In case of an error an Exception of type OCDM_Exception will be thrown
Description:
This function adds a new Attribute in the Annotation object we are currently use
Arguments:
  • Attr: The new attribute to be added to the Annotation object we are currently use

void ReconstructAnnotation void   )  const
 

Description:
This function will construct a new Annotation object an replace the Annotation object in use with the new one The only difference will be that the returned Annotation object will utilise elements from the object cache that is managed internally by CDM. As a result the returned object will normally require less memory to be stored than the provided one, as it will re-use elements already in use by other CDM objects. This function should be used on Annotation objects that originate from an unknown source. For example, if an Annotation object is stored in a file and then red back as a string, it will not use cached by the CDM objects. It will be a good idea if the caller created a new object by calling this function and delete the object red from the file by either calling Tcl_DecrRefCount or CDM_Free.
Note:
The new Annotation object will be an exact copy of the Annotation object.

void RemoveAttribute const char *  name  ) 
 

Arguments:
  • name: The name of the attribute to be removed.
Note:
The altered Annotation will replace the one in use

void RemoveSpan const long  start,
const long  end
 

Description:
This function will remove the Span having as start and end offsets the values specified through the "start" and "end" parameters from the Annotation object in use, if such a Span object exists. The altered Annotation will replace the one in use. If a Span object with the proper start and end offsets was not found, the the replacemnt will not take place. Finally, in the case of an error an Exception of type OCDM_Exception will be thrown
Arguments:
  • start: The starting value of the span to be removed
  • end: The ending value of the span to be removed


Generated on Wed Aug 16 22:32:02 2006 for PythonCDM by  doxygen 1.4.6