def set_location(self): if self.has_non_empty_attribute("location"): location_q = utils.q_from_first_wikilink("en", self.location) if location_q: self.add_statement("location", location_q) else: self.add_to_report("location", self.location, "location")
def set_architect(self): if self.has_non_empty_attribute("bouwdoor"): if utils.count_wikilinks(self.bouwdoor) == 1: arch_q = utils.q_from_first_wikilink("nl", self.bouwdoor) self.add_statement("architect", arch_q) else: self.add_to_report("bouwdoor", self.bouwdoor, "architect")
def set_adm_location(self): """ Set the administrative location. First try to resolve the municipality, and if that doesn't work use the department which is a higher unit. """ match = None if self.has_non_empty_attribute("municipio"): match = utils.q_from_first_wikilink("es", self.municipio) if not match: self.add_to_report("municipio", self.municipio, "located_adm") if not match: dep_match = utils.get_item_from_dict_by_key( dict_name=self.data_files["departments"], search_term=self.iso, search_in="iso") if len(dep_match) == 1: match = dep_match[0] else: self.add_to_report("iso", self.iso, "located_adm") if match: self.add_statement("located_adm", match)
def set_location(self): """ Set the Location. Use the linked Localidad if available, and if it's not linked, try and see if there's an article anyway. Compare against external list of settlements. """ loc_dic = self.data_files["settlements"] loc_q = None if self.has_non_empty_attribute("localidad"): loc_raw = self.localidad if utils.count_wikilinks(loc_raw) == 1: loc_try = utils.q_from_first_wikilink("es", loc_raw) loc_match = utils.get_item_from_dict_by_key( dict_name=loc_dic, search_term=loc_try, search_in="item") if len(loc_match) == 1: loc_q = loc_try else: loc_try = utils.q_from_wikipedia("es", loc_raw) loc_match = utils.get_item_from_dict_by_key( dict_name=loc_dic, search_term=loc_try, search_in="item") if len(loc_match) == 1: loc_q = loc_try if loc_q: self.add_statement("location", loc_q) else: self.add_to_report("localidad", self.localidad, "location")
def set_adm_location(self): """ Set the Admin Location. Use the linked Municipality first, checking against external list. If failed, use the Region iso code, which is a bigger unit. """ adm_q = None municip_dic = self.data_files["municipalities"] region_dict = self.data_files["regions"] municip_q = utils.q_from_first_wikilink("es", self.comuna) if utils.get_item_from_dict_by_key(dict_name=municip_dic, search_term=municip_q, search_in="item"): adm_q = municip_q else: self.add_to_report("comuna", self.comuna, "located_adm") if adm_q is None: iso_match = utils.get_item_from_dict_by_key(dict_name=region_dict, search_term=self.ISO, search_in="iso") if len(iso_match) == 1: adm_q = iso_match[0] else: self.add_to_report("ISO", self.ISO, "located_adm") if adm_q: self.add_statement("located_adm", adm_q)
def set_location(self): """Set location, using wikilinked value.""" if self.has_non_empty_attribute("ville"): if utils.count_wikilinks(self.ville) == 1: loc_q = utils.q_from_first_wikilink("fr", self.ville) self.add_statement("location", loc_q) else: self.add_to_report("ville", self.ville, "location")
def set_adm_location(self): adm_match = None if self.has_non_empty_attribute("county"): adm_match = utils.q_from_first_wikilink("en", self.county) if adm_match: self.add_statement("located_adm", adm_match) else: self.add_to_report("county", self.county, "located_adm")
def exists_with_monument_article(self, language): """ Set article about the object. Note that "articulo" goes to the "main article", often one level above the particular object. """ if self.has_non_empty_attribute("nombre"): return utils.q_from_first_wikilink("es", self.nombre)
def set_location(self): """Set the Location, using linked article.""" loc_q = None if self.has_non_empty_attribute("localidad"): if utils.count_wikilinks(self.localidad) == 1: loc_q = utils.q_from_first_wikilink("es", self.localidad) if loc_q: self.add_statement("location", loc_q) else: self.add_to_report("localidad", self.localidad, "location")
def set_homeport(self): """ Add homeport to data object. Only works if column 'hemmahamn' contains exactly one wikilink. Use WLM database as source. """ if self.has_non_empty_attribute("hemmahamn"): if utils.count_wikilinks(self.hemmahamn) == 1: home_port = utils.q_from_first_wikilink("sv", self.hemmahamn) ref = self.wlm_source self.add_statement("home_port", home_port, refs=[ref])
def set_location(self): settlements_dict = self.data_files["settlements"] if utils.count_wikilinks(self.miejscowosc) == 1: location = utils.q_from_first_wikilink("pl", self.miejscowosc) self.add_statement("location", location) else: placename = utils.remove_markup(self.miejscowosc) try: location = [x["item"] for x in settlements_dict if x[ "pl"].strip() == placename][0] self.add_statement("location", location) except IndexError: return
def set_adm_location(self): """ Set administrative location, or location. The 'municipality' field contains links pointing at both municipalities/districts and settlements. Try to first match actual administrative units, and if that doesn't work, settlements via mapping file. Settlements are added as 'location'. """ adm_q = None settlement_q = None adm_dic = self.data_files["admin"] settlement_dic = self.data_files["settlements"] if self.has_non_empty_attribute("municipality"): if utils.count_wikilinks(self.municipality) == 1: adm_try = utils.q_from_first_wikilink("ka", self.municipality) # ensure this is an administrative unit... if any(x['item'] == adm_try for x in adm_dic): adm_q = adm_try # alternatively a settlement elif any(x['item'] == adm_try for x in settlement_dic): settlement_q = adm_try else: adm_match = utils.get_item_from_dict_by_key( dict_name=adm_dic, search_term=self.municipality, search_in="itemLabel") if len(adm_match) == 1: adm_q = adm_match[0] else: settlement_match = utils.get_item_from_dict_by_key( dict_name=settlement_dic, search_term=self.municipality, search_in="itemLabel") if len(settlement_match) == 1: settlement_q = settlement_match[0] if adm_q: self.add_statement("located_adm", adm_q) if settlement_q: self.add_statement("location", settlement_q) else: self.add_to_report("municipality", self.municipality, "located_adm")
def set_location(self): loc_q = None loc_dic = self.data_files["settlements"] if self.has_non_empty_attribute("plaats"): if utils.count_wikilinks(self.plaats) == 1: loc_q = utils.q_from_first_wikilink("nl", self.plaats) else: loc_match = utils.get_item_from_dict_by_key( dict_name=loc_dic, search_term=self.plaats, search_in="itemLabel", return_content_of="item") if len(loc_match) == 1: loc_q = loc_match[0] if loc_q: self.add_statement("location", loc_q) else: self.add_to_report("plaats", self.plaats, "location")
def set_adm_location(self): """ Set municipality of the object. Note: All distinct values in this column are wikilinked and in the form "[[Allerød Kommune]]". For safety, compare with offline list of Danish municipalities. """ mun_dict = self.data_files["municipalities"] if self.has_non_empty_attribute("kommune"): if utils.count_wikilinks(self.kommune) == 1: try: adm_q = utils.q_from_first_wikilink("da", self.kommune) municipality = [ x["item"] for x in mun_dict if x["item"] == adm_q ] municipality = municipality[0] self.add_statement("located_adm", municipality) except IndexError: self.add_to_report("kommune", self.kommune)
def set_shipyard(self): """ Set the manufacturer property. Process the column 'varv'. It can look like this: '[[Bergsunds varv]]<br>[[Stockholm]]' We only use this if the actual shipyard is wikilinked, which is not always the case. Use WLM database as reference. """ if self.has_non_empty_attribute("varv"): possible_varv = self.varv if "<br>" in possible_varv: possible_varv = self.varv.split("<br>")[0] if "[[" in possible_varv: varv = utils.q_from_first_wikilink("sv", possible_varv) ref = self.wlm_source self.add_statement("manufacturer", varv, refs=[ref]) else: self.add_to_report("varv", self.varv)
def set_adm_location(self): """ Set the Admin Location. Use the linked Municipality first then fall back on state iso code, which is a bigger unit. """ adm_q = utils.q_from_first_wikilink("es", self.municipio) if adm_q is None: self.add_to_report("municipio", self.municipio, "located_adm") iso_match = utils.get_item_from_dict_by_key( dict_name=self.data_files["states"], search_term=self.estado_iso, search_in="iso") if len(iso_match) == 1: adm_q = iso_match[0] else: self.add_to_report("estado_iso", self.estado_iso, "located_adm") if adm_q: self.add_statement("located_adm", adm_q)
def set_location(self): """ Set the location. If present, use the wikilink, otherwise match value against list of settlements. """ loc_q = None loc_raw = self.site if utils.count_wikilinks(loc_raw) == 1: loc_q = utils.q_from_first_wikilink("fr", loc_raw) else: loc_dic = self.data_files["settlements"] loc_match = utils.get_item_from_dict_by_key(dict_name=loc_dic, search_term=loc_raw, search_in="itemLabel") if len(loc_match) == 1: loc_q = loc_match[0] if loc_q: self.add_statement("location", loc_q) else: self.add_to_report("site", self.site, "location")
def set_location(self): """ Set location or street address. There are some street addresses. Some are simple: Norra Murgatan 3 Some are complex: Skolgatan 5, Västra Kyrkogatan 3 Norra Murgatan 27, Uddens gränd 14-16 If self.plats consists of 1 wikilinked item, get the WD item and cross check with the list of known human settlements. If it's not wikilinked text, try to extract an address. """ settlements_dict = self.data_files["settlements"] if self.has_non_empty_attribute("plats"): if utils.count_wikilinks(self.plats) == 1: location_q = utils.q_from_first_wikilink("sv", self.plats) try: legit_location = [ x["item"] for x in settlements_dict if x["item"] == location_q ] legit_location_clean = legit_location[0] self.add_statement("location", legit_location_clean) except IndexError: self.add_to_report("plats", self.plats) elif utils.count_wikilinks(self.plats) == 0: processed_address = utils.get_street_address(self.plats, "sv") if processed_address: self.add_statement("located_street", processed_address) else: self.add_to_report("plats", self.plats) else: self.add_to_report("plats", self.plats)
def set_adm_location(self): """ Set the Admin Location. Try a linked Municipality first, then unlinked Municipality. If failed, use the Department iso code. """ adm_q = None municip_dic = self.data_files["municipalities"] dep_dic = self.data_files["departments"] municip_raw = self.municipio iso = self.departamento_iso if utils.count_wikilinks(municip_raw) == 1: adm_q = utils.q_from_first_wikilink("es", municip_raw) else: municip_match = utils.get_item_from_dict_by_key( dict_name=municip_dic, search_in="itemLabel", search_term=municip_raw) if len(municip_match) == 1: adm_q = municip_match[0] if adm_q is None: self.add_to_report("municipio", municip_raw, "located_adm") dep_match = utils.get_item_from_dict_by_key( dict_name=dep_dic, search_in="iso", search_term=iso) if len(dep_match) == 1: adm_q = dep_match[0] else: self.add_to_report("departamento_iso", iso, "located_adm") if adm_q is not None: self.add_statement("located_adm", adm_q)
def set_adm_location(self): if self.has_non_empty_attribute("kommune"): if utils.count_wikilinks(self.kommune) == 1: adm_location = utils.q_from_first_wikilink("da", self.kommune) self.add_statement("located_adm", adm_location)
def set_adm_location(self): if self.has_non_empty_attribute("freguesia"): parish = utils.q_from_first_wikilink("pt", self.freguesia) self.add_statement("located_adm", parish)