def test_lexicalStats(self):
        conv = self.getConversation(mio.getResourcesPath() + "\\unittest\\test_word_count.txt")
        tokensCount, vocabularyCount, lexicalRichness = conv.stats.getLexicalStats()

        self.assertEqual(tokensCount, 18)
        self.assertEqual(vocabularyCount, 17)
        self.assertEqual(lexicalRichness, vocabularyCount/tokensCount)
Esempio n. 2
0
    def test_delayStats(self):
        conv = self.getConversation(mio.getResourcesPath() +
                                    "\\unittest\\test_delay_conv.txt")
        df = conv.stats.generateStats(IConvStats.STATS_NAME_DELAY)

        self.assertEqual(df.loc['S1'].values[0],
                         (np.timedelta64(10, 'h') + np.timedelta64(8, 's')))
        self.assertEqual(df.loc['S2'].values[0], np.timedelta64(10, 's'))
Esempio n. 3
0
 def test_wordUsageByHourAndYear(self):
     words = ['the', 'hello', 'a', 'when']
     conv = self.getConversation(mio.getResourcesPath() + PlottingTestCase.TEST_FILE)
     stats = WordsCountStats(conv)
     stats.loadWordsCount(['month', 'year'])
     mplot.plotWordsCount(stats, words)
     mplot.plotWordsCount(stats, words, 's1')
     mplot.plotWordsCount(stats, words, 's2')
Esempio n. 4
0
def savePlotAsImage(plot, filename):
    folderPath = os.path.join(mio.getResourcesPath(), 'imgs')
    if not os.path.exists(folderPath):
        os.makedirs(folderPath)
    if SAVE_PLOT:
        filepath = os.path.join(folderPath, filename)
        plot.savefig(filepath)
    else:
        pass
    def test_intervalStats(self):
        conv = self.getConversation(mio.getResourcesPath() + "\\unittest\\test_interval_conv.txt")
        start, end, interval = conv.stats.getIntervalStats()
        days = conv.stats.getDaysWithoutMessages()

        self.assertEqual(start, Timestamp('2014-01-01 00:00:00'))
        self.assertEqual(end, Timestamp('2014.01.07 00:10:00'))
        self.assertEqual(interval, datetime.timedelta(6, 600))
        self.assertTrue(set(days) == set(['2014.01.02', '2014.01.06']))
Esempio n. 6
0
    def test_lexicalStats(self):
        conv = self.getConversation(mio.getResourcesPath() +
                                    "\\unittest\\test_word_count.txt")
        tokensCount, vocabularyCount, lexicalRichness = conv.stats.getLexicalStats(
        )

        self.assertEqual(tokensCount, 18)
        self.assertEqual(vocabularyCount, 17)
        self.assertEqual(lexicalRichness, vocabularyCount / tokensCount)
    def test_singleWordCount(self):
        conv = self.getConversation(mio.getResourcesPath() + "\\unittest\\test_word_count.txt")
        totalCount = conv.stats.getWordCountStats(word='hello')
        s1Count = conv.stats.getWordCountStats(word='hello', sender='S1')
        s2Count = conv.stats.getWordCountStats(word='hello', sender='S2')

        self.assertEqual(totalCount, 3)
        self.assertEqual(s1Count, 2)
        self.assertEqual(s2Count, 1)
    def test_emoticonStats(self):
        conv = self.getConversation(mio.getResourcesPath() + "\\unittest\\test_emoticons_conv.txt")
        numEmoticons = conv.stats.getEmoticonsStats()[0]
        numEmoticonsS1 = conv.stats.getEmoticonsStats(sender='S1')[0]
        numEmoticonsS2 = conv.stats.getEmoticonsStats(sender='S2')[0]

        self.assertEqual(numEmoticons, 6)
        self.assertEqual(numEmoticonsS1, 3)
        self.assertEqual(numEmoticonsS2, 3)
Esempio n. 9
0
def savePlotAsImage(plot, filename):
    folderPath = os.path.join(mio.getResourcesPath(), 'imgs')
    if not os.path.exists(folderPath):
        os.makedirs(folderPath)
    if SAVE_PLOT:
        filepath = os.path.join(folderPath, filename)
        plot.savefig(filepath)
    else:
        pass
Esempio n. 10
0
    def test_emoticonStats(self):
        conv = self.getConversation(mio.getResourcesPath() +
                                    "\\unittest\\test_emoticons_conv.txt")
        numEmoticons = conv.stats.getEmoticonsStats()[0]
        numEmoticonsS1 = conv.stats.getEmoticonsStats(sender='S1')[0]
        numEmoticonsS2 = conv.stats.getEmoticonsStats(sender='S2')[0]

        self.assertEqual(numEmoticons, 6)
        self.assertEqual(numEmoticonsS1, 3)
        self.assertEqual(numEmoticonsS2, 3)
Esempio n. 11
0
    def test_singleWordCount(self):
        conv = self.getConversation(mio.getResourcesPath() +
                                    "\\unittest\\test_word_count.txt")
        totalCount = conv.stats.getWordCountStats(word='hello')
        s1Count = conv.stats.getWordCountStats(word='hello', sender='S1')
        s2Count = conv.stats.getWordCountStats(word='hello', sender='S2')

        self.assertEqual(totalCount, 3)
        self.assertEqual(s1Count, 2)
        self.assertEqual(s2Count, 1)
    def test_wordsUsedJustByStats(self):
        conv = self.getConversation(mio.getResourcesPath() + "\\unittest\\test_word_count.txt")
        wordsUsedBy = conv.stats.getWordsBySender(usedJustBy=True)
        wordsSaidJustByS1 = wordsUsedBy['S1']
        wordsSaidJustByS2 = wordsUsedBy['S2']

        sender = {'S2': {'fine', 'sender2', 'xd', ':d'},
                  'S1': {'are', 'how', 'you', 'sender1', 'bye'}}
        self.assertEqual(wordsSaidJustByS1, sender['S1'])
        self.assertEqual(wordsSaidJustByS2, sender['S2'])
Esempio n. 13
0
    def test_intervalStats(self):
        conv = self.getConversation(mio.getResourcesPath() +
                                    "\\unittest\\test_interval_conv.txt")
        start, end, interval = conv.stats.getIntervalStats()
        days = conv.stats.getDaysWithoutMessages()

        self.assertEqual(start, Timestamp('2014-01-01 00:00:00'))
        self.assertEqual(end, Timestamp('2014.01.07 00:10:00'))
        self.assertEqual(interval, datetime.timedelta(6, 600))
        self.assertTrue(set(days) == set(['2014.01.02', '2014.01.06']))
Esempio n. 14
0
    def test_singleWordCount(self):
        conv = self.getConversation(mio.getResourcesPath() +
                                    "\\unittest\\test_word_count.txt")
        stats = conv.stats.generateStats(IConvStats.STATS_NAME_WORDCOUNT)
        totalCount = stats.getWordsCount(['hello']).values[0]
        s1Count = stats.getWordsCount(['hello'], 'S1').values[0]
        s2Count = stats.getWordsCount(['hello'], 'S2').values[0]

        self.assertEqual(totalCount, 3)
        self.assertEqual(s1Count, 2)
        self.assertEqual(s2Count, 1)
Esempio n. 15
0
    def test_wordsUsedJustByStats(self):
        conv = self.getConversation(mio.getResourcesPath() +
                                    "\\unittest\\test_word_count.txt")
        wordsUsedBy = conv.stats.getWordsBySender(usedJustBy=True)
        wordsSaidJustByS1 = wordsUsedBy['S1']
        wordsSaidJustByS2 = wordsUsedBy['S2']

        sender = {
            'S2': {'fine', 'sender2', 'xd', ':d'},
            'S1': {'are', 'how', 'you', 'sender1', 'bye'}
        }
        self.assertEqual(wordsSaidJustByS1, sender['S1'])
        self.assertEqual(wordsSaidJustByS2, sender['S2'])
