Sentence API for Python#
- class eot.wowool.annotation.Sentence#
Bases:
eot.wowool.annotation.annotation.BasicAnnotation
Sentence
is a class that contains all theTokens
andConcepts
of a sentence- __init__(begin_offset: int, end_offset: int) None #
Initialize a
Sentence
instance- Parameters
begin_offset (
int
) – Begin offset of the sentenceend_offset (
int
) – End offset of the sentence
- Returns
An initialized sentence
- Return type
- rich() str #
- Returns
The rich string representation of the sentence
- Return type
str
- __iter__()#
A
Sentence
instance is iterable, yieldingAnnotation
objects. For example:for annotation in sentence: print(annotation)
- Return type
- __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
- 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
- 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
ofConcept
- __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
See also the corresponding JSON schema.