get_word_frequency | R Documentation |
Uses an LLM to obtain frequency information for a specified word position in the stimulus. The user can specify a corpus; if none is provided and corpus_source is "llm", the LLM will generate or assume a representative corpus.
get_word_frequency(
stimulus,
position = "first",
corpus = "",
corpus_source = ifelse(corpus != "", "provided", "llm"),
model = "gpt-3.5-turbo",
api_key = "",
top_p = 1,
temp = 0
)
stimulus |
A character string representing the language material. |
position |
A character string indicating which word to analyze ("first", "last", "each", or "total"). |
corpus |
An optional character string representing the corpus to use for frequency analysis. |
corpus_source |
A character string, either "provided" or "llm". Default is "provided" if corpus is given, otherwise "llm". |
model |
A character string specifying the LLM model (default "gpt-3.5-turbo"). |
api_key |
API key as a character string. |
top_p |
Numeric value for probability mass (default 1). |
temp |
Numeric value for temperature (default 0). |
Default definition: "Word frequency is defined as the number of times a word appears in a corpus (often log-transformed)."
A numeric value representing the frequency (or a JSON string if "each" is specified).
## Not run:
freq_first <- get_word_frequency("The quick brown fox jumps over the lazy dog",
position = "first",
corpus = "A sample corpus text with everyday language.",
corpus_source = "provided",
model = "gpt-3.5-turbo",
api_key = "your_api_key")
cat("Frequency (first word):", freq_first, "\n")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.