blob: 24b6d89c2482c646a81609fe2115141cd36d4d94 [file] [log] [blame]
Marc Kupietze981eae2023-10-18 09:00:17 +02001library(httr2)
2library(tidyverse)
3
4derekovecs_server = 'https://corpora.ids-mannheim.de/openlab/derekovecs/'
5
6DeReKoVecsCall <- function(method="", ...) {
7 request(derekovecs_server) %>%
8 req_url_path_append(method) %>%
9 req_url_query(...) %>%
10 req_perform() %>%
11 resp_body_json(simplifyVector = TRUE)
12}
13
14syntagmaticNeighbours <- function(word = "Test", ...) {
15 DeReKoVecsCall("", word=word, json=1, ...)$collocators
16}
17
18countbasedCollocates <- function(w = "Test", ...) {
19 DeReKoVecsCall(method = "/getClassicCollocators", w = w, ...)$collocates
20}
21
22paradigmaticNeighbours <- function(word = "Test", ...) {
23 DeReKoVecsCall("", word=word, json=1, ...)$list[[1]]
24}
25
26collocationScores <- function(w, c, ...) {
27 DeReKoVecsCall("/getCollocationAssociation", w=w, c=c, ...)$collocates
28}
29
30cosineSimilarity <- function(w1, w2, ...) {
31 DeReKoVecsCall("/getSimilarity", w1=w1, w2=w2, ...)
32}