def append(self, item): if item['name'] in label_overrides: item['labels'] = label_overrides[item['name']] else: item['labels'] = [ disease for event in item['meta']['events'] for disease in event['diseases'] if disease is not None and not disease_label_table.is_not_human_disease( disease ) and # TODO: We should make multiple classifiers # if we want to also diagnose plant and animal diseases. not ( event.get('species') and len(event.get('species')) > 0 and event.get('species').lower() != "humans" ) ] if len(item['labels']) == 0: self.rejected_items += 1 # There are too many to list: # print "Warning: skipping unlabeled (or animal only) item at",\ # "http://healthmap.org/ai.php?" + item['name'][:-4] return return self.items.append(item)
def get_item_labels(item): if add_parents: all_labels = set(item['labels']) for label in item['labels']: for l2 in disease_label_table.get_inferred_labels(label): if disease_label_table.is_not_human_disease(l2): continue all_labels.add(l2) return list(all_labels) else: return item['labels']