get_similar_stories {stoRy} | R Documentation |
Find similar stories to a given story
Description
get_similar_stories
calculates the top n
most thematically
similar stories to a given story.
Usage
get_similar_stories(
query_story,
background_collection = NULL,
top_n = 10,
weights = list(choice = 3, major = 2, minor = 1),
explicit = TRUE,
min_freq = 1,
blacklist = NULL,
metric = c("hgt", "tfidf")
)
Arguments
query_story |
A |
background_collection |
A If |
top_n |
Maximum number of similar stories to report. The default is
If |
weights |
A list assigning nonnegative weights to choice, major, and
minor theme levels. The default weighting
|
explicit |
Set to |
min_freq |
Drop themes occurring less than this number of times from
the analysis. The default |
blacklist |
A If |
metric |
A character vector specifying the choice of weighting to use
in the cosine similarity measure used to evaluate story thematic
similarity.
Use The default specification of |
Value
Returns a tibble
with top_n
rows (stories)
and 5 columns:
story_id : | n -th most thematically similar story to the query
story |
title : | Reference story title |
description : | Reference story description |
score : | Cosine similarity score with hypergeometric test weights
(if metric = "hgt" ) or TF-IDF weights (if metric = "tfidf" ). |
common_themes : | List of themes common to both the query and reference story |
References
Paul Sheridan, Mikael Onsjö, Claudia Becerra, Sergio Jimenez, Georg Dueñas (2019). An Ontology-Based Recommender System with an Application to the Star Trek Television Franchise. Future Internet, 11(9), 182. DOI: doi:10.3390/fi11090182
Examples
## Not run:
# Retrieve the top 10 most similar stories to the classic "The Twilight
# Zone" series episode "Nightmare at 20,000 Feet" (1959):
set_lto("demo")
query_story <- Story$new(story_id = "tz1959e5x03")
result_tbl <- get_similar_stories(query_story)
result_tbl
# Retrieve the top 10 most similar stories to the classic "The Twilight
# Zone" series episode "Nightmare at 20,000 Feet" (1959) without taking
# minor themes into account:
set_lto("demo")
query_story <- Story$new(story_id = "tz1959e5x03")
result_tbl <- get_similar_stories(query_story, weights = list(choice = 3, major = 2, minor = 0))
result_tbl
# Retrieve the top 10 most similar stories to the classic "The Twilight
# Zone" series episode "Nightmare at 20,000 Feet" (1959) when implicitly
# featured themes are included in the similarity calculation:
set_lto("demo")
query_story <- Story$new(story_id = "tz1959e5x03")
result_tbl <- get_similar_stories(query_story, explicit = FALSE)
result_tbl
## End(Not run)