(September 2011) #18 Texas Wild fire 2011 #32 No No No No No Yes No No Turkey 2011) #39 No Yes Yes Yes No No No No Encephalitis (India) #27 No Yes Yes Yes No Yes No Yes Guatemala Earthquake #47 Yes Yes Yes Yes No No No No Virginia Tech Global Disasters Collection #67 Yes Yes No Yes Yes Yes No No Virginia Earthquake (Aug 23rd, 2011) #49 No Yes No Yes No Yes No Yes Indonesia Crash (September 2011) #93 No Yes No Yes No Yes No Yes Hurricane Sandy (October 2012) #23 Yes Yes Yes Yes No Yes No Yes East Helicopter Crash ( October 5th, 2011) #55 Yes Yes No No No Yes No No Midwest Snowstorms (Feb 2011) #12 No No No No No No No Yes Hurricane Irene ( Aug 2011 ) #21 Yes Yes No No No No No No
2012 #18 Hurricane Irene ( Aug 2011 ) #35 No Yes Yes Yes No Yes No Yes Turkey 2011) #32 Yes Yes No Yes Yes Yes No Yes Indonesia Plane Crash (September 2011) #20 Yes Yes No Yes Yes Yes Yes Yes Guatemala Earthquake #50 Yes Yes Yes No Yes Yes No Yes Nevada air race (September 16, 2011) #2 Yes No Yes No Yes No No No Somalia Bomb Blast #13 Yes Yes No Yes Yes Yes Yes No China Floods #38 Yes Yes No No No Yes No Yes April 16 Archive #5 Yes Yes Yes Yes Yes Yes No Yes Philippines Floods (September 2011) #42 Yes Yes No Yes No No No No 16 Archive #42 No Yes Yes Yes No Yes No Yes Virgnia Tech April16 Shootings #27 Yes Yes Yes Yes No Yes No Yes New Zealand Earthquake #27 Yes Yes No No Yes Yes No No China Floods #35 Yes Yes Yes Yes Yes No No Yes Chile Earthquake #1 Yes Yes Yes Yes Yes No No No Wild fire 2011 #21 Yes Yes Yes Yes Yes Yes Yes Yes
from ReliefStructures import Location, Person, Agency, NamedEntity, Relief, ReliefType from ProcessorUtil import ProcessorUtil logging.basicConfig(level=logging.INFO) # Comment this line out to silence the script OUT_DIR = os.path.join(os.path.dirname(__file__), "Output") SUMMARY_DIR = os.path.join(os.path.dirname(__file__), "Summary") def get_entities(named_entity_class, document): ref_dict = dict() for name in if name in document.content: entity = named_entity_class(name) try: ref_dict[name] += 1 except KeyError: ref_dict[name] = 1 return ref_dict # adapted from def get_nltk_nes(document, node_type): """A generator that yields the of objects of type node_type""" for sentence in document.sentences: for chunk in nltk.ne_chunk(nltk.pos_tag(nltk.word_tokenize(sentence))): if "label") and chunk.label() == node_type: yield [leaf[0] for leaf in chunk.leaves()] def get_people(names, document): """Gets people based on a list of their names""" people = dict() for name in names: person = Person(" ".join(name)) try: people[person] += 1 except KeyError: people[person] = 1 return people def generate_meta(document): locations = get_entities(Location, document) agencies = get_entities(Agency, document) people = get_people(get_nltk_nes(document, "PERSON"), document) # each dictionary's contents to a length-delimited file
long_term = """Whether aid is long-term""" amount = 0 """Amount of relief given, in units 'unit'""" unit = "" """Unit for amount of relief (dollars, # cans of etc)""" type = ReliefType.UNCLASSIFIED """Type of relief provided""" logging.info("Loading location names.") NamedEntity.load_names(Location) logging.info("Loading agency names.") NamedEntity.load_names(Agency) logging.info("Locations loaded: \n" + str(Location.names) + "\n") logging.info("Agencies loaded: \n" + + "\n") Appendix IV: ProcessorUtil.py import os import logging # Makes it easy to represent the number of location mentions # Creates a file with the following format: # First line: document_name number_of_locations # Second line: location_name occurrence_count class ProcessorUtil: @staticmethod def entity_mentions_by_disaster(references): """Returns a dict of disasters from a dict of references: {disaster: {entity_name: count}}""" disaster_dict = dict() for doc_name, ref_dict in references.items(): disaster_name = doc_name.rsplit("#", 1)[0] for entity_name, count in ref_dict.items(): if disaster_name in disaster_dict: try: disaster_dict[disaster_name][entity_name] += int(count) except KeyError: disaster_dict[disaster_name][entity_name] = int(count) else: disaster_dict[disaster_name] = {entity_name: int(count)}