def main(useDefault): text = "There is a flood on 1444 N Bosworth Avenue. My name is Deckard Cain." time = None email = Gmail() messages = email.readEmails(True) if not useDefault: text,time = messages[-1].split("|") entities = findEntities(text) if not time == None: entities[time] = "Time" s = parsetree(text) for sentence in s: chunks = sentence.chunks for chunk in chunks: tag, myString = chunk.tag, chunk.string if tag == "NP": no_adjective_string = removeAdjective(chunk) no_adjective_string = formatString(no_adjective_string) if len(no_adjective_string) > 0: if not entities.has_key(no_adjective_string): entities[no_adjective_string] = determineType(no_adjective_string,sentence) for i,textfile in enumerate(textfile_names): value = textfile_mappings[i] writeOutput(textfile,entities,value)
def getEmails(username,password): HOST = "pod51009.outlook.com" email = Gmail(HOST,username,password) messages = email.readEmails(False) return messages