From c8280da7c8036c60f76500bf92c0521189104895 Mon Sep 17 00:00:00 2001 From: chillaranand Date: Sun, 28 Dec 2014 21:45:01 +0530 Subject: [PATCH 1/3] modified get_emoticons util functions --- nidaba/features/_util/question.py | 20 ++++++++++++++++++++ nidaba/features/test/test_questions_util.py | 11 +++++++++++ 2 files changed, 31 insertions(+) diff --git a/nidaba/features/_util/question.py b/nidaba/features/_util/question.py index d80e62e..3f1b590 100644 --- a/nidaba/features/_util/question.py +++ b/nidaba/features/_util/question.py @@ -155,3 +155,23 @@ def python_docs_urls(s): result = regex.findall(s) return result + + +def get_emoticons(text): + """ + Return a list of emoticons in the given text. + :param text: String. + :return: List of emoticons. + """ + emoticons = (":-) :) :D :o) :] :3 :c) :> =] 8) =) :} :^) :っ) :-D 8-D 8D" + "x-D xD X-D XD =-D =D =-3 =3 B^D :-)) >:[ :-( :( :-c :c :-<" + ":っC :< :-[ :[ :{ ;( :-|| :@ >:( :'-( :'( :'-) :')D :< D:" + "D8 D; D= DX v.v D-': >:O :-O:O:-o:o 8-0 O_O o-o O_o o_O o_o" + "O-O :* :^* ;^) :-, >:P :-P :P X-P x-p xp XP :-p :p =p :-Þ" + ">:\ >:/ :-/ :-. :/ :\ =/ =\ :L =L :S >.< :| :-| :$ :-X :X" + ":-# :# O:-) 0:-3 0:3 0:-) 0:) 0;^) >:) >;) >:-) }:-) }:)" + "3:-) 3:) o/\o ^5 >_>^ ^<_< |;-) |-O :-J :-& :& #-) %-) %)" + ":-###.. :###.. <:-| ಠ_ಠ <*)))-{ ><(((*> ><> \o/ *\0/*" + "@}-;-'--- @>-->-- ~(_8^(I) 5:-) ~:-\ //0-0\\ *<|:-) =:o]" + ",:-) 7:^] <3 Date: Mon, 29 Dec 2014 22:47:18 +0530 Subject: [PATCH 2/3] get_emoticons function should return dict instead of set --- nidaba/features/_util/question.py | 5 +++-- nidaba/features/test/test_questions_util.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/nidaba/features/_util/question.py b/nidaba/features/_util/question.py index 3f1b590..7367943 100644 --- a/nidaba/features/_util/question.py +++ b/nidaba/features/_util/question.py @@ -161,7 +161,7 @@ def get_emoticons(text): """ Return a list of emoticons in the given text. :param text: String. - :return: List of emoticons. + :return: Dictionary - emoticons as keys and their count as values. """ emoticons = (":-) :) :D :o) :] :3 :c) :> =] 8) =) :} :^) :っ) :-D 8-D 8D" "x-D xD X-D XD =-D =D =-3 =3 B^D :-)) >:[ :-( :( :-c :c :-<" @@ -174,4 +174,5 @@ def get_emoticons(text): ":-###.. :###.. <:-| ಠ_ಠ <*)))-{ ><(((*> ><> \o/ *\0/*" "@}-;-'--- @>-->-- ~(_8^(I) 5:-) ~:-\ //0-0\\ *<|:-) =:o]" ",:-) 7:^] <3 Date: Mon, 29 Dec 2014 23:55:12 +0530 Subject: [PATCH 3/3] modified get_emoticons --- nidaba/features/_util/question.py | 9 +++++---- nidaba/features/test/test_questions_util.py | 11 +++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/nidaba/features/_util/question.py b/nidaba/features/_util/question.py index 7367943..bf65e75 100644 --- a/nidaba/features/_util/question.py +++ b/nidaba/features/_util/question.py @@ -159,8 +159,8 @@ def python_docs_urls(s): def get_emoticons(text): """ - Return a list of emoticons in the given text. - :param text: String. + Return a dictionary of emoticons & their count in the given text. + :param text: String or List of words. :return: Dictionary - emoticons as keys and their count as values. """ emoticons = (":-) :) :D :o) :] :3 :c) :> =] 8) =) :} :^) :っ) :-D 8-D 8D" @@ -174,5 +174,6 @@ def get_emoticons(text): ":-###.. :###.. <:-| ಠ_ಠ <*)))-{ ><(((*> ><> \o/ *\0/*" "@}-;-'--- @>-->-- ~(_8^(I) 5:-) ~:-\ //0-0\\ *<|:-) =:o]" ",:-) 7:^] <3