rm(list = ls()) closeAllConnections()
library(rstudioapi) library(stringdist) library(lattice) library(latticeExtra) library(vwr) library(strngrams)
#’ Set directory & files #’ ——————— current_path = getActiveDocumentContext()$path rootdir = setwd(dirname(current_path)) getwd()
old20_score <- function(target_word, word_list) {
distances <- stringdist::stringdist(target_word, word_list, method = “lv”)
top_20_distances <- sort(distances)[1:20]
old20 <- mean(top_20_distances)
return(old20) }
word_list <- c(“emmek”, “emilmek”, “emme”, “emiş”, “emek”, “ermek”, “ekmek”, “esmek”, “esnek”, “elek”, “melek”, “elek”, “erken”, “emir”, “erimek”, “emel”, “eker”, “eken”, “emik”, “emin”) target_word <- “saprımak” old20_value <- old20_score(target_word, word_list) print(paste(“OLD20 skoru:”, old20_value))
word_list <- c(“sömürmek”, “sönmek”, “sömürü”, “sömürücü”, “sömürge”, “sömürüş”, “sömürgen”, “sömür”, “sömürülmek”, “sömürülen”, “sömüren”, “söndür”, “söndürmek”, “sömürme”, “sön”, “söndürme”, “ömür”, “ömürlü”, “ös”, “sönmek”) target_word <- “takurmak” old20_value <- old20_score(target_word, word_list) print(paste(“OLD20 skoru:”, old20_value))
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.