def tailor_web_output(gt_dict): if gt_dict["error"]: return json.dumps(gt_dict) gt_dict["summary"] = generate_summary(gt_dict) gt_dict["pc"] = city_adapter.convert_readable(gt_dict["pc"]) del gt_dict["rname"] gt_dict["tweets"] = gt_dict["tweets"][:10] return json.dumps(gt_dict)
def generate_summary(gt_dict): summary = None if gt_dict["oconf"] == 2: summary = "Summary: <b>{0}</b> has <b>{1}</b> recent status updates. <b>{2}</b> of them are geotagged tweets and the home location is in <b>{3}</b>. Our prediction error distance is <b>{4}</b> kilometers.".format( gt_dict["sname"], len(gt_dict["tweets"]), len(gt_dict["footprints"]), city_adapter.convert_readable(gt_dict["oc"]), gt_dict["errdist"], ) elif gt_dict["oconf"] == 1: summary = "Summary: <b>{0}</b> has <b>{1}</b> recent status updates. <b>{2}</b> of them are geotagged tweets and the most frequent location (<b>{3}</b>) is assumed to be the home location. Our prediction error distance is <b>{4}</b> kilometers.".format( gt_dict["sname"], len(gt_dict["tweets"]), len(gt_dict["footprints"]), city_adapter.convert_readable(gt_dict["oc"]), gt_dict["errdist"], ) else: summary = "Summary: <b>{0}</b> has <b>{1}</b> recent status updates. None of them is geotagged.".format(gt_dict["sname"], len(gt_dict["tweets"])) return summary
def generate_summary(gt_dict): summary = None if gt_dict["oconf"] == 2: summary = "Summary: <b>{0}</b> has <b>{1}</b> recent status updates. <b>{2}</b> of them are geotagged tweets and the home location is in <b>{3}</b>. Our prediction error distance is <b>{4}</b> kilometers.".format( gt_dict["sname"], len(gt_dict["tweets"]), len(gt_dict["footprints"]), city_adapter.convert_readable(gt_dict["oc"]), gt_dict["errdist"], ) elif gt_dict["oconf"] == 1: summary = "Summary: <b>{0}</b> has <b>{1}</b> recent status updates. <b>{2}</b> of them are geotagged tweets and the most frequent location (<b>{3}</b>) is assumed to be the home location. Our prediction error distance is <b>{4}</b> kilometers.".format( gt_dict["sname"], len(gt_dict["tweets"]), len(gt_dict["footprints"]), city_adapter.convert_readable(gt_dict["oc"]), gt_dict["errdist"], ) else: summary = "Summary: <b>{0}</b> has <b>{1}</b> recent status updates. None of them is geotagged.".format( gt_dict["sname"], len(gt_dict["tweets"])) return summary
def tailor_bot_output(sname, gt_dict): if gt_dict["error"]: return None lat = gt_dict["plat"] lon = gt_dict["plon"] pc = gt_dict["pc"] oc = gt_dict["oc"] rpc = city_adapter.convert_readable(pc) msg = None if oc: if pc == oc: msg = "Dear @{0}, I am confident that your home location is near {1}({2},{3})".format(sname, rpc, lat, lon) else: msg = "Dear @{0}, I think your home location is near {1}({2},{3}), but probably I am wrong".format(sname, rpc, lat, lon) else: msg = "Dear @{0}, I think your home location is near {1}({2},{3}). Please tell me if I am wrong.".format(sname, rpc, lat, lon) return msg
def tailor_bot_output(sname, gt_dict): if gt_dict["error"]: return None lat = gt_dict["plat"] lon = gt_dict["plon"] pc = gt_dict["pc"] oc = gt_dict["oc"] rpc = city_adapter.convert_readable(pc) msg = None if oc: if pc == oc: msg = "Dear @{0}, I am confident that your home location is near {1}({2},{3})".format( sname, rpc, lat, lon) else: msg = "Dear @{0}, I think your home location is near {1}({2},{3}), but probably I am wrong".format( sname, rpc, lat, lon) else: msg = "Dear @{0}, I think your home location is near {1}({2},{3}). Please tell me if I am wrong.".format( sname, rpc, lat, lon) return msg