Add functions wordEmbedding and frequencyRank
Change-Id: Ic08c9660e3085d46143af8c4dfd32cfb2eca2aca
diff --git a/R/derekovecs.R b/R/derekovecs.R
index 53efb67..721d79d 100644
--- a/R/derekovecs.R
+++ b/R/derekovecs.R
@@ -48,6 +48,32 @@
derekovecsApiCall("", word = word, json = 1, ...)$list[[1]]
}
+#' Get word embedding
+#'
+#' Get the normalized embedding vector of a word from the derekovecs model.
+#'
+#' @param word The word to get the paradigmatic neighbours for.
+#' @param ... Additional parameters to pass to the API.
+#' @return Normalized embedding vector of the given word.
+#' @export
+#'
+wordEmbedding <- function(word = "Test", ...) {
+ derekovecsApiCall("", word = word, n=1, json = 1, ...)[["list"]][[1]][["vector"]][[1]]
+}
+
+#' Get frequency rank
+#'
+#' Gets the frequency rank of a word in the training data.
+#'
+#' @param word The word to get the frequency rank of.
+#' @param ... Additional parameters to pass to the API.
+#' @return Frequency rank.
+#' @export
+#'
+frequencyRank <- function(word = "Test", ...) {
+ derekovecsApiCall("/getWord", w = word, ...)$frequencyRank
+}
+
#' Get collocation scores
#'
#' Calculate the association scores between a node (target word) and words in a window around the it.