Nothing
## ----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<x<1 if value present, NA if missing
sem_matches(c("yellow", "sun", "leaf"), "yellow")
# would return N=nrow(lexops) values (mostly NA) of similarity to "yellow"
# sem_matches(lexops$string, "yellow")
## ----generate-control_for_map-------------------------------------------------
# speed up by removing unusable word pairs from pairs
pairs <- filter(pairs, root>=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)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.