def get_codescriptors(): """ looks for all codescriptors of grounds (as COLD and SNOWY as) """ import sys sys.path.insert(1, '../') data = Data() with open('../res/wiki/alland.txt', 'r') as f: for line in f: words = line.split(" ") for ground in data.grounds.keys(): other = "" if words[1] == ground: other = words[3] elif words[3] == ground: other = words[1] if wn.synsets(other, wn.ADJ): print "adj " + other g = data.get_ground(ground) g.add_codescriptor(other) elif other != "": print "no adj " + other data.save()
def get_attributes(): """ Gets all attributes for all vehicles ("GROUND * such as VEHICLE") """ wd = Data() for vehicle in wd.vehicles.keys(): if not wn.synsets(vehicle, wn.NOUN): del wd.vehicles[vehicle] for ground in wd.grounds.keys(): if not wn.synsets(ground, wn.ADJ): del wd.grounds[ground] with open('../res/wiki/allsuchas.txt', 'r') as f: for line in f: split_line = line.split(" such as ") left_side = split_line[0] right_side = split_line[1] for ground in wd.grounds.keys(): ground_temp = " " + ground + " " if ground_temp.replace("_", " ") in left_side: for vehicle in wd.vehicles.keys(): vehicle_temp = " a " + vehicle.replace("_", " ") + " " vehicle_plural = " " + vehicle.replace("_", " ") + "s " vehicle_temp = vehicle_temp.replace("_", " ") if vehicle_temp in right_side or vehicle_plural in right_side: wd.get_vehicle(vehicle).add_attribute(wd.get_ground(ground)) print str(vehicle) + " " + str(ground) + " ... " + line wd.save()