Skip to content

Instantly share code, notes, and snippets.

@sftekin
Created January 17, 2020 12:11
Show Gist options
  • Save sftekin/fb826a5b5d448998ba24a1019388580e to your computer and use it in GitHub Desktop.
Save sftekin/fb826a5b5d448998ba24a1019388580e to your computer and use it in GitHub Desktop.
textual emoji count in a sentence
self.pattern_happy_emoji = re.compile(r'([:;=] ?-?(\)|D+|d+|P))')
self.pattern_unhappy_emoji = re.compile(r'(: ?-?(\(|/|([Ss]))+)')
def _extract_feature(self, sentence):
emoji_flag = np.array([0, 0])
# search for happy emoji
emoji_flag[0] = len(self.pattern_happy_emoji.findall(sentence))
# search for unhappy emoji
emoji_flag[1] = len(self.pattern_unhappy_emoji.findall(sentence))
return emoji_flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment