pynlpl.formats.folia.AllowTokenAnnotation¶
- class pynlpl.formats.folia.AllowTokenAnnotation¶
Bases:
pynlpl.formats.folia.AllowCorrections
Elements that allow token annotation (including extended annotation) must inherit from this class
Method Summary
__init__
()alternatives
([Class, set])Generator over alternatives, either all or only of a specific annotation type, and possibly restrained also by set.
annotation
(type[, set])Obtain a single annotation element.
annotations
(Class[, set])Obtain child elements (annotations) of the specified class.
correct
(**kwargs)Apply a correction (TODO: documentation to be written still)
hasannotation
(Class[, set])Returns an integer indicating whether such as annotation exists, and if so, how many.
__str__
()Return str(self).
Method Details
- __init__()¶
- __init__()¶
- alternatives(Class=None, set=None)¶
Generator over alternatives, either all or only of a specific annotation type, and possibly restrained also by set.
- Parameters
Class (class) – The python Class you want to retrieve (e.g. PosAnnotation). Or set to
None
to select all alternatives regardless of what type they are.set (str) – The set you want to retrieve (defaults to
None
, which selects irregardless of set)
- Yields
Alternative
elements
- annotation(type, set=None)¶
Obtain a single annotation element.
A further restriction can be made based on set.
- Parameters
Class (class) – The class to select; any python class (not instance) subclassed off
AbstractElement
Set (str) – The set to match against, only elements pertaining to this set will be returned. If set to None (default), all elements regardless of set will be returned.
- Returns
An element (instance derived from
AbstractElement
)
Example:
sense = word.annotation(folia.Sense, 'http://some/path/cornetto').cls
- Raises
NoSuchAnnotation –
- annotations(Class, set=None)¶
Obtain child elements (annotations) of the specified class.
A further restriction can be made based on set.
- Parameters
Class (class) – The class to select; any python class (not instance) subclassed off
AbstractElement
Set (str) – The set to match against, only elements pertaining to this set will be returned. If set to None (default), all elements regardless of set will be returned.
- Yields
Elements (instances derived from
AbstractElement
)
Example:
for sense in text.annotations(folia.Sense, 'http://some/path/cornetto'): ..
See also
- Raises
AllowTokenAnnotation.annotations –
NoSuchAnnotation –
- correct(**kwargs)¶
Apply a correction (TODO: documentation to be written still)
- hasannotation(Class, set=None)¶
Returns an integer indicating whether such as annotation exists, and if so, how many.
See
AllowTokenAnnotation.annotations`()
for a description of the parameters.
- __str__()¶
Return str(self).