def calculateSentScore(self): sentList = [] count = 0 pos_negCount =0 sentScore =0 objDA = DataAccess() ds = objDA.getFilteredTxt() if ds == []: pass for record in ds: sentList.append(count) print('text '+str(record)) sentList[count] = ss(str(record)) if sentList[count] == "pos": pos_negCount +=2 print('pos sent') else: pos_negCount +=0.2 print('neg sent') count+= 1 print('pos count ',pos_negCount) print('count ',count) try: sentScore = round((pos_negCount/count)*10,1) except: sentScore = -1 print('sentscore ',sentScore) if sentScore == 0: sentScore = 1 if sentScore >= 1: formatedTime = formatTime(str(datetime.now())) print('If') formatedTime = formatedTime[0:12] objDA.saveHL(formatedTime, sentScore) else: formatedTime = formatTime(str(datetime.now())) print('Else') formatedTime = formatedTime[0:12] print(formatedTime +' '+str(sentScore)) objDA.saveHL(formatedTime, sentScore)
def check_and_calculateDayHL(self): print('Running check_and_calculateDayHL ') fileOut = open('D:\Project Amigo\Project\TextFiles\date.txt','w') while timer('m',5): f = open('D:\Project Amigo\Project\TextFiles\date.txt','r') storedDate = f.read() f.close() dateNow = formatTime(str(datetime.now())) if storedDate[0:8] == dateNow[0:8]: print('Ignore') else: print('Calculating DayHL') self.calculateDayHL() finallyCalculatedDate = formatTime(str(datetime.now())) fileOut.write(finallyCalculatedDate) fileOut.close()
def calculateDayHL(self): objDA = DataAccess() ds = objDA.getHL_forDayHL_Cal() totDayHL = 0 count = 1 dayHL = 0 for r in ds: totDayHL+= r[2] dayHL = totDayHL/count t = formatTime(subtractTime('d',1)) t = t[0:8] print(t) objDA.saveDayHL(t, dayHL)
def OnKeyboardEvent(event): global text searchObj = re.search(r"(.*)facebook(.*)", str(event.WindowName), re.I) if not searchObj == None: text += chr(event.Ascii) searchObj = re.search(r"(.*)gmail(.*)", str(event.WindowName), re.I) if not searchObj == None: # text += chr(event.Ascii) pass searchObj = re.search(r"(.*)skype(.*)", str(event.WindowName), re.I) if not searchObj == None: text += chr(event.Ascii) searchObj = re.search(r"(.*)viber(.*)", str(event.WindowName), re.I) if not searchObj == None: text += chr(event.Ascii) searchObj = re.search(r"(.*)yahoo(.*)", str(event.WindowName), re.I) if not searchObj == None: text += chr(event.Ascii) searchObj = re.search(r"(.*)googleplus(.*)", str(event.WindowName), re.I) if not searchObj == None: text += chr(event.Ascii) searchObj = re.search(r"(.*)evernote(.*)", event.WindowName, re.I) if not searchObj == None: text += chr(event.Ascii) searchObj = re.search(r"(.*)onenote(.*)", str(event.WindowName), re.I) if not searchObj == None: text += chr(event.Ascii) searchObj = re.search(r"(.*)outlook(.*)", str(event.WindowName), re.I) if not searchObj == None: text += chr(event.Ascii) searchObj = re.search(r"(.*)hotmail(.*)", str(event.WindowName), re.I) if not searchObj == None: text += chr(event.Ascii) # return True to pass the event to other handlers+2+ if len(text) == 50: result = list(text) for (start, end) in [(m.start(), m.end()) for m in re.finditer("\b", text)]: text = text.replace("".join(result[start - 1 : end]), "") time = datetime.now() timeFormatted = formatTime(str(time)) print("Log Text " + text) objDataA = DataAccess() objDataA.saveFilteredText(timeFormatted, text) text = "" result = [] return True