Skip to content

Commit

Permalink
fix #37 by adding more keywords for the warnings (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aivean authored Aug 1, 2024
1 parent a689c74 commit a30dfab
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 6 deletions.
67 changes: 66 additions & 1 deletion src/main/scala/com/aivean/royalroad/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ object Utils {
"theft" -> 0.8,
"report" -> 0.7,
"please report" -> 0.61,
"read the official version" -> 0.8,
"support the" -> 0.7,
"without permission" -> 0.6,
"without author" -> 0.6,
"without the author" -> 0.6,
"without consent" -> 0.6,
"unauthorized" -> 0.6,
"pilfered" -> 0.5,
"pirated" -> 0.5,
"pirate" -> 0.5,
"lifted" -> 0.5,
"obtained" -> 0.5,
"taken" -> 0.5,
Expand All @@ -45,7 +49,68 @@ object Utils {
"taken without" -> 0.7,
"misappropriated" -> 0.6,
"sightings" -> 0.4,
"encounter" -> 0.3
"encounter" -> 0.3,
"original" -> 0.6,
"official" -> 0.6,
"authentic" -> 0.6,
"genuine" -> 0.6,
"elsewhere" -> 0.5,
"different site" -> 0.6,
"another platform" -> 0.6,
"another site" -> 0.6,
"other great novels" -> 0.4,
"creative writers" -> 0.5,
"author's preferred platform" -> 0.7,
"originally published" -> 0.7,
"true home" -> 0.5,
"ensure the author gets" -> 0.8,
"published on a different platform" -> 0.8,
"seeking out the original" -> 0.8,
"find the genuine version" -> 0.8,
"did you know" -> 0.4,
"favorite authors" -> 0.5,
"deserves support" -> 0.6,
"support creators" -> 0.7,
"read it there" -> 0.5,
"real experience" -> 0.5,
"posted elsewhere" -> 0.6,
"originates from" -> 0.6,
"help the author" -> 0.7,
"look for the official" -> 0.7,
"visit royal road" -> 0.8,
"discover and support" -> 0.7,
"ensure author gets credit" -> 0.8,
"support creativity" -> 0.7,
"enjoying this book" -> 0.5,
"seek out the original" -> 0.7,
"get the support they deserve" -> 0.7,
"reading their stories" -> 0.5,
"support the creativity" -> 0.7,
"by visiting" -> 0.3,
"can be found on" -> 0.5,
"check it out there" -> 0.6,
"find this and other great novels" -> 0.8,
"author's preferred platform" -> 0.8,
"support original creators" -> 0.8,
"help support creative writers" -> 0.8,
"read it on royal road" -> 0.9,
"ensure the author gets credit" -> 0.9,
"searching for the original publication" -> 0.8,
"book's true home" -> 0.7,
"novel's true home" -> 0.7,
"posted elsewhere by the author" -> 0.9,
"reading the authentic version" -> 0.8,
"story originates from" -> 0.8,
"different website" -> 0.6,
"reading it there" -> 0.6,
"support creative writers" -> 0.8,
"finding and reading their stories" -> 0.8,
"on the original site" -> 0.7,
"support the author" -> 0.8,
"searching for the original" -> 0.8,
"original publication" -> 0.7,
"true home is a different platform" -> 0.9,
"support the author by finding it" -> 0.9
)

val threshold = 2.5
Expand Down
49 changes: 44 additions & 5 deletions src/test/scala/com/aivean/royalroad/UtilsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,38 @@ class UtilsTest extends FunSuite {
"This tale has been unlawfully lifted from Royal Road; report any instances of this story if found elsewhere.",
"This story has been taken without authorization. Report any sightings.",
"This tale has been unlawfully lifted without the author's consent. Report any appearances on Amazon.",
"This story has been unlawfully obtained without the author's consent. Report any appearances on Amazon."
"This story has been unlawfully obtained without the author's consent. Report any appearances on Amazon.",
"Did you know this story is from Royal Road? Read the official version for free and support the author.",
"Did you know this text is from a different site? Read the official version to support the creator.",
"Enjoying this book? Seek out the original to ensure the author gets credit.",
"Ensure your favorite authors get the support they deserve. Read this novel on Royal Road.",
"Ensure your favorite authors get the support they deserve. Read this novel on the original website.",
"Find this and other great novels on the author's preferred platform. Support original creators!",
"Help support creative writers by finding and reading their stories on the original site.",
"If you come across this story on Amazon, be aware that it has been stolen from Royal Road. Please report it.",
"Love this novel? Read it on Royal Road to ensure the author gets credit.",
"Love this story? Find the genuine version on the author's preferred platform and support their work!",
"Love what you're reading? Discover and support the author on the platform they originally published on.",
"Reading on Amazon or a pirate site? This novel is from Royal Road. Support the author by reading it there.",
"Reading on this site? This novel is published elsewhere. Support the author by seeking out the original.",
"Support creative writers by reading their stories on Royal Road, not stolen versions.",
"Support the author by searching for the original publication of this novel.",
"Support the creativity of authors by visiting Royal Road for this novel and more.",
"Support the creativity of authors by visiting the original site for this novel and more.",
"The genuine version of this novel can be found on another site. Support the author by reading it there.",
"This book is hosted on another platform. Read the official version and support the author's work.",
"This book was originally published on Royal Road. Check it out there for the real experience.",
"This book's true home is on another platform. Check it out there for the real experience.",
"This novel is published on a different platform. Support the original author by finding the official source.",
"This novel's true home is a different platform. Support the author by finding it there.",
"This story is posted elsewhere by the author. Help them out by reading the authentic version.",
"This story originates from Royal Road. Ensure the author gets the support they deserve by reading it there.",
"This story originates from a different website. Ensure the author gets the support they deserve by reading it there.",
"This text was taken from Royal Road. Help the author by reading the original version there.",
"You could be reading stolen content. Head to Royal Road for the genuine story.",
"You could be reading stolen content. Head to the original site for the genuine story.",
"You might be reading a pirated copy. Look for the official release to support the author.",
"You might be reading a stolen copy. Visit Royal Road for the authentic version."
)

test("amazonRegex") {
Expand All @@ -56,12 +87,20 @@ class UtilsTest extends FunSuite {
}

test("amazonRegex2") {
reportWarnings.foreach { w =>
println(w +
s" score: ${Utils.WarningFuzzyMatcher.scoreString(w)} > ${Utils.WarningFuzzyMatcher.threshold}")
val (aboveThreshold, belowThreshold) = reportWarnings.partition { w =>
Utils.WarningFuzzyMatcher.scoreString(w) > Utils.WarningFuzzyMatcher.threshold
}
}

println("Above Threshold:")
aboveThreshold.foreach { w =>
println(w + s" score: ${Utils.WarningFuzzyMatcher.scoreString(w)}")
}

println("Below Threshold:")
belowThreshold.foreach { w =>
println(w + s" score: ${Utils.WarningFuzzyMatcher.scoreString(w)}")
}
}

test("renderTemplate") {
assert(Utils.renderTemplate(
Expand Down

0 comments on commit a30dfab

Please sign in to comment.