colonel.word module

Module providing the Word class.

class colonel.word.Word(index=None, head=None, deprel=None, **kwargs)[source]

Bases: colonel.base_rich_sentence_element.BaseRichSentenceElement

Representation of a Word sentence element

deprel

Universal dependency relation to the head or a defined language-specific subtype of one.

It is compatible with CoNLL-U DEPREL field.

head

Head of the current word, which is usually a value of another Word’s index or zero (0, for root grammatical relations).

It is compatible with CoNLL-U HEAD field.

index

Word index.

It is compatible with CoNLL-U ID field.

The term index has been preferred over the more conventional ID, mostly for the purpose of preventing confusion, especially with Python’s id() built-in function (which returns the “identity” of an object).

is_valid()[source]

Returns whether or not the object can be considered valid, however ignoring the context of the sentence in which the word itself is possibly inserted.

In compliance with the CoNLL-U format, an instance of type Word is considered valid only when index is set to a value greater than zero (0).

Return type:bool
to_conllu()[source]

Returns a CoNLL-U formatted representation of the element.

No validity check is performed on the attributes; values not compatible with CoNLL-U format could lead to an incorrect output value or raising of exceptions.

Return type:str