From 79ddae646f14e16d4bbab1924730af8d32e2d5fa Mon Sep 17 00:00:00 2001 From: Theodore Summer Date: Sat, 17 Mar 2018 00:14:51 -0700 Subject: [PATCH] Add REGEX to match people that would like to try and be vegan with corresponding tests --- filters/english.js | 4 ++-- lib/filter.js | 2 +- test/test-english.js | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/filters/english.js b/filters/english.js index 1d5c570..541b71c 100644 --- a/filters/english.js +++ b/filters/english.js @@ -7,7 +7,7 @@ track("vegan"); var adverbs = [ 'really', 'totally', 'probably', 'defin[ia]tely', 'absolutely', 'actually', 'certainly', 'literally', 'legitimately', 'genuinely', 'honestly', 'truly', - 'undoubtedly', 'unquestionably' + 'undoubtedly', 'unquestionably', 'seriously', 'rly' ]; var adverbsRegexSet = adverbs.join('|'); @@ -18,7 +18,7 @@ var recidivismAdjectivesRegexSet = recidivismAdjectives.join('|'); module.exports = [ regex( "help me (be( a)?|become( a)?|go) #?vegan" ), - regex( "i (" + adverbsRegexSet + ")? ?(want to|wanna|would like to) (be( a)?|become( a)?|go) #?vegan" ), + regex( "i (" + adverbsRegexSet + ")? ?(want to|wanna|would like to)( try( to| and|))? (be( a)?|become( a)?|go|being) #?vegan" ), // forcing this to be at the start of the tweet is a simple hack for excluding things like "don't tell me I should go vegan" regex( "^(i think)? ?i (" + adverbsRegexSet + ")? ?(should) (go|be) #?vegan" ), regex( "i (" + adverbsRegexSet + ")? ?(will|do)? ?(need|want) help (going|becoming( a)?|being( a)?|staying( a)?) #?vegan" ), diff --git a/lib/filter.js b/lib/filter.js index c6002f0..de2eea5 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -190,7 +190,7 @@ TweetFilter.prototype.tweetIsPrivateConvo = function(tweet) { } TweetFilter.prototype.tweetContainsMultipleMentions = function(tweet) { - return tweet.text.split('@').length - 1 > 1; + return tweet.text.split('@').length - 1 > 1; } TweetFilter.prototype.tweetIsEligable = function(tweet) { diff --git a/test/test-english.js b/test/test-english.js index ce0a3f1..a4bb282 100644 --- a/test/test-english.js +++ b/test/test-english.js @@ -45,6 +45,9 @@ var matches = [ "\"i like to quote\" but i want to go vegan and \"stuff\"", "i'm planning on going vegan", "i'm totally thinking about becoming a vegan", + "i want to try and go vegan", + "i wanna try being vegan", + "i would like to try and be a vegan", ]; var falsePositives = [