import education import location import other_contexts import occupation # import personname # import lifeInfo import birthDeath """ This is a possible temporary main script that creates the biography related triples TODO: add documentation implement personname """ logger = utilities.config_logger("biography") def main(): file_dict = utilities.parse_args(__file__, "Majority of biography related data") entry_num = 1 uber_graph = utilities.create_graph() highest_triples = 0 least_triples = 0 smallest_person = None largest_person = None logger.info("Time started: " + utilities.get_current_time() + "\n")
from rdflib import Literal from Utils import utilities from Utils.context import Context from Utils.event import Event from Utils.organizations import get_org_uri """ Status: ~75% TODO: - review unmapped instances - revise method of capturing failed mappings to be similar to culturalforms """ # temp log library for debugging # --> to be eventually replaced with proper logging library logger = utilities.config_logger("occupation") uber_graph = utilities.create_graph() context_count = 0 event_count = 0 class Occupation(object): """docstring for Occupation """ def __init__(self, job_tag, predicate=None, other_attributes=None): super(Occupation, self).__init__() if predicate: self.predicate = predicate self.value = self.get_mapped_term(job_tag) else:
#!/usr/bin/python3 from biography import Biography from Utils.context import Context from Utils.event import Event from Utils.place import Place from Utils import utilities """ Status: ~80% """ logger = utilities.config_logger("location") uber_graph = utilities.create_graph() location_occurences = {} location_count = { "VISITED": 0, "UNKNOWN": 0, "TRAVELLED": 0, "LIVED": 0, "MIGRATED": 0, "MOVED": 0, } location_event_count = { "VISITED": 0, "UNKNOWN": 0, "TRAVELLED": 0, "LIVED": 0,
from Utils.organizations import get_org, get_org_uri from Utils.place import Place from Utils.event import Event from Utils.context import Context """ Status: ~90% Most of cultural forms have been mapped TODO: Review missing religions & PAs Forebear still needs to be handled/attempted with a query --> load up gurjap's produced graph and query it for forebear info to test temp solution until endpoint is active """ logger = utilities.config_logger("culturalform") uber_graph = utilities.create_graph() class CulturalForm(object): """docstring for CulturalForm NOTE: mapping is done prior to creation of cf instance, no need to include class type then using other_attributes to handle extra predicates that may come up for cfs Ex. Organizations other_attributes=utilities.NS_DICT["org"].memberOf This being the uri rather the typical cf one """ def __init__(self, predicate, reported, value, other_attributes=None):
from Utils import utilities from Utils.context import Context from Utils.place import Place from Utils.event import get_date_tag, Event, format_date # TODO: clean up imports post death # Should be matched up to deb's contexts somehow # otherwise we're looking at duplicate contexts # two unique id'd contexts but with the same text and different triples # attached but this might fine if we're distinguishing between # death context vs cause of death context # TODO # - once resolved: https://github.com/cwrc/ontology/issues/462 # - handle multiple DEATH/BIRTH tags logger = utilities.config_logger("birthdeath") class Birth: def __init__(self, date, positions, birthplace): self.date = date self.position = [] self.place = birthplace for birth_position in positions: if birth_position == "ONLY": self.position.append(utilities.NS_DICT["cwrc"].onlyChild) elif birth_position == "ELDEST": self.position.append(utilities.NS_DICT["cwrc"].eldestChild) elif birth_position == "YOUNGEST": self.position.append(utilities.NS_DICT["cwrc"].youngestChild)
from biography import Biography from Utils import utilities from Utils.context import Context from Utils.event import Event """ Status: ~89% extraction of health context will possibly accompanied by health factors at a later point only identifying contexts being created """ logger = utilities.config_logger("other_contexts") uber_graph = utilities.create_graph() def extract_health_contexts_data(bio, person): issue_map = { "PHYSICAL": "PhysicalHealthContext", "MENTAL": "MentalHealthContext", "FEMALEBODY": "WomensHealthContext", } contexts = bio.find_all("HEALTH") count = 1 event_count = 1 for context in contexts: context_type = context.get("ISSUE") if context_type: context_type = issue_map[context_type] else: context_type = "HealthContext" paragraphs = context.find_all("P") for paragraph in paragraphs: context_id = person.id + "_" + context_type + str(count)
for thisTag in name.find_all(tagname): newPerson = makePerson(basic_layout_dict[tagname], thisTag, personNameList, personName=person.name) if newPerson: personNameList.append(newPerson) person.name_list = personNameList context_id = person.id + "_PersonNameContext" + str(0) tempContext = Context(context_id, personNameTags[0], "PersonNameContext") tempContext.link_triples(person.name_list[1:]) person.context_list.append(tempContext) logger = utilities.config_logger("personname") def main(): from bs4 import BeautifulSoup import culturalForm from biography import Biography file_dict = utilities.parse_args(__file__, "Personname") print("-" * 200) entry_num = 1 uber_graph = utilities.create_graph() for filename in file_dict.keys(): with open(filename) as f: soup = BeautifulSoup(f, 'lxml-xml')