Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions lib/algorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function rank(tweet: string): RankResponse {
lowercase(tweetData),
uppercase(tweetData),
hazing(tweetData),
usPolitics(tweetData),
]
const scores = rules.map((item) => item.score)
const validations: Array<Validation> = compact(
Expand Down Expand Up @@ -353,3 +354,45 @@ function hazing({ tweet, sentiment }: TweetData): Rank {
score: 0,
}
}

/**
* U.S. politics is so awesome, and everybody should love to read about it,
* no matter their background, interests, or country of residence.
* You WILL form an opinion on us!
*/
function usPolitics({ tweet, sentiment }: TweetData): Rank {
// List of hot topics, power posters, and coronavirus conspiracy
const topics = [
"🇺🇸", "american?s?", "patriots?", "president", "states", "psyop",
"conservatives?", "democrats?", "demonrat", "republicans?", "crt", "woke\\w*",
"abortion", "pro-life", "authoritarian", "drag", "ideology",
"trump", "biden", "obama", "aoc", "cruz", "bernie", "sanders", "mtg",
"ilhan", "pelosi", "lindsey", "mcconnell", "warren", "mccarthy", "kamala",
"romney", "tulsi", "gabbard", "rubio", "bannon", "yang", "klobuchar",
"crenshaw", "desantis", "buttigieg", "fauci", "feinstein", "cheney",
"newsom", "smollett", "beto", "schumer", "hillary", "clinton", "walsh",
"capitol", "house bill", "chicago", "amendments?", "constitution",
"vaccines?", "pfizer", "wuhan", "mandates?",
"plandemic", "bill gates"
]
const r = new RegExp("\\b(?:" + topics.join("|") + ")\\b", "gi")
const matches: boolean = !!tweet.match(r)
if (matches) {
if (sentiment.comparative <= -0.1) {
// Downhill U.S. politics is great, you love reading about it
return {
score: 60,
message: "Downhill U.S. politics."
}
} else {
// Normal U.S. politics is decent too
return {
score: 40,
message: "U.S. politics."
}
}
}
return {
score: 0,
}
}