Skip to main content

Python SDK

The example below shows how to call the General API from Python 3.6+ with our Python SDK.

Installation

pip install geneea-nlp-client

Simple Call

Executing this code:

from geneeanlpclient import g3

requestBuilder = g3.Request.Builder(analyses=[g3.AnalysisType.ENTITIES])

with g3.Client.create(userKey=<your user key>) as analyzer:
result = analyzer.analyze(requestBuilder.build(id=str(1), text='The pizza in London was great!'))

for e in result.entities:
print(f'\t{e.type}: {e.stdForm}')

prints the only named entity in the text to the console:

location: London

The examples directory in the public repository contains more examples.

SDK

The SDK has the following main classes:

  • Client – a simple REST client
  • Request – an object encapsulating the request the Client send to the G3 API; typically it is built via RequestBuilder
  • Analysis – object encapsulating the response of the API
  • Readers/Writers – objects for reading/writing from/to json

The code is publicly available at bitbucket .