File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ def get_emoticons(text):
161161 """
162162 Return a list of emoticons in the given text.
163163 :param text: String.
164- :return: List of emoticons.
164+ :return: Dictionary - emoticons as keys and their count as values .
165165 """
166166 emoticons = (":-) :) :D :o) :] :3 :c) :> =] 8) =) :} :^) :っ) :-D 8-D 8D"
167167 "x-D xD X-D XD =-D =D =-3 =3 B^D :-)) >:[ :-( :( :-c :c :-<"
@@ -174,4 +174,5 @@ def get_emoticons(text):
174174 ":-###.. :###.. <:-| ಠ_ಠ <*)))-{ ><(((*> ><> \o/ *\0 /*"
175175 "@}-;-'--- @>-->-- ~(_8^(I) 5:-) ~:-\ //0-0\\ *<|:-) =:o]"
176176 ",:-) 7:^] <3 </3" ).split ()
177- return frozenset (emoticons ).intersection (text .split ())
177+ return dict ((emoticon , text .count (emoticon )) for emoticon in emoticons
178+ if emoticon in text .split ())
Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ def test_get_emoticons():
216216 Test the get_emoticons() _util function.
217217 :return: None
218218 """
219- text = 'these are emoticons :) :D :-) '
220- assert question .get_emoticons (text ) == {':)' , ':D' , ':-)' }
221- code = 'this is code x = [:D], y = [0:3], ED8 = 12 '
222- assert question .get_emoticons (code ) != {':D' , '0:3' , 'D8' }
219+ text = 'these are emoticons :) :D :) '
220+ assert question .get_emoticons (text ) == {':)' : 2 , ':D' : 1 }
221+ code = 'this is code x = [:D], y = [0:3], ED8 = [:D] '
222+ assert question .get_emoticons (code ) != {':D' : 2 , '0:3' : 1 }
You can’t perform that action at this time.
0 commit comments