예제 #1
0
 def run(self):
     if self.fromfile_pack:
         self.linelog = LineLog.fromFilename(self.fromfile_pack['filepath'],
                                              self.fromfile_pack['savedTimeZone'],
                                              self.fromfile_pack['progressCallback'])
         print "Log import complete"
     elif self.fromstring_pack:
         self.linelog = LineLog.fromString(self.fromstring_pack['unprocessed_str'],
                                           self.fromstring_pack['savedTimeZone'],
                                           self.fromstring_pack['progressCallback'])
     elif self.frompickle_pack:
         self.linelog = LineLog.fromPickle(self.frompickle_pack['dataFilePath'])
예제 #2
0
 def testPickle(self):
     import os
     from mineline.Events import MessageEvent, PhotoEvent
     from mineline.LineLog import LineLog
     
     # Setup
     loglist = [MessageEvent("John", "12/13/14 12:12", "Testing"),PhotoEvent("John","12/13/14")]
     line = LineLog(loglist, "2014/01/01 13:00")
     
     # Exercise
     testFile = "./testPickle.data"
     line.pickleLog(testFile)
     testLine = LineLog.fromPickle(testFile)
     os.remove(testFile)
     
     # Test
     self.assertEqual(line, testLine)
예제 #3
0
 def testGetUserEvents(self):
     import pytz
     from mineline.LineLog import LineLog
  
     # Setup
     log = LineLog.fromFilename(self.filepath, pytz.timezone("Asia/Tokyo"))
     
     # Exercise
     count = 0
     for event in log.getUserEvents('i am ok'):
         count += 1
     print str(count)
예제 #4
0
            if event.getUser not in users:
                users[event.getUser()] = FreqDist()
            words = event.getMessage().lower().split()
            words_tag = pos_tag(words)
            for word, tag in words_tag:
                if tag == "NN":
                    users[event.getUser()].inc(word)
        return users


if __name__ == "__main__":
    linelog = None
    import os.path

    if os.path.isfile(dirpath + filename + ".data"):
        linelog = LineLog.fromPickle(dirpath + filename + ".data")
    else:
        linelog = LineLog.fromFilename(dirpath + filename + ".txt")
        linelog.pickleLog(dirpath + filename + ".data")

    analyze = Analysis()

    ## Hours of Day
    # hoursOfDayTest(linelog)
    ## 10-min bins
    # tenMinBinCount(linelog)
    ## Velocity
    # velocityTest(linelog)
    analyze.freqDisp(linelog)
    """
    fdistUsers = freqDispByUsers(linelog)