Skip to main content

European Language Grid Python SDK

The European Language Grid is the primary platform for Language Technology in Europe. With the ELG Python SDK, you can use LT services and search the catalog inside your Python projects.

Installation

Via pip / PyPI

pip install elg

Register on the ELG

Please visit the ELG website to create a user account if you haven't got one already.

Functionalities

Use LTs

Initialize LT service

LT Services can be initialized as Service objects using the service_id parameter and an integer corresponding to the LT service you want to use.
In the following code example, 474 corresponds to the Cogito Discover Named Entity Recognizer (notice the ID at the end of the URL). For more LT services, search the catalog via the Catalog functionality (see section below) or visit the list of LT services on the ELG.

from elg import Service

# Init LT service using its ID
lt = Service.from_id(474)

This requires you to login to your ELG account via the URL that is printed on your terminal.

ELG Login

After successful login, your tokens are saved as ~/.cache/elg/tokens.json, so you do not need to log in again for subsequent calls.

Run LT service

You can either pass an input file or a string / raw text.

# Pass an input file that should be processed by the LT service
result = lt("path/to/file")

# You can also directly pass raw text to the LT service in most cases
result = lt("Did Nikola Tesla live in Berlin?")

Use corpus

from elg import Corpus

corpus = Corpus.from_id(913)
corpus.download()

Use the catalog

from elg import Catalog

catalog = Catalog()

# Search and get the result as a list of Entity
results = catalog.search(
    resource = "Tool/Service", # "Corpus", "Lexical/Conceptual resource" or "Language description"
    function = "Machine Translation", # function should be pass only if resource is set to "Tool/Service"
    languages = ["en", "fr"], # string or list if multiple languages
    limit = 100,
)

# search interactively 
catalog.interactive_search(
    search = "keyword1 keyword2 ...",
    resource = "Tool/Service", # "Corpus", "Lexical/Conceptual resource" or "Language description"
    function = "Machine Translation", # function should be pass only if resource is set to "Tool/Service"
    languages = ["en", "fr"], # string or list if multiple languages
)

Create a LT service object from the results

service = Service.from_entity(results[0])
result = service("Did Nikola Tesla live in Berlin?")

Get info of an entity

from elg import Entity

entity = Entity.from_id(476)
print(entity)

Benchmark

You can also run a benchmark that evaluates multiple services receiving the same input:

from elg import Benchmark

ben = Benchmark.from_ids([610, 624])

result = ben(["Bush is the president of the USA and lives in Washington", "My name is Rémi and I live in France"], number_of_runs=4)

df = result.compare()
print("General comparison:\n", df)
df = result.compare_results()
print("Comparison of the results:\n", df)
df = result.compare_response_times()
print("Comparison of the response time:\n", df)

You can investigate the results by saving the output from the bench call to a variable or by accessing bench.services.

CLI

elg-cli search *term1* *term2* ... *termN* --lang "" --resource "" --function ""
elg-cli info *id*
elg-cli run *id* --authentication_file path/to/tokens.json --data_file path/to/file

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elg-0.3.5.tar.gz (38.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elg-0.3.5-py3-none-any.whl (51.4 kB view details)

Uploaded Python 3

File details

Details for the file elg-0.3.5.tar.gz.

File metadata

  • Download URL: elg-0.3.5.tar.gz
  • Upload date:
  • Size: 38.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1

File hashes

Hashes for elg-0.3.5.tar.gz
Algorithm Hash digest
SHA256 1cbd8ba70a8f175f8149826d9db208d58b8d0b2767201417006136ee7587f76c
MD5 e1e6bb6bde3167645f5f13de6e8d12eb
BLAKE2b-256 fa81dea84fa998a7a05d8402a7bdb4c9909efb0f04d0db983436ee1680166856

See more details on using hashes here.

File details

Details for the file elg-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: elg-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 51.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1

File hashes

Hashes for elg-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ff85ce13055c49174c00775b93cea637e620c79d3fbb6d856b79b1f96af0a225
MD5 7facd2d05a3ba03bce0b5edff26c82d9
BLAKE2b-256 64b7c9b9484c9e76cf3f386bd6e103626c7e494a95f1d30e07b73b6d56347f2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page