Sentence API for Python#

class eot.wowool.annotation.Sentence#

Bases: eot.wowool.annotation.annotation.BasicAnnotation

Sentence is a class that contains all the Tokens and Concepts of a sentence

__init__(begin_offset: int, end_offset: int) None#

Initialize a Sentence instance

Parameters
  • begin_offset (int) – Begin offset of the sentence

  • end_offset (int) – End offset of the sentence

Returns

An initialized sentence

Return type

Sentence

rich() str#
Returns

The rich string representation of the sentence

Return type

str

__iter__()#

A Sentence instance is iterable, yielding Annotation objects. For example:

for annotation in sentence:
    print(annotation)
Return type

Annotation

__getattr__(uri: str)#

Find the first instance of the concept with the given URI in the sentence

For example:

# Find the first person in the current sentence
person = sentence.Person
Parameters

uri (str) – URI, or name, of the concept

Returns

The first matching instance of the given concept

Type

Concept

find_first(uri: str)#

Find the first instance of the concept with the given URI in the sentence

For example:

# Find a child concept in the current sentence
person = concept.find_first('Person'))
Parameters

uri (str) – URI, or name, of the concept

Returns

The first matching instance of the given concept

Type

Concept

find(uri: str)#

Find all instances of the concept the with the given URI in the sentence

For example:

# List all persons in the sentence
for person in concept.find('Person')):
    print(person)
Parameters

uri (str) – URI, or name, of the concept

Returns

The matching instances of the given concept

Return type

A list of Concept

__getitem__(value)#
property text#
Returns

A string representation of the sentence

Return type

str

property stems#
Returns

A string representation of the sentence with the stems

Return type

str

property begin_offset: int#
Returns

The begin offset of the annotation

Type

int

property end_offset: int#
Returns

The end offset of the annotation

Type

int

property is_concept: bool#
Returns

Whether the annotation is a Concept

Return type

bool

property is_sentence: bool#
Returns

Whether the annotation is a Sentence

Return type

bool

property is_token: bool#
Returns

Whether the annotation is a Token

Return type

bool

See also the corresponding JSON schema.