lift_utils.base¶
Manipulate base linguistic elements.
Module Contents¶
Classes¶
Provides a mechanism for adding meta-information to almost any element. |
|
Used to provide certain extra information in a controlled way. |
|
A generalised element to allow an application to store information. |
|
An important mechanism for giving type information to an object. |
|
A representation of a string in a particular language and script. |
|
A representation of a sense's gloss. |
|
This is a base class for all LIFT nodes. |
|
Allows for different representations of the same information. |
|
A Unicode string marked with language and formatting information. |
|
Contains textual data mixed with |
|
An important mechanism for giving type information to an object. |
|
This is a URL with a caption. |
- class lift_utils.base.Annotation(name: str = None, value: str = None, who: str = None, when: str = None, xml_tree: lxml.etree._Element | None = None, **kwargs)¶
Bases:
MultitextProvides a mechanism for adding meta-information to almost any element.
- XML_TAG = 'annotation'¶
- class lift_utils.base.Extensible(xml_tree: lxml.etree._Element | None = None, **kwargs)¶
Bases:
LIFTUtilsBaseUsed to provide certain extra information in a controlled way.
- Variables:
date_created (Optional[DateTime]) – Contains a date/timestamp saying when the element was added to the dictionary.
date_modified (Optional[DateTime]) – Contains a date/timestamp saying when the element was last changed.
field_items (Optional[List[Field]]) – Holds extra textual information.
trait_items (Optional[List[Trait]]) – Adds type or constraint information.
annotation (Optional[List[Annotation]]) – Adds meta-information describing the element.
- XML_TAG¶
- add_annotation(name=None, value=None, who=None, when=None)¶
- add_field(name=None)¶
- add_trait(name=None, value=None, trait_id=None)¶
- set_date_created()¶
- set_date_modified()¶
- class lift_utils.base.Field(field_type: str = None, name: str = None, xml_tree: lxml.etree._Element | None = None, **kwargs)¶
Bases:
MultitextA generalised element to allow an application to store information. It’s for information in a LIFT file that isn’t explicitly described in the LIFT standard.
- XML_TAG = 'field'¶
- class lift_utils.base.Flag(xml_tree: lxml.etree._Element | None = None, **kwargs)¶
Bases:
TraitAn important mechanism for giving type information to an object. It can also be use for adding binary constraints.
Note
Used by LIFT v0.13 (FieldWorks). Mentioned in specification but not defined; assumed to be equivalent to
Trait.
- class lift_utils.base.Form(lang: lift_utils.datatypes.Lang = None, text: Text = None, xml_tree: lxml.etree._Element | None = None, **kwargs)¶
Bases:
LIFTUtilsBaseA representation of a string in a particular language and script. This is specified by the
langattribute.- XML_TAG = 'form'¶
- class lift_utils.base.Gloss(lang: str = None, text: str = None, xml_tree: lxml.etree._Element | None = None, **kwargs)¶
Bases:
FormA representation of a sense’s gloss. It’s given in a particular language and script as specified by the
langattribute.- XML_TAG = 'gloss'¶
- set_trait_items(trait_dict)¶
- class lift_utils.base.LIFTUtilsBase(parent_item=None, xml_tree: lxml.etree._Element = None)¶
This is a base class for all LIFT nodes.
- Variables:
xml_tree (etree._Element) – The node’s current data.
- XML_PY_NAMES¶
- XML_TAG¶
- print(_format='xml')¶
Print the node’s data to stdout; as XML by default.
- prop_name_from_xml_name(xml_name)¶
Return the object property name from the given XML attribute or element name.
- show()¶
Print an overview of the object in the terminal window.
- class lift_utils.base.Multitext(form_dict: dict = None, xml_tree: lxml.etree._Element | None = None, **kwargs)¶
Bases:
TextAllows for different representations of the same information. It can be in a given language, or in multiple languages.
- XML_TAG¶
- get_form_by_lang(lang)¶
Return first form item with matching
langattribute.- Variables:
lang (str) – Language code; e.g. “en”.
- set_form_items(form_dict)¶
- class lift_utils.base.Span(text: str = None, tail: str = None, lang: str = None, href: str = None, span_class: str = None, xml_tree: lxml.etree._Element | None = None, **kwargs)¶
Bases:
LIFTUtilsBaseA Unicode string marked with language and formatting information.
- XML_TAG = 'span'¶
- class lift_utils.base.Text(text: str = None, xml_tree: lxml.etree._Element | None = None, subinit=False, **kwargs)¶
Bases:
LIFTUtilsBaseContains textual data mixed with
spanelements only.- XML_TAG = 'text'¶
- class lift_utils.base.Trait(name: str = None, value: str = None, trait_id: str = None, xml_tree: lxml.etree._Element | None = None, **kwargs)¶
Bases:
LIFTUtilsBaseAn important mechanism for giving type information to an object. It can also be used for adding binary constraints.
- XML_TAG = 'trait'¶
- class lift_utils.base.URLRef(href: str = None, label: dict = None, xml_tree: lxml.etree._Element | None = None, **kwargs)¶
Bases:
LIFTUtilsBaseThis is a URL with a caption.
- XML_TAG = 'urlref'¶
- set_label(label_dict)¶