location
autocorpus.ac_bioc.location
¤
This module defines the BioCLocation class.
It provides methods for converting between dictionary, XML, and object representations.
Classes¤
BioCLocation(offset=int(), length=int())
dataclass
¤
Represents a location in BioC format.
Functions¤
from_dict(data)
classmethod
¤
Create a BioCLocation instance from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cls
|
type
|
The class to instantiate. |
required |
data
|
dict[str, int]
|
A dictionary containing the 'offset' and 'length' keys. If the keys are not present, default values of 0 will be used. |
required |
Returns:
Name | Type | Description |
---|---|---|
BioCLocation |
BioCLocation
|
An instance of BioCLocation created from the dictionary. |
Source code in autocorpus/ac_bioc/location.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
from_xml(elem)
classmethod
¤
Create a BioCLocation instance from an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
elem
|
Element
|
An XML element with 'offset' and 'length' attributes. The attributes will be converted to integers. |
required |
Returns:
Type | Description |
---|---|
BioCLocation
|
BioCLocation An instance of BioCLocation created from the XML element. If the attributes are not present, default values of 0 will be used. |
Source code in autocorpus/ac_bioc/location.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
to_xml()
¤
Convert the BioCLocation instance to an XML element.
Returns:
Type | Description |
---|---|
Element
|
ET.Element An XML element representation of the BioCLocation instance. The element will have 'offset' and 'length' attributes. |
Source code in autocorpus/ac_bioc/location.py
44 45 46 47 48 49 50 51 52 53 54 55 |
|