Skip to contents

Returns a coder function for the coder argument of llm_auto_code() that tags texts by regular-expression matching instead of calling an LLM. It is meant for trying the workflow offline with mock_mixed_data(), not for real research coding.

Usage

mock_coder(
  patterns = c(UI_Confusion = "lost|confus|can't find|frustrat|error",
    Positive_Experience = "love|seamless|clean|effortless|efficient|fast",
    Feature_Request = "wish|please add|would be great")
)

Arguments

patterns

Named character vector of case-insensitive regular expressions, one per code. Codes without a pattern are coded FALSE.

Value

A function function(texts, codebook).

Examples

coder <- mock_coder()
coder(c("I got lost", "I love it"), c(UI_Confusion = "", Positive_Experience = ""))
#>   UI_Confusion Positive_Experience
#> 1         TRUE               FALSE
#> 2        FALSE                TRUE