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 asSentence
,Token
andConcept
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
- __iter__()#
An
Analysis
instance is iterable, yieldingSentence
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
- __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
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
ofSentence
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
- property text#
- Returns
A string representation
- Return type
str
- internal_annotations()#
- Returns
A dictionary representing a JSON object of the processed document
- Return type
dict
See also the corresponding JSON schema.