File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -155,3 +155,23 @@ def python_docs_urls(s):
155155 result = regex .findall (s )
156156
157157 return result
158+
159+
160+ def get_emoticons (text ):
161+ """
162+ Return a list of emoticons in the given text.
163+ :param text: String.
164+ :return: List of emoticons.
165+ """
166+ emoticons = (":-) :) :D :o) :] :3 :c) :> =] 8) =) :} :^) :っ) :-D 8-D 8D"
167+ "x-D xD X-D XD =-D =D =-3 =3 B^D :-)) >:[ :-( :( :-c :c :-<"
168+ ":っC :< :-[ :[ :{ ;( :-|| :@ >:( :'-( :'( :'-) :')D :< D:"
169+ "D8 D; D= DX v.v D-': >:O :-O:O:-o:o 8-0 O_O o-o O_o o_O o_o"
170+ "O-O :* :^* ;^) :-, >:P :-P :P X-P x-p xp XP :-p :p =p :-Þ"
171+ ">:\ >:/ :-/ :-. :/ :\ =/ =\ :L =L :S >.< :| :-| :$ :-X :X"
172+ ":-# :# O:-) 0:-3 0:3 0:-) 0:) 0;^) >:) >;) >:-) }:-) }:)"
173+ "3:-) 3:) o/\o ^5 >_>^ ^<_< |;-) |-O :-J :-& :& #-) %-) %)"
174+ ":-###.. :###.. <:-| ಠ_ಠ <*)))-{ ><(((*> ><> \o/ *\0 /*"
175+ "@}-;-'--- @>-->-- ~(_8^(I) 5:-) ~:-\ //0-0\\ *<|:-) =:o]"
176+ ",:-) 7:^] <3 </3" ).split ()
177+ return frozenset (emoticons ).intersection (text .split ())
Original file line number Diff line number Diff line change @@ -209,3 +209,14 @@ def test_python_docs_urls():
209209
210210 for url in urls :
211211 assert url in result
212+
213+
214+ def test_get_emoticons ():
215+ """
216+ Test the get_emoticons() _util function.
217+ :return: None
218+ """
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' }
You can’t perform that action at this time.
0 commit comments