Analysis API for Python#

class eot.wowool.analysis.Analysis#

Analysis is a class that holds the results of an NLP analysis. Instances of this class can parse the NLP result and yield objects such as Sentence, Token and Concept to conveniently access the data behind those annotations. Furthermore, the class also provides a static method to parse raw JSON data as returned by, for example, the Portal API.

static parse(json_data: Union[dict, str], id=None)#

Create an Analysis instance from JSON (dict) data such as that returned from the Portal API.

analysis = Analysis.parse(json_raw)
Parameters

json_data (dict) – Raw JSON representation of the NLP analysis results

Return type

Analysis

__iter__()#

An Analysis instance is iterable, yielding Sentence objects. For example:

document = analyzer("some text")
for sentence in document: print(annotation)

Refer to the Sentence documentation for more information on further iteration.

Return type

Sentence

__getitem__(index: int) eot.wowool.annotation.sentence.Sentence#
Parameters

index (int) – Sentence index

Returns

The sentence at the given index or None if the index is out of range

Return type

Sentence

document = analyzer("This is the first sentence.")
first_sentence = document.analysis[0]
__len__()#
Returns

The number of sentences in the processed document

Return type

int

property language#
Returns

The identified language of the processed document

Return type

str

property sentences#
Returns

The sentences present in the analysis

Return type

A list of Sentence objects

rich()#
Returns

A rich string representation of the processed document object

Return type

str

to_json()#
Returns

A dictionary representing a JSON object of the processed document

Return type

dict

to_json_data() str#
Returns

A dictionary representing a JSON object of the processed document

Return type

dict

concepts(filter=<function _filter_pass_thru_concept>)#

Access the concepts in the analysis

Parameters

filter (Functor accepting a Concept and returning a bool) – Optional filter to select or discard concepts

Returns

A generator expression yielding the concepts in the processed document

Return type

Concepts

property text#
Returns

A string representation

Return type

str

reset()#

Reset the object, clearing all underlying data

Return type

Analysis

internal_annotations()#
Returns

A dictionary representing a JSON object of the processed document

Return type

dict

See also the corresponding JSON schema.