Esempio n. 16
0
    def test_firstAndLastOccurences(self):
        conv = self.getConversation(mio.getResourcesPath() +
                                    "\\unittest\\test_words_trends.txt")
        stats = WordsCountStats(conv)
        stats.loadWordsCount(['date'])

        # Present word, total
        res = stats.getWordFirstAndLastOccurences('dog')
        self.assertEqual(res, ('2015.10.04', '2015.10.04'))

        # Present word, sender specified
        res = stats.getWordFirstAndLastOccurences('dog', 'S1')
        self.assertEqual(res, ('2015.10.04', '2015.10.04'))

        # Word not present
        res = stats.getWordFirstAndLastOccurences('log', 'S1')
        self.assertEqual(res, (-1, -1))
    def test_basicLengthStats(self):
        conv = self.getConversation(mio.getResourcesPath() + "\\unittest\\test_basic_conv.txt")
        testSet = set(['S1', 'S2'])
        self.assertEqual(testSet, conv.senders)

        totalNumS1, totalLengthS1, avgLegthS1 = conv.stats.getBasicLengthStats('S1')
        self.assertEqual(totalNumS1, 3)
        self.assertEqual(totalLengthS1, 110)
        self.assertEqual(avgLegthS1, 110/3)
        totalNumS2, totalLengthS2, avgLegthS2 = conv.stats.getBasicLengthStats('S2')
        self.assertEqual(totalNumS2, 3)
        self.assertEqual(totalLengthS2, 56)
        self.assertEqual(avgLegthS2, 56/3)
        totalNum, totalLength, avgLegth = conv.stats.getBasicLengthStats()
        self.assertEqual(totalNum, 6)
        self.assertEqual(totalLength, 166)
        self.assertEqual(avgLegth, 166/6)
Esempio n. 18
0
    def test_basicLengthStats(self):
        conv = self.getConversation(mio.getResourcesPath() +
                                    "\\unittest\\test_basic_conv.txt")
        testSet = set(['S1', 'S2'])
        self.assertEqual(testSet, conv.senders)

        totalNumS1, totalLengthS1, avgLegthS1 = conv.stats.getBasicLengthStats(
            'S1')
        self.assertEqual(totalNumS1, 3)
        self.assertEqual(totalLengthS1, 110)
        self.assertEqual(avgLegthS1, 110 / 3)
        totalNumS2, totalLengthS2, avgLegthS2 = conv.stats.getBasicLengthStats(
            'S2')
        self.assertEqual(totalNumS2, 3)
        self.assertEqual(totalLengthS2, 56)
        self.assertEqual(avgLegthS2, 56 / 3)
        totalNum, totalLength, avgLegth = conv.stats.getBasicLengthStats()
        self.assertEqual(totalNum, 6)
        self.assertEqual(totalLength, 166)
        self.assertEqual(avgLegth, 166 / 6)
Esempio n. 19
0
def testConversationGenerator():
    conv = conversationGenerator.generateNewConversation(100, "2014.01.30 06:01:57", "2014.12.30 06:01:57", ["s1", "s2"], 3, 20)
    mio.printListToFile(conv, os.path.join(mio.getResourcesPath(), "test.txt"))
    def test_delayStats(self):
       conv = self.getConversation(mio.getResourcesPath() + "\\unittest\\test_delay_conv.txt")
       df = conv.stats.generateStats(IConvStats.STATS_NAME_DELAY)

       self.assertEqual(df.loc['S1'].values[0], (np.timedelta64(10, 'h')+np.timedelta64(8, 's')))
       self.assertEqual(df.loc['S2'].values[0], np.timedelta64(10, 's'))
Esempio n. 21
0
def testConversationGenerator():
    conv = conversationGenerator.generateNewConversation(
        100, "2014.01.30 06:01:57", "2014.12.30 06:01:57", ["s1", "s2"], 3, 20)
    mio.printListToFile(conv, os.path.join(mio.getResourcesPath(), "test.txt"))
Esempio n. 22
0
 def setUpClass(cls):
     cls.conv = PlottingTestCase.getConversation(mio.getResourcesPath() + PlottingTestCase.TEST_FILE)
Esempio n. 23
0
 def setUpClass(cls):
     cls.conv = PlottingTestCase.getConversation(mio.getResourcesPath() +
                                                 PlottingTestCase.TEST_FILE)