
Sentiment analysis codebook for movie reviews
data_codebook_sentiment.RdA qlm_codebook object defining instructions for sentiment analysis of movie
reviews. Designed to work with data_corpus_LMRDsample but with an expanded
polarity scale that includes a "mixed" category.
Format
A qlm_codebook object containing:
- name
Task name: "Movie Review Sentiment"
- instructions
Coding instructions for analyzing movie review sentiment
- schema
Response schema with two fields:
polarity(Enum of "neg", "mixed", or "pos") andrating(Integer from 1 to 10)- role
Expert film critic persona
- input_type
"text"
Examples
# View the codebook
data_codebook_sentiment
#> quallmer codebook: Sentiment analysis
#> Input type: text
#> Role: You are a political communication analyst evaluating public ...
#> Instructions: Analyze the sentiment of this text, on both a 1-10 scale and...
#> Output schema:ellmer::TypeObject
#> Levels:
#> sentiment: nominal
#> rating: ordinal
# \donttest{
# Use with movie review corpus (requires API key)
coded <- qlm_code(data_corpus_LMRDsample[1:10],
data_codebook_sentiment,
model = "openai")
#> Using model = "gpt-4.1".
#> Error in openai_key(): Can't find env var `OPENAI_API_KEY`.
# Create multiple coded versions for comparison
coded1 <- qlm_code(data_corpus_LMRDsample[1:20],
data_codebook_sentiment,
model = "openai/gpt-4o-mini")
#> Error in openai_key(): Can't find env var `OPENAI_API_KEY`.
coded2 <- qlm_code(data_corpus_LMRDsample[1:20],
data_codebook_sentiment,
model = "openai/gpt-4o")
#> Error in openai_key(): Can't find env var `OPENAI_API_KEY`.
# Compare inter-rater reliability
comparison <- qlm_compare(coded1, coded2, by = "rating", level = "interval")
#> Error: object 'coded1' not found
print(comparison)
#> Error: object 'comparison' not found
# }