tree: 332df90eaa6bb706229ea138fc8d00389f9601f0 [path history] [tgz]
  1. .github/
  2. examples/
  3. figures/
  4. KorAPClient/
  5. .gitignore
  6. LICENSE
  7. Readme.md
  8. setup.py
Readme.md

KorAP web service client package for Python

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. CI check Last commit GitHub closed issues GitHub issues

Description

Python client package to access the web service API of the KorAP Corpus Analysis Platform developed at IDS Mannheim. Currently, this is no native Python package. Internally, it uses KorAP's client package for R via rpy2. Please note that with a native implementation the API might change.

Installation

1. Install R (version >= 3.5)

From CRAN or, alternatively, on some recent Linux distributions:

#### Debian / Ubuntu
sudo apt-get install -y r-base r-base-dev r-cran-tidyverse r-cran-r.utils r-cran-pixmap r-cran-webshot r-cran-ade4 r-cran-segmented r-cran-purrr r-cran-dygraphs r-cran-cvst r-cran-quantmod r-cran-graphlayouts r-cran-rappdirs r-cran-ggdendro r-cran-seqinr r-cran-heatmaply r-cran-igraph r-cran-plotly libcurl4-gnutls-dev libssl-dev libxml2-dev libsodium-dev python3-pip python3-rpy2 python3-pandas

#### Fedora / CentOS / RHEL
sudo yum install -y R R-devel libcurl-devel openssl-devel libxml2-devel libsodium-devel python3-pandas

2. Install the R package

Rscript -e "install.packages('RKorAPClient')"

3. Install the Python package

python3 -m pip install git+https://github.com/KorAP/PythonKorAPClient

Documentation

Currently, there is no dedicated documentation for the Python variant of the library. Please refer to the Refernce Manual of RKorAPClient for now. For translating the R syntax to Python and vice versa, pleas refer to the rpy2 Documentation.

Examples

Frequencies over years and countries

from KorAPClient import KorAPClient
import plotly.express as px

QUERY = "Hello World"
YEARS = range(2010, 2019)
COUNTRIES = ["DE", "CH"]

kcon = KorAPClient.KorAPConnection(verbose=True)

vcs = ["textType=/Zeit.*/ & pubPlaceKey=" + c + " & pubDate in " + str(y) for c in COUNTRIES for y in YEARS]
df = KorAPClient.ipm(KorAPClient.frequencyQuery(kcon, QUERY, vcs))
df['Year'] = [y for c in COUNTRIES for y in YEARS]
df['Country'] = [c for c in COUNTRIES for y in YEARS]

fig = px.line(df, title=QUERY, x="Year", y="ipm", color="Country",
              error_y="conf.high", error_y_minus="conf.low")
fig.show()

Frequency per million words of “Hello World“ in DE vs. AT from 2010 to 2018 in newspapers and magazines

Accessed API Services

By using the KorAPClient you agree to the respective terms of use of the accessed KorAP API services which will be printed upon opening a connection.

Development and License

Author: Marc Kupietz

Copyright (c) 2020, Leibniz Institute for the German Language, Mannheim, Germany

This package is developed as part of the KorAP Corpus Analysis Platform at the Leibniz Institute for German Language (IDS).

It is published under the BSD-2 License.

Contributions

Contributions are very welcome!

Your contributions should ideally be committed via our Gerrit server to facilitate reviewing (see Gerrit Code Review - A Quick Introduction if you are not familiar with Gerrit). However, we are also happy to accept comments and pull requests via GitHub.

Please note that unless you explicitly state otherwise any contribution intentionally submitted for inclusion into this software shall – as this software itself – be under the BSD-2 License.

References