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""" location names.") logging.info("Loading NamedEntity.load_names(Location) agency names.") logging.info("Loading NamedEntity.load_names(Agency) loaded: \n" "\n") logging.info("Locations + str(Location.names) + 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)}
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)}
CS4624ProjectReport.docx