annotation
autocorpus.ac_bioc.annotation
¤
This module defines the BioCAnnotation class.
Classes¤
BioCAnnotation(id=str(), text=str(), offset=int(), length=int(), infons=dict(), locations=list())
dataclass
¤
Represents an annotation in a BioC document.
Functions¤
from_dict(data)
classmethod
¤
Create a BioCAnnotation instance from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict[str, Any]
|
A dictionary containing annotation data. |
required |
Returns:
Name | Type | Description |
---|---|---|
BioCAnnotation |
BioCAnnotation
|
An instance of BioCAnnotation created from the dictionary. |
Source code in autocorpus/ac_bioc/annotation.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
from_xml(elem)
classmethod
¤
Create a BioCAnnotation instance from an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
elem
|
Element
|
An XML element representing the annotation. |
required |
Returns:
Name | Type | Description |
---|---|---|
BioCAnnotation |
BioCAnnotation
|
An instance of BioCAnnotation created from the XML element. |
Source code in autocorpus/ac_bioc/annotation.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
to_json()
¤
Convert the annotation to a JSON-serializable dictionary.
Returns:
Type | Description |
---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary containing the annotation's id, text, offset, length, infons, and locations. |
Source code in autocorpus/ac_bioc/annotation.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
to_xml()
¤
Convert the annotation to an XML element.
Returns:
Type | Description |
---|---|
Element
|
ET.Element: An XML element representing the annotation. |
Source code in autocorpus/ac_bioc/annotation.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|