wiki:SkE/Methods/example

Sketch Engine API Documentation

Back to API overview

Examples

This page provides links to various API scripts that show how the Sketch Engine can be accessed automatically.

Example - Corpus Architect authentication and JSON

This example will show you how to access the Sketch Engine API through the Corpus Architect (at  http://beta.sketchengine.co.uk) and get frequencies for a list of CQL queries by the means of JSON (compare to http authenticated version below).

(the java version needs a module for JSON parsing and a non-standard   org.apache.commons.httpclient module)

Example in Java (view full source) Download

Example in Python (view full source) Download

Examples - Basic http authentication and JSON

This example demonstrates how to get a list of frequencies from a list of CQL queries. Using the basic http authentication (it is common for local installations but not compatible with the beta.sketchengine.co.uk server) and JSON query (compare to the CA auth version above).

Example3 in Java (view full source) Download

Example3 in Python (view full source) Download

The following example presents an easy way how to convert usual structures (dictionaries for Python, Maps for Java) to JSON objects and how to use the obtained JSON objects as a query to Sketch Engine. Available for Java and Python.

Example2 in Java (view full source) Download

Example2 in Python (view full source) Download

This example presents how to connect the Sketch Engine service on your server using Basic http authentication (it will not work for sketchengine.co.uk, CA auth), send a query (in this particular case simple word list query without JSON) and parse the result for JSON syntax. Note that many modules for JSON parsing are available, you do not have to use the one from the examples.

Example1 in Java (view full source) Download

Example1 in Python (view full source) Download

Minimalistic example - no authentication, no JSON parsing

This exampe shows bare bones of getting results from the Sketch Engine without any authentication or parsing overhead.

Example in Java (view full source)

Example in Python (view full source)


Back to API overview

Attachments