Marc Kupietz | e981eae | 2023-10-18 09:00:17 +0200 | [diff] [blame^] | 1 | library(httr2) |
| 2 | library(tidyverse) |
| 3 | |
| 4 | derekovecs_server = 'https://corpora.ids-mannheim.de/openlab/derekovecs/' |
| 5 | |
| 6 | DeReKoVecsCall <- 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 | |
| 14 | syntagmaticNeighbours <- function(word = "Test", ...) { |
| 15 | DeReKoVecsCall("", word=word, json=1, ...)$collocators |
| 16 | } |
| 17 | |
| 18 | countbasedCollocates <- function(w = "Test", ...) { |
| 19 | DeReKoVecsCall(method = "/getClassicCollocators", w = w, ...)$collocates |
| 20 | } |
| 21 | |
| 22 | paradigmaticNeighbours <- function(word = "Test", ...) { |
| 23 | DeReKoVecsCall("", word=word, json=1, ...)$list[[1]] |
| 24 | } |
| 25 | |
| 26 | collocationScores <- function(w, c, ...) { |
| 27 | DeReKoVecsCall("/getCollocationAssociation", w=w, c=c, ...)$collocates |
| 28 | } |
| 29 | |
| 30 | cosineSimilarity <- function(w1, w2, ...) { |
| 31 | DeReKoVecsCall("/getSimilarity", w1=w1, w2=w2, ...) |
| 32 | } |