## ----packages, message=FALSE-------------------------------------------------- if (!requireNamespace("lexopsdata", quietly = TRUE)) { knitr::opts_chunk$set(eval = FALSE) } else { library(lexopsdata) } library(readr) library(dplyr) library(LexOPS) ## ----hidden-setup, include=FALSE---------------------------------------------- set.seed(1) ## ----import-data-------------------------------------------------------------- pairs <- readr::read_csv("https://media.githubusercontent.com/media/doomlab/shiny-server/master/wn_double/double_words.csv") ## ----create-function---------------------------------------------------------- sem_matches <- function(matches, target) { # for speed, return N ones if possible if (all(matches==target)) return(rep(1, length(matches))) # find each match-target association value tibble(CUE = matches, TARGET = target) |> full_join(pairs, by=c("CUE", "TARGET")) |> filter(TARGET == target & CUE %in% matches) |> pull(root) } ## ----test-function------------------------------------------------------------ # should return 1 sem_matches("yellow", "yellow") # should return 3 values: 1 if identical, 0=0.5) stim <- lexops |> # speed up by removing strings unknown to pairs df dplyr::filter(string %in% pairs$CUE) |> # create a random 2-level split split_random(2) |> # control for semantic similarity control_for_map(sem_matches, string, -0.5:0, name = "root_cosine") |> # control for other values control_for(Length, 0:0) |> control_for(PoS.SUBTLEX_UK) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> # generate 20 items per factorial cell (40 total) generate(20) ## ----print, eval=FALSE-------------------------------------------------------- # print(stim) ## ----print-kable, echo=FALSE-------------------------------------------------- knitr::kable(stim)