From 7c00f6eaf960e4c9a053bac2981eee10c3c9197b Mon Sep 17 00:00:00 2001 From: Piyush Jha Date: Sun, 2 Apr 2023 08:52:05 +0530 Subject: [PATCH] Add new score logic to boost cat pics, everything else will be hidden. --- .../relevance/scorers/TweetTextScorer.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/java/com/twitter/search/common/relevance/scorers/TweetTextScorer.java b/src/java/com/twitter/search/common/relevance/scorers/TweetTextScorer.java index e682e5614..e614bffd1 100644 --- a/src/java/com/twitter/search/common/relevance/scorers/TweetTextScorer.java +++ b/src/java/com/twitter/search/common/relevance/scorers/TweetTextScorer.java @@ -120,13 +120,16 @@ public class TweetTextScorer extends TweetScorer { double readabilityScore = normalize(textQuality.getReadability(), readabilityAlpha); double entropyScore = normalize(textQuality.getEntropy(), entropyAlpha); - double score = (isOffensiveText ? offensiveTermDamping : DEFAULT_NO_DAMPING) - * (isOffensiveScreenName ? offensiveNameDamping : DEFAULT_NO_DAMPING) - * (lengthWeight * lengthScore - + readabilityWeight * readabilityScore - + shoutWeight * shoutScore - + entropyWeight * entropyScore - + linkWeight * (tweet.getExpandedUrlMapSize() > 0 ? 1 : 0)); + //Updated score function to assign everything a score of zero + //except tweets that contain cat pictures. + //Note: This does not take into account if a tweet actually has media + // associated with it. This is just for text scores. + String tweetText = tweet.getText().toLowerCase(); + double score = 0; + + if(tweetText.contains("cat") && tweetText.contains("pic")){ + score = Double.MAX_VALUE/3.14; + } // scale to [0, 100] byte textQuality.setTextScore((byte) (score * 100));