commit | 0915894f597ded465e466eeecd6820b7a392b601 | [log] [tgz] |
---|---|---|
author | Marc Kupietz <kupietz@ids-mannheim.de> | Fri Jun 26 22:40:49 2020 +0200 |
committer | Marc Kupietz <kupietz@ids-mannheim.de> | Fri Jun 26 22:40:49 2020 +0200 |
tree | bc068032c263cebbf8b80c2ebedd8cdfcad2bf14 | |
parent | 6d539746db12811ec12e8cb2a413de2630792186 [diff] |
Improve Readme.md Change-Id: I8deb36fe9e952c3f976069c82a06ca05475166fa
Python client wrapper 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. The latter also automatically translates between R data frames (or tibbles) and pandas DataFrames.
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
set R_HOME="C:Program Files\R\R-4.0.2" set R_USER=%R_HOME% set PATH=%R_HOME%\bin;%R_HOME%\bin\x64;%PATH%
Rscript -e "install.packages('RKorAPClient', repos='https://cloud.r-project.org/')"
python3 -m pip install git+https://github.com/KorAP/PythonKorAPClient
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.
Please note that some arguments in the original RKorAPClient functions use characters that are not allowed in Python keyword argument names. For these cases, you can however use Python's **kwargs
syntax. For example, to get the result of corpusStats
as a pandas.DataFrame
, and print the size of the whole corpus in tokens, you can write:
from KorAPClient import KorAPConnection kcon = KorAPConnection(verbose=True) print(kcon.corpusStats(**{"as.df": True})['tokens'])
from KorAPClient import KorAPClient, KorAPConnection import plotly.express as px QUERY = "Hello World" YEARS = range(2010, 2019) COUNTRIES = ["DE", "CH"] kcon = KorAPConnection(verbose=True) vcs = ["textType=/Zeit.*/ & pubPlaceKey=" + c + " & pubDate in " + str(y) for c in COUNTRIES for y in YEARS] df = KorAPClient.ipm(kcon.frequencyQuery(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()
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.
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 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.
Kupietz, Marc / Margaretha, Eliza / Diewald, Nils / Lüngen, Harald / Fankhauser, Peter (2019): What’s New in EuReCo? Interoperability, Comparable Corpora, Licensing. In: Bański, Piotr/Barbaresi, Adrien/Biber, Hanno/Breiteneder, Evelyn/Clematide, Simon/Kupietz, Marc/Lüngen, Harald/Iliadi, Caroline (eds.): Proceedings of the International Corpus Linguistics Conference 2019 Workshop "Challenges in the Management of Large Corpora (CMLC-7)", 22nd of July Mannheim: Leibniz-Institut für Deutsche Sprache, 33-39.
Kupietz, Marc / Diewald, Nils / Margaretha, Eliza (2020): RKorAPClient: An R package for accessing the German Reference Corpus DeReKo via KorAP. In: Calzolari, Nicoletta, Frédéric Béchet, Philippe Blache, Khalid Choukri, Christopher Cieri, Thierry Declerck, Sara Goggi, Hitoshi Isahara, Bente Maegaard, Joseph Mariani, Hélène Mazo, Asuncion Moreno, Jan Odijk, Stelios Piperidis (eds.): Proceedings of The 12th Language Resources and Evaluation Conference (LREC 2020). Marseille: European Language Resources Association (ELRA), 7017-7023.