def _getEmoticonsStats(messages):
     numEmoticons = 0
     if len(messages) == 0:
         return numEmoticons
     # emoticons = mio.getSetFromFile(mio.getResourcesPath() + "\emoticonList.txt")
     for m in messages:
         mEmoticons = statsUtil.getEmoticonsFromText(m.text)
         numEmoticons += len(mEmoticons)
     return numEmoticons
Beispiel #2
0
 def _getEmoticonsStats(messages):
     numEmoticons = 0
     if len(messages) == 0:
         return numEmoticons
     #emoticons = mio.getSetFromFile(mio.getResourcesPath() + "\emoticonList.txt")
     for m in messages:
         mEmoticons = statsUtil.getEmoticonsFromText(m.text)
         numEmoticons += len(mEmoticons)
     return numEmoticons
Beispiel #3
0
    def _generateEmoticonsStatsBy(self, groupByColumns=[]):
        res = self.df.rename(columns={'text':'text'})
        #grouped = res.groupby(['sender'] + groupByColumns, as_index=False)
        res = res.groupby(['sender'] + groupByColumns, as_index=False).agg({'text' : lambda x: " ".join(x)})
        res['lenMsgs'] = res['text'].apply(lambda x: len(x))
        res['numEmoticons'] = res['text'].apply(lambda x: len(statsUtil.getEmoticonsFromText(x)))

        res.drop('text', axis=1, inplace=True)
        if groupByColumns:
            tot = res.groupby(groupByColumns, as_index=False).sum()
            tot['sender'] = "total"
            res = pd.concat([res, tot])
            res['emoticonsRatio'] = res['numEmoticons']/res['lenMsgs']
            return res[['numEmoticons', 'emoticonsRatio', 'lenMsgs']]
        else:
            res.set_index(['sender'], inplace=True)
            res.loc['total'] = res.sum()
            res['emoticonsRatio'] = res['numEmoticons']/res['lenMsgs']
            return res[['numEmoticons', 'emoticonsRatio', 'lenMsgs']]