Learn R Programming

RKorAPClient (version 0.5.9)

KorAPConnection-class: Class KorAPConnection

Description

KorAPConnection objects represent the connection to a KorAP server. New KorAPConnection objects can be created by new("KorAPConnection").

Usage

# S4 method for KorAPConnection
initialize(
  .Object,
  KorAPUrl = "https://korap.ids-mannheim.de/",
  apiVersion = "v1.0",
  apiUrl,
  accessToken = getAccessToken(KorAPUrl),
  userAgent = "R-KorAP-Client",
  timeout = 110,
  verbose = FALSE,
  cache = TRUE
)

# S4 method for KorAPConnection persistAccessToken(kco, accessToken = kco@accessToken)

# S4 method for KorAPConnection clearAccessToken(kco)

# S4 method for KorAPConnection apiCall(kco, url, json = TRUE, getHeaders = FALSE, cache = kco@cache)

# S4 method for KorAPConnection clearCache(kco)

# S4 method for KorAPConnection show(object)

Arguments

.Object

KorAPConnection object

KorAPUrl

the URL of the KorAP server instance you want to access.

apiVersion

which version of KorAP's API you want to connect to.

apiUrl

URL of the KorAP web service.

accessToken

OAuth2 access token. To use authorization based on an access token in subsequent queries, initialize your KorAP connection with kco <- new("KorAPConnection", accessToken="<access 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 persistAccessToken(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 clearAccessToken(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.

userAgent

user agent string.

timeout

time out in seconds.

verbose

logical. Decides whether following operations will default to be verbose.

cache

logical. Decides if API calls are cached locally. You can clear the cache with clearCache().

kco

KorAPConnection object

url

request url

json

logical that determines if json result is expected

getHeaders

logical that determines if headers and content should be returned (as a list)

object

KorAPConnection object

Value

KorAPConnection object that can be used e.g. with corpusQuery

Examples

Run this code
# NOT RUN {
kcon <- new("KorAPConnection", verbose = TRUE)
kq <- corpusQuery(kcon, "Ameisenplage")
kq <- fetchAll(kq)
# }
# NOT RUN {
# }
# NOT RUN {
kcon <- new("KorAPConnection", verbose = TRUE, accessToken="e739u6eOzkwADQPdVChxFg")
kq <- corpusQuery(kcon, "Ameisenplage", metadataOnly=FALSE)
kq <- fetchAll(kq)
kq@collectedMatches$snippet
# }
# NOT RUN {
# }
# NOT RUN {
kco <- new("KorAPConnection", accessToken="e739u6eOzkwADQPdVChxFg")
persistAccessToken(kco)
# }
# NOT RUN {
# }
# NOT RUN {
kco <- new("KorAPConnection")
clearAccessToken(kco)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab