Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 1 | % 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 Kupietz | 3f57528 | 2019-10-04 14:46:04 +0200 | [diff] [blame] | 14 | \alias{frequencyQuery,KorAPConnection-method} |
| 15 | \alias{frequencyQuery} |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 16 | \alias{format.KorAPQuery} |
| 17 | \alias{show,KorAPQuery-method} |
Marc Kupietz | e203832 | 2021-03-04 18:24:02 +0100 | [diff] [blame^] | 18 | \alias{collocationScoreQuery,KorAPConnection-method} |
| 19 | \alias{collocationScoreQuery} |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 20 | \title{Class KorAPQuery} |
| 21 | \usage{ |
Marc Kupietz | 76685f5 | 2019-11-25 17:46:06 +0100 | [diff] [blame] | 22 | \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 Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 37 | |
Marc Kupietz | 76685f5 | 2019-11-25 17:46:06 +0100 | [diff] [blame] | 38 | \S4method{fetchNext}{KorAPQuery}( |
| 39 | kqo, |
| 40 | offset = kqo@nextStartIndex, |
| 41 | maxFetch = maxResultsPerPage, |
| 42 | verbose = kqo@korapConnection@verbose |
| 43 | ) |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 44 | |
Marc Kupietz | 76685f5 | 2019-11-25 17:46:06 +0100 | [diff] [blame] | 45 | \S4method{fetchAll}{KorAPQuery}(kqo, verbose = kqo@korapConnection@verbose) |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 46 | |
Marc Kupietz | 76685f5 | 2019-11-25 17:46:06 +0100 | [diff] [blame] | 47 | \S4method{fetchRest}{KorAPQuery}(kqo, verbose = kqo@korapConnection@verbose) |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 48 | |
Marc Kupietz | 76685f5 | 2019-11-25 17:46:06 +0100 | [diff] [blame] | 49 | \S4method{frequencyQuery}{KorAPConnection}( |
| 50 | kco, |
| 51 | query, |
| 52 | vc = "", |
| 53 | conf.level = 0.95, |
| 54 | as.alternatives = FALSE, |
| 55 | ... |
| 56 | ) |
Marc Kupietz | 3f57528 | 2019-10-04 14:46:04 +0200 | [diff] [blame] | 57 | |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 58 | \method{format}{KorAPQuery}(x, ...) |
| 59 | |
| 60 | \S4method{show}{KorAPQuery}(object) |
Marc Kupietz | e203832 | 2021-03-04 18:24:02 +0100 | [diff] [blame^] | 61 | |
| 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 Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 74 | } |
| 75 | \arguments{ |
| 76 | \item{.Object}{…} |
| 77 | |
Marc Kupietz | b897218 | 2019-09-20 21:33:46 +0200 | [diff] [blame] | 78 | \item{korapConnection}{KorAPConnection object} |
| 79 | |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 80 | \item{request}{query part of the request URL} |
| 81 | |
Marc Kupietz | e203832 | 2021-03-04 18:24:02 +0100 | [diff] [blame^] | 82 | \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 Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 83 | |
| 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 Kupietz | 7776dec | 2019-09-27 16:59:02 +0200 | [diff] [blame] | 96 | \item{hasMoreMatches}{logical that signals if more query results can be fetched} |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 97 | |
| 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 Kupietz | 3f57528 | 2019-10-04 14:46:04 +0200 | [diff] [blame] | 108 | \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 Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 111 | |
Marc Kupietz | 43a6ade | 2020-02-18 17:01:44 +0100 | [diff] [blame] | 112 | \item{conf.level}{confidence level of the returned confidence interval (passed through \code{\link{ci}} to \code{\link{prop.test}}).} |
Marc Kupietz | 0c29cea | 2019-10-09 08:44:36 +0200 | [diff] [blame] | 113 | |
Marc Kupietz | 71d6e05 | 2019-11-22 18:42:10 +0100 | [diff] [blame] | 114 | \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 Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 116 | \item{...}{further arguments passed to or from other methods} |
| 117 | |
Marc Kupietz | 3f57528 | 2019-10-04 14:46:04 +0200 | [diff] [blame] | 118 | \item{x}{KorAPQuery object} |
| 119 | |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 120 | \item{object}{KorAPQuery object} |
Marc Kupietz | e203832 | 2021-03-04 18:24:02 +0100 | [diff] [blame^] | 121 | |
| 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 Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 137 | } |
| 138 | \value{ |
| 139 | The \code{kqo} input object with updated slots \code{collectedMatches}, \code{apiResponse}, \code{nextStartIndex}, \code{hasMoreMatches} |
Marc Kupietz | e203832 | 2021-03-04 18:24:02 +0100 | [diff] [blame^] | 140 | |
| 141 | tibble with query KorAP web request URL, all observed values and association scores |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 142 | } |
| 143 | \description{ |
Marc Kupietz | 43a6ade | 2020-02-18 17:01:44 +0100 | [diff] [blame] | 144 | \code{KorAPQuery} objects represent the current state of a query to a KorAP server. |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 145 | New \code{KorAPQuery} objects are typically created by the \code{\link{corpusQuery}} method. |
Marc Kupietz | 3f57528 | 2019-10-04 14:46:04 +0200 | [diff] [blame] | 146 | |
| 147 | \bold{\code{fetchNext}} fetches the next bunch of results of a KorAP query. |
| 148 | |
| 149 | \bold{\code{frequencyQuery}} combines \code{\link{corpusQuery}}, \code{\link{corpusStats}} and |
| 150 | \code{\link{ci}} to compute a table with the relative frequencies and |
| 151 | confidence intervals of one ore multiple search terms across one or multiple |
| 152 | virtual corpora. |
Marc Kupietz | e203832 | 2021-03-04 18:24:02 +0100 | [diff] [blame^] | 153 | |
| 154 | \bold{\code{collocationScoreQuery}} computes various collocation association scores |
| 155 | based on \code{\link{frequencyQuery}}s for a target word and a collocate. |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 156 | } |
| 157 | \examples{ |
Marc Kupietz | 657d8e7 | 2020-02-25 18:31:50 +0100 | [diff] [blame] | 158 | \donttest{q <- new("KorAPConnection") \%>\% corpusQuery("Ameisenplage") \%>\% fetchNext() |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 159 | q@collectedMatches |
Marc Kupietz | 657d8e7 | 2020-02-25 18:31:50 +0100 | [diff] [blame] | 160 | } |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 161 | |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 162 | \donttest{ |
Marc Kupietz | 69cc54a | 2019-09-30 12:06:54 +0200 | [diff] [blame] | 163 | q <- new("KorAPConnection") \%>\% corpusQuery("Ameisenplage") \%>\% fetchAll() |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 164 | q@collectedMatches |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 165 | } |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 166 | |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 167 | \donttest{ |
| 168 | q <- new("KorAPConnection") \%>\% corpusQuery("Ameisenplage") \%>\% fetchRest() |
| 169 | q@collectedMatches |
| 170 | } |
| 171 | |
| 172 | \donttest{ |
Marc Kupietz | 3f57528 | 2019-10-04 14:46:04 +0200 | [diff] [blame] | 173 | new("KorAPConnection", verbose = TRUE) \%>\% |
| 174 | frequencyQuery(c("Mücke", "Schnake"), paste0("pubDate in ", 2000:2003)) |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 175 | } |
Marc Kupietz | 3f57528 | 2019-10-04 14:46:04 +0200 | [diff] [blame] | 176 | |
Marc Kupietz | e203832 | 2021-03-04 18:24:02 +0100 | [diff] [blame^] | 177 | \donttest{ |
| 178 | new("KorAPConnection", verbose = TRUE) \%>\% |
| 179 | collocationScoreQuery("Grund", "triftiger") |
| 180 | } |
| 181 | |
| 182 | \donttest{ |
| 183 | new("KorAPConnection", verbose = TRUE) \%>\% |
| 184 | collocationScoreQuery("Grund", c("guter", "triftiger"), |
| 185 | scoreFunctions = list(localMI = function(O1, O2, O, N, E, window_size) { O * log2(O/E) }) ) |
| 186 | } |
| 187 | |
| 188 | \donttest{ |
| 189 | library(highcharter) |
| 190 | library(tidyr) |
| 191 | new("KorAPConnection", verbose = TRUE) \%>\% |
| 192 | collocationScoreQuery("Team", "agil", vc = paste("pubDate in", c(2014:2018)), |
| 193 | lemmatizeNodeQuery = TRUE, lemmatizeCollocateQuery = TRUE) \%>\% |
| 194 | pivot_longer(14:last_col(), names_to = "measure", values_to = "score") \%>\% |
| 195 | hchart(type="spline", hcaes(label, score, group=measure)) \%>\% |
| 196 | hc_add_onclick_korap_search() |
| 197 | } |
| 198 | |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 199 | } |
| 200 | \references{ |
| 201 | \url{https://ids-pub.bsz-bw.de/frontdoor/index/index/docId/9026} |
| 202 | } |