Esempio n. 1
0
    def parse_node(self, item: wdi_core.WDItemEngine):
        type_statements = [s for s in item.statements if s.get_prop_nr() == self.type_pid]
        if len(type_statements) != 1:
            return None
        node_template = dict()
        node_template[':LABEL'] = self.qid_dbxref["Q" + str(type_statements[0].get_value())]
        node_template['id:ID'] = self.qid_dbxref[item.wd_item_id]
        node_template['preflabel'] = self.undo_id_parenthesis(item.get_label())
        node_template['name'] = item.get_label()
        node_template['description'] = item.get_description()
        node_template['synonyms:IGNORE'] = "|".join(item.get_aliases())

        return node_template
Esempio n. 2
0
 def _remove_alias(self, entity: wdi_core.WDItemEngine,
                   objct: LiteralElement) -> wdi_core.WDItemEngine:
     lang = get_lang_from_literal(objct)
     logging.debug("Removing alias @%s of %s", lang, entity)
     curr_aliases = entity.get_aliases(lang)
     try:
         curr_aliases.remove(objct.content)
         entity.set_aliases(curr_aliases, lang, append=False)
     except ValueError:
         logging.warning(
             "Alias %s@%s does not exist for object %s. Skipping removal...",
             objct.content, lang, entity.wd_item_id)
     return entity