Created
January 17, 2020 12:11
-
-
Save sftekin/fb826a5b5d448998ba24a1019388580e to your computer and use it in GitHub Desktop.
textual emoji count in a sentence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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