Skip to main content

Python client for MINE system

Project description

minetext

MINE is a collaboration project between the Niedersächsische Staats- und Universitätsbibliothek Göttingen (SUB) and the Gesellschaft für wissenschaftliche Datenverarbeitung Göttingen (GWDG) with the goal to offer a convenient platform for text analysis.

minetext is a Python package, which facilitates the interaction between Python clients and the MINE system. For other clients, REST API of MINE is the way to go.

Note: minetext only works on Python version >=3.7.

To install it, simply run

$ pip install minetext

Examples

Simple search

from minetext import EsRequest, Mine

es_request = EsRequest(search_term='biology')
mine = Mine(es_request)

response = mine.search()

for hit in response:
    print(hit.meta.score, hit.mine.dc_title)

The example above shows us how to search in MINE. It is done in 3 steps:

  1. Line 3: create an instance of the EsRequest class with the query set to biology.
  2. Line 4: create an instance of the Mine class. Since all operations are done via this instance, creating this instance is the first required step to interact with the MINE system.
  3. Line 6: search for the word biology in MINE. To access the result, simply loop through the response, as shown in line 8.

Get full-text

from minetext import EsRequest, Mine

# Search for all documents which have full-text
es_request = EsRequest(search_term='_exists_:content')

mine = Mine(es_request)
mine.login()

response = mine.search()

for hit in response:
    print(hit.content)

To access the full-text, authentication is required. It is done by calling the login method of the Mine class, as shown in the example above on line 7. The full-text, if existed, will be accessible via hit.content. The syntax of the search_term is the query string syntax.

For consecutive runs, the credentials is re-used so that users do not have to log in for every run. For more details, please check the Authentication section.

Note: the response object is an instance of the Response class from the elasticsearch-dsl package

For more information, please refer to the full documentation.

Project details


Download files

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

Source Distribution

minetext-0.6.0.tar.gz (9.7 kB view hashes)

Uploaded Source

Built Distribution

minetext-0.6.0-py3-none-any.whl (13.9 kB view hashes)

Uploaded Python 3

Supported by

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