def extractLocation(main=False, onto=None, functType=None, loconto=None, activity=None, time="present"): clear() loc = AGLocation(loconto, onto) print(texts[time]["ventilation"].format(name=loconto.name)) uindex = userMenu(list([x[0] for x in ventilation])+["I don't know."]) if uindex < len(ventilation): loc.ventilation = ventilation[uindex][1] clear() print(texts[time]["distancing"].format(name=loconto.name)) uindex = userMenu(list([x[0] for x in distancing])+["I don't know."]) if uindex < len(distancing): loc.distancing = distancing[uindex][1] if activity.name == "Consuming": clear() print(textsmain[main]["eatingwhere"]) uindex = userMenu(list([x[0] for x in eating_where])+["I don't know."]) if uindex < len(eating_where): loc.eating_where = eating_where[uindex][1] clear() print(textsmain[main]["groupseating"].format(name=loconto.name)) uindex = userMenu(list([x[0] for x in seating])+["I don't know."]) if uindex < len(seating): loc.seating = seating[uindex][1] return loc
def extractProtectionGear(main=False, onto=None, personname=None, placename=None): clear() uindexes = multiUserMenu([x[0] for x in gears], textprompt=texts[main].format(name=personname, place=placename)) gear = AGProtectionGear(onto) gear.gears = [gears[x][1] for x in uindexes] return gear.toOnto()
def extractTransportation(main=False, onto=None, personname=None, placename=None, time="present"): clear() print(texts[main][time]["transpstart"].format(name=personname, place=placename)) tra = AGTransportation(onto) uindex = userMenu([x[0] for x in transps] + ["I don't know."]) if uindex < len(transps): tra.trans = transps[uindex][1] return tra
def renameUser(username, names): resp = input("Mmm... Is this person the same " + username + " you mentioned before? (yes/no): ") while (True): if resp.lower() == "yes": return None elif resp.lower() == "no": break resp = input("Please answer yes or no: ") clear() print( "I see, in that case, we're gonna have to name them something different. What do you want to name this new " + username + "?: ") resp = input("Answer: ") while (resp in names): clear() print("You already told me about someone named!") resp = input("What do you want to name this new " + username + "?: ") return resp
def extractLivingwith(main=False, onto=None, person=None): clear() liveswith = [] while (True): resp = input(texts[main]["liveswith"].format(name=person.name)) if resp.lower() == "yes": break elif resp.lower() == "no": return None else: print("Please answer yes or no") while (True): clear() p = extractPerson(main=main, onto=onto, functType="liveswith", name=person.name) liveswith.append(p) while (True): clear() resp = input( texts[main]["furtherliveswith"].format(name=person.name)) if resp.lower() == "yes": break elif resp.lower() == "no": return liveswith else: print("Please answer yes or no")
onto.load() locationsText = { "Consuming": "Go eat/drink something", "Leisure": "Other activities", "Sports": "Sports" } locations = [ "Bookshop", "Boutique", "Cafe", "Library", "Restaurant", "Shop", "Stadium" ] #activities = list(activityText.keys()) if __name__ == "__main__": clear() mainact = extractActivity( main=True, entranceText= "Hello and welcome to your personal COVID-19 awareness assistant!\nLet us know, what kind of activity did you wish to do?", onto=onto, locations=locations) scenario = AGScenario(onto=onto, act=mainact) scenario.toOnto() clear() for el in scenario.toOnto().hasUser: print("\t" + str(el.hasHealth)) close_world(mainact.mainAgent, Properties=[onto.hasKnownCOVID], recursive=False)
def extractPerson(main=False, onto=None, functType=None, name=None, time="present"): if onto is None: raise Exception("Parameters found None") if main and functType is None: usernametext = "Alright! Tell me about yourself. What is your name?: " healthparamsaux = healthparams elif functType == "liveswith": usernametext = texts[main]["liveswithintroduce"].format(name=name) healthparamsaux = healthliveswith main = False elif functType == "companions": usernametext = texts[main]["companionsintroduce"] healthparamsaux = healthcompanions main = False else: pass #debug username = input(usernametext) person = AGPerson(username, onto) if username in ag.globalAgent().people: name = renameUser(username, ag.globalAgent().people.keys()) if name is None: return ag.globalAgent().people[name] person.name = name ag.globalAgent().addPerson(person) if main: userparamstext = "What else could be of interest about you? This data will help me give you a better analysis." else: userparamstext = "What else could be of interest about " + username + "? This data will help me give you a better analysis." while (True): clear() print(userparamstext) uindex = userMenu( list(x[0] for x in healthparamsaux) + ["That's enough data."]) if uindex == len(healthparamsaux): break else: clear() healthparamsaux[uindex][1](main, person) if uindex == len(healthparamsaux) - 1: healthparamsaux = healthparamsaux[:uindex] elif uindex == 0: healthparamsaux = healthparamsaux[uindex + 1:] else: healthparamsaux = healthparamsaux[:uindex] + healthparamsaux[ uindex + 1:] if functType != "liveswith": liveswith = extractLivingwith(main=main, person=person, onto=onto) person.toOnto() if liveswith is not None: person.linkLivesWith(liveswith) gears = extractProtectionGear(main=main, onto=onto, personname=person.name, placename=name) if gears is not None: person.gears = gears person.updateGears() clear() while (True): resp = input(texts[main]["pastactivityyesno"].format(name=person.name)) if resp.lower() == "no": break elif resp.lower() == "yes": clear() pastActivities = AC.extractActivity( main=main, entranceText=texts[main]["pastactivitytell"].format( name=person.name), onto=onto, locations=[ "Bookshop", "Boutique", "Cafe", "Library", "Restaurant", "Shop", "Stadium" ], time="past", agent=person) clear() else: clear() print("Please introduce yes or no.") person.toOnto() return person