blob: b3a0edf7a19a1d22117040aa049c542f6de33f9b [file] [log] [blame]
Marc Kupietze95108e2019-09-18 13:23:58 +02001% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/KorAPQuery.R
3\docType{class}
4\name{KorAPQuery-class}
5\alias{KorAPQuery-class}
6\alias{KorAPQuery}
7\alias{initialize,KorAPQuery-method}
8\alias{fetchNext,KorAPQuery-method}
9\alias{fetchNext}
10\alias{fetchAll,KorAPQuery-method}
11\alias{fetchAll}
12\alias{fetchRest,KorAPQuery-method}
13\alias{fetchRest}
Marc Kupietz3f575282019-10-04 14:46:04 +020014\alias{frequencyQuery,KorAPConnection-method}
15\alias{frequencyQuery}
Marc Kupietze95108e2019-09-18 13:23:58 +020016\alias{format.KorAPQuery}
17\alias{show,KorAPQuery-method}
Marc Kupietze2038322021-03-04 18:24:02 +010018\alias{collocationScoreQuery,KorAPConnection-method}
19\alias{collocationScoreQuery}
Marc Kupietze95108e2019-09-18 13:23:58 +020020\title{Class KorAPQuery}
21\usage{
Marc Kupietz76685f52019-11-25 17:46:06 +010022\S4method{initialize}{KorAPQuery}(
23 .Object,
24 korapConnection = NULL,
25 request = NULL,
26 vc = "",
27 totalResults = 0,
28 nextStartIndex = 0,
29 fields = c("corpusSigle", "textSigle", "pubDate", "pubPlace", "availability",
30 "textClass", "snippet"),
31 requestUrl = "",
32 webUIRequestUrl = "",
33 apiResponse = NULL,
34 hasMoreMatches = FALSE,
35 collectedMatches = NULL
36)
Marc Kupietze95108e2019-09-18 13:23:58 +020037
Marc Kupietz76685f52019-11-25 17:46:06 +010038\S4method{fetchNext}{KorAPQuery}(
39 kqo,
40 offset = kqo@nextStartIndex,
41 maxFetch = maxResultsPerPage,
42 verbose = kqo@korapConnection@verbose
43)
Marc Kupietze95108e2019-09-18 13:23:58 +020044
Marc Kupietz76685f52019-11-25 17:46:06 +010045\S4method{fetchAll}{KorAPQuery}(kqo, verbose = kqo@korapConnection@verbose)
Marc Kupietze95108e2019-09-18 13:23:58 +020046
Marc Kupietz76685f52019-11-25 17:46:06 +010047\S4method{fetchRest}{KorAPQuery}(kqo, verbose = kqo@korapConnection@verbose)
Marc Kupietze95108e2019-09-18 13:23:58 +020048
Marc Kupietz76685f52019-11-25 17:46:06 +010049\S4method{frequencyQuery}{KorAPConnection}(
50 kco,
51 query,
52 vc = "",
53 conf.level = 0.95,
54 as.alternatives = FALSE,
55 ...
56)
Marc Kupietz3f575282019-10-04 14:46:04 +020057
Marc Kupietze95108e2019-09-18 13:23:58 +020058\method{format}{KorAPQuery}(x, ...)
59
60\S4method{show}{KorAPQuery}(object)
Marc Kupietze2038322021-03-04 18:24:02 +010061
62\S4method{collocationScoreQuery}{KorAPConnection}(
63 kco,
64 node,
65 collocate,
66 vc = "",
67 lemmatizeNodeQuery = FALSE,
68 lemmatizeCollocateQuery = FALSE,
69 leftContextSize = 5,
70 rightContextSize = 5,
71 scoreFunctions = defaultAssociationScoreFunctions(),
72 smoothingConstant = 0.5
73)
Marc Kupietze95108e2019-09-18 13:23:58 +020074}
75\arguments{
76\item{.Object}{}
77
Marc Kupietzb8972182019-09-20 21:33:46 +020078\item{korapConnection}{KorAPConnection object}
79
Marc Kupietze95108e2019-09-18 13:23:58 +020080\item{request}{query part of the request URL}
81
Marc Kupietze2038322021-03-04 18:24:02 +010082\item{vc}{string describing the virtual corpus in which the query should be performed. An empty string (default) means the whole corpus, as far as it is license-wise accessible.}
Marc Kupietze95108e2019-09-18 13:23:58 +020083
84\item{totalResults}{number of hits the query has yielded}
85
86\item{nextStartIndex}{at what index to start the next fetch of query results}
87
88\item{fields}{what data / metadata fields should be collected}
89
90\item{requestUrl}{complete URL of the API request}
91
92\item{webUIRequestUrl}{URL of a web frontend request corresponding to the API request}
93
94\item{apiResponse}{data-frame representation of the JSON response of the API request}
95
Marc Kupietz7776dec2019-09-27 16:59:02 +020096\item{hasMoreMatches}{logical that signals if more query results can be fetched}
Marc Kupietze95108e2019-09-18 13:23:58 +020097
98\item{collectedMatches}{matches already fetched from the KorAP-API-server}
99
100\item{kqo}{object obtained from \code{\link{corpusQuery}}}
101
102\item{offset}{start offset for query results to fetch}
103
104\item{maxFetch}{maximum number of query results to fetch}
105
106\item{verbose}{print progress information if true}
107
Marc Kupietz3f575282019-10-04 14:46:04 +0200108\item{kco}{\code{\link{KorAPConnection}} object (obtained e.g. from \code{new("KorAPConnection")}}
109
110\item{query}{string that contains the corpus query. The query language depends on the \code{ql} parameter. Either \code{query} must be provided or \code{KorAPUrl}.}
Marc Kupietze95108e2019-09-18 13:23:58 +0200111
Marc Kupietz43a6ade2020-02-18 17:01:44 +0100112\item{conf.level}{confidence level of the returned confidence interval (passed through \code{\link{ci}} to \code{\link{prop.test}}).}
Marc Kupietz0c29cea2019-10-09 08:44:36 +0200113
Marc Kupietz71d6e052019-11-22 18:42:10 +0100114\item{as.alternatives}{LOGICAL that specifies if the query terms should be treated as alternatives. If \code{as.alternatives} is TRUE, the sum over all query hits, instead of the respective vc token sizes is used as total for the calculation of relative frequencies.}
115
Marc Kupietze95108e2019-09-18 13:23:58 +0200116\item{...}{further arguments passed to or from other methods}
117
Marc Kupietz3f575282019-10-04 14:46:04 +0200118\item{x}{KorAPQuery object}
119
Marc Kupietze95108e2019-09-18 13:23:58 +0200120\item{object}{KorAPQuery object}
Marc Kupietze2038322021-03-04 18:24:02 +0100121
122\item{node}{target word}
123
124\item{collocate}{collocate of target word}
125
126\item{lemmatizeNodeQuery}{logical, set to TRUE if node query should be lemmatized, i.e. x -> [tt/l=x]}
127
128\item{lemmatizeCollocateQuery}{logical, set to TRUE if collocate query should be lemmatized, i.e. x -> [tt/l=x]}
129
130\item{leftContextSize}{size of the left context window}
131
132\item{rightContextSize}{size of the right context window}
133
134\item{scoreFunctions}{named list of score functions of the form function(O1, O2, O, N, E, window_size), see e.g. \link{pmi}}
135
136\item{smoothingConstant}{smoothing constant will be added to all observed values}
Marc Kupietze95108e2019-09-18 13:23:58 +0200137}
138\value{
139The \code{kqo} input object with updated slots \code{collectedMatches}, \code{apiResponse}, \code{nextStartIndex}, \code{hasMoreMatches}
Marc Kupietze2038322021-03-04 18:24:02 +0100140
141tibble with query KorAP web request URL, all observed values and association scores
Marc Kupietze95108e2019-09-18 13:23:58 +0200142}
143\description{
Marc Kupietza6e4ee62021-03-05 09:00:15 +0100144This class provides methods to perform different kinds of queries on the KorAP API server.
145\code{KorAPQuery} objects, which are typically created by the \code{\link{corpusQuery}} method,
146represent the current state of a query to a KorAP server.
Marc Kupietz3f575282019-10-04 14:46:04 +0200147
148\bold{\code{fetchNext}} fetches the next bunch of results of a KorAP query.
149
Marc Kupietza6e4ee62021-03-05 09:00:15 +0100150\bold{\code{fetchAll}} fetches allf results of a KorAP query.
151
Marc Kupietz3f575282019-10-04 14:46:04 +0200152\bold{\code{frequencyQuery}} combines \code{\link{corpusQuery}}, \code{\link{corpusStats}} and
153\code{\link{ci}} to compute a table with the relative frequencies and
154confidence intervals of one ore multiple search terms across one or multiple
155virtual corpora.
Marc Kupietze2038322021-03-04 18:24:02 +0100156
157\bold{\code{collocationScoreQuery}} computes various collocation association scores
158based on \code{\link{frequencyQuery}}s for a target word and a collocate.
Marc Kupietze95108e2019-09-18 13:23:58 +0200159}
160\examples{
Marc Kupietz657d8e72020-02-25 18:31:50 +0100161\donttest{q <- new("KorAPConnection") \%>\% corpusQuery("Ameisenplage") \%>\% fetchNext()
Marc Kupietze95108e2019-09-18 13:23:58 +0200162q@collectedMatches
Marc Kupietz657d8e72020-02-25 18:31:50 +0100163}
Marc Kupietze95108e2019-09-18 13:23:58 +0200164
Marc Kupietz05b22772020-02-18 21:58:42 +0100165\donttest{
Marc Kupietz69cc54a2019-09-30 12:06:54 +0200166q <- new("KorAPConnection") \%>\% corpusQuery("Ameisenplage") \%>\% fetchAll()
Marc Kupietze95108e2019-09-18 13:23:58 +0200167q@collectedMatches
Marc Kupietz05b22772020-02-18 21:58:42 +0100168}
Marc Kupietze95108e2019-09-18 13:23:58 +0200169
Marc Kupietz05b22772020-02-18 21:58:42 +0100170\donttest{
171q <- new("KorAPConnection") \%>\% corpusQuery("Ameisenplage") \%>\% fetchRest()
172q@collectedMatches
173}
174
175\donttest{
Marc Kupietz3f575282019-10-04 14:46:04 +0200176new("KorAPConnection", verbose = TRUE) \%>\%
177 frequencyQuery(c("Mücke", "Schnake"), paste0("pubDate in ", 2000:2003))
Marc Kupietz05b22772020-02-18 21:58:42 +0100178}
Marc Kupietz3f575282019-10-04 14:46:04 +0200179
Marc Kupietze2038322021-03-04 18:24:02 +0100180\donttest{
181new("KorAPConnection", verbose = TRUE) \%>\%
182 collocationScoreQuery("Grund", "triftiger")
183}
184
185\donttest{
186new("KorAPConnection", verbose = TRUE) \%>\%
187collocationScoreQuery("Grund", c("guter", "triftiger"),
188 scoreFunctions = list(localMI = function(O1, O2, O, N, E, window_size) { O * log2(O/E) }) )
189}
190
191\donttest{
192library(highcharter)
193library(tidyr)
194new("KorAPConnection", verbose = TRUE) \%>\%
195 collocationScoreQuery("Team", "agil", vc = paste("pubDate in", c(2014:2018)),
196 lemmatizeNodeQuery = TRUE, lemmatizeCollocateQuery = TRUE) \%>\%
197 pivot_longer(14:last_col(), names_to = "measure", values_to = "score") \%>\%
198 hchart(type="spline", hcaes(label, score, group=measure)) \%>\%
199 hc_add_onclick_korap_search()
200}
201
Marc Kupietze95108e2019-09-18 13:23:58 +0200202}
203\references{
204\url{https://ids-pub.bsz-bw.de/frontdoor/index/index/docId/9026}
205}