Add support for API token authorization

To use authorization based on an API token in subsequent queries,
initialize your KorAP connection with
kco <- new("KorAPConnection", apiToken="<API Token>").
In order to make the API token persistent for the currently
used KorAPUrl (you can have one token per KorAPUrl / KorAP server
instance), use persistApiToken(kco). This will store it in your keyring
using the keyring package.
Subsequent new("KorAPConnection") calls will then automatically
retrieve the token from your keying.
To stop using a persisted token, call clearApiToken(kco).

Please note that for DeReKo, authorized queries will behave differently
inside and outside the IDS, because of the special license situation.
This concerns also cached results which do not take into account from
where a request was issued. If you experience problems or unexpected
results, please try kco <- new("KorAPConnection", cache=FALSE) or use
clearCache to clear the cache completely.

Change-Id: Ic956b0dcf03574e63b62d5036622f30a6cf27f8a
5 files changed
tree: 6a6baa7892f6911e81da3e20a7399ea8d3f4108a
  1. demo/
  2. man/
  3. R/
  4. .gitignore
  5. .Rbuildignore
  6. DESCRIPTION
  7. LICENSE
  8. NAMESPACE
  9. Readme.md
  10. RKorAPClient.Rproj
Readme.md

KorAP web service client package for R: tidyverse branch

Description

Simple R package to access the web service API of the KorAP Corpus Analysis Platform devloped at the IDS Mannheim

This packgage is in its early stages and not stable yet! In particular, please expect that, at this early stage, objects, functions, parameters as well as their names or identifiers will still change continuously without any notification. Use it on your own risk!

Getting started

At this point there is no binary package on CRAN yet, so you have to install the development version from our Gerrit server using the devtool package:

# install.packages("devtools")
library(devtools)
install_git("https://korap.ids-mannheim.de/gerrit/KorAP/RKorAPClient", ref="tidy")
library(RKorAPClient)
?corpusQuery
?freqeuncyQuery

Hello world

library(RKorAPClient)
new("KorAPConnection", verbose=TRUE) %>% corpusQuery("Hello world") %>% fetchAll()

Example

library(RKorAPClient)
library(ggplot2)
kco <- new("KorAPConnection", verbose=TRUE)
expand_grid(condition = c("textDomain = /Wirtschaft.*/", "textDomain != /Wirtschaft.*/"), 
            year = (2002:2018)) %>%
    cbind(frequencyQuery(kco, "[tt/l=Heuschrecke]", paste0(.$condition," & pubDate in ", .$year)))  %>%
    ipm() %>%
    ggplot(aes(x = year, y = ipm, fill = condition, colour = condition)) +
    geom_freq_by_year_ci()

Demos

More elaborate R scripts demonstrating the use of the package can be found in the demo folder.

Development and License

Authors: Marc Kupietz

Copyright (c) 2019, IDS 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

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 (Hrsg.): Proceedings of the Internation 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.