How to use the biblib.metajson.Person function in biblib

To help you get started, we’ve selected a few biblib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github medialab / reference_manager / biblib / services / creator_service.py View on Github external
if name_family and name_family.lower().startswith(particule+" "):
                    name_prefix = name_family[0:len(particule)]
                    name_family = name_family[len(particule):].strip()
                if name_given:
                    if name_given.lower().endswith(" "+particule):
                        name_prefix = name_given[-len(particule):]
                        name_given = name_given[:-len(particule)].strip()
                    if name_given.lower().startswith(particule+" "):
                        name_prefix = name_given[:len(particule)]
                        name_given = name_given[len(particule):].strip()
                    if name_given.lower() == particule:
                        name_prefix = name_given
                        name_given = None

            if rec_class == constants.REC_CLASS_PERSON:
                person = Person()
                person.set_key_if_not_none("name_family", name_family)
                person.set_key_if_not_none("name_given", name_given)
                person.set_key_if_not_none("name_middle", name_middle)
                person.set_key_if_not_none("name_terms_of_address", name_terms_of_address)
                person.set_key_if_not_none("name_prefix", name_prefix)
                person.set_key_if_not_none("date_birth", date_birth)
                person.set_key_if_not_none("date_death", date_death)

                creator["agent"] = person

                if 'affiliation_name' in vars() and affiliation_name:
                    #todo manage as an object
                    affiliation = Orgunit()
                    affiliation["name"] = affiliation_name
                    creator["affiliation"] = affiliation
github medialab / reference_manager / biblib / services / metajson_service.py View on Github external
def load_dict(meta_dict):
    if "rec_class" not in meta_dict:
        return Common(meta_dict)
    elif meta_dict["rec_class"] == "Document":
        return Document(meta_dict)
    elif meta_dict["rec_class"] == "Person":
        return Person(meta_dict)
    elif meta_dict["rec_class"] == "Orgunit":
        return Orgunit(meta_dict)
    elif meta_dict["rec_class"] == "Project":
        return Project(meta_dict)
    elif meta_dict["rec_class"] == "Event":
        return Event(meta_dict)
    elif meta_dict["rec_class"] == "Family":
        return Family(meta_dict)
    elif meta_dict["rec_class"] == "Field":
        return Field(meta_dict)
    elif meta_dict["rec_class"] == "Resource":
        return Resource(meta_dict)
    elif meta_dict["rec_class"] == "Target":
        return Target(meta_dict)
    elif meta_dict["rec_class"] == "Type":
        return Type(meta_dict)
github medialab / reference_manager / biblib / crosswalks / unimarc_crosswalk.py View on Github external
def extract_unimarc_creator(field):
    if field:
        creator = Creator()
        # $4 -> role
        if field['4'] and field['4'] in creator_service.role_unimarc_to_role_code:
            creator["roles"] = [creator_service.role_unimarc_to_role_code[field['4']]]
        elif field.tag in ["700", "701", "710", "711", "720", "721", "740", "741"]:
            creator["roles"] = ["aut"]
        else:
            creator["roles"] = ["ctb"]

        # 600, 700, 701, 702 -> Person
        if field.tag in ["600", "700", "701", "702"]:
            # Person
            person = Person()
            if field.subfields:
                if field.get_subfields('a'):
                    # name_family
                    person["name_family"] = "".join(field.get_subfields('a'))
                if field.get_subfields('b'):
                    # name_given
                    person["name_given"] = "".join(field.get_subfields('b'))
                if field.get_subfields('f'):
                    dates = format_dates_as_list(field.get_subfields('f'))
                    if dates:
                        person["date_birth"] = dates[0]
                        if len(dates) > 1:
                            person["date_death"] = dates[1]
                if person:
                    creator["agent"] = person
github medialab / reference_manager / biblib / crosswalks / mods_crosswalk.py View on Github external
elif dai_dict is not None and mods_name_id in dai_dict:
                # agent_rec_id
                agent_rec_id = dai_dict[mods_name_id]["value"]
                # agent_identifiers
                id_value = dai_dict[mods_name_id]["authority"] + "/" + dai_dict[mods_name_id]["value"]
                agent_identifiers = [metajson_service.create_identifier("uri", id_value)]

        if mods_name_affiliations:
            affiliation_name = mods_name_affiliations[0].text.strip()

        if affiliation_name or affiliation_rec_id:
            affiliation = metajson_service.create_affiliation(affiliation_rec_id, affiliation_name, None, None, None, False)

        if mods_name_type == "personal":
            # logging.debug("personal")
            person = Person()

            if agent_rec_id:
                person["rec_id"] = agent_rec_id
            if agent_identifiers:
                person["identifiers"] = agent_identifiers

            if mods_name_parts:
                for mods_name_part in mods_name_parts:
                    if mods_name_part.get("type") == "given":
                        person["name_given"] = mods_name_part.text.strip()
                    elif mods_name_part.get("type") == "family":
                        person["name_family"] = mods_name_part.text.strip()
                    elif mods_name_part.get("type") == "date":
                        date = mods_name_part.text.replace("(", "").replace(")", "").strip()
                        minus_index = date.find("-")
                        if minus_index == -1:
github medialab / reference_manager / biblib / crosswalks / researcherml_crosswalk.py View on Github external
def rml_person_to_metajson(rml_person, source, rec_id_prefix):
    """ person -> person """
    person = Person()

    # source
    if source:
        person["rec_source"] = source

    # academicTitle, honorificTitle -> titles
    person.update(get_rml_titles(rml_person))

    # address -> addresses
    person.update(get_rml_addresses(rml_person))

    # affiliation -> affiliations
    person.update(get_rml_affiliations(rml_person))

    # award -> awards
    person.update(get_rml_textlangs_and_set_key(rml_person, "award", "awards"))
github medialab / reference_manager / biblib / crosswalks / summonjson_crosswalk.py View on Github external
def convert_creators(sum_doc, sum_authors_key, sum_affiliations_key, creator_type, role):
    creators = []
    if sum_authors_key in sum_doc:
        sum_authors = sum_doc[sum_authors_key]
        if sum_authors:
            affiliations_dict = {}
            if sum_affiliations_key in sum_doc:
                sum_affiliations = sum_doc[sum_affiliations_key]
                if sum_affiliations:
                    for index, affiliation in enumerate(sum_affiliations):
                        affiliations_dict[index + 1] = affiliation

            for author in sum_authors:
                creator = Creator()
                if "surname" in author and "givenname" in author:
                    person = Person()
                    person.set_key_if_not_none("name_family", author["surname"])
                    person.set_key_if_not_none("name_given", author["givenname"])
                    creator["agent"] = person
                    if role:
                        creator["roles"] = [role]
                else:
                    formatted_name = ""
                    if "fullname" in author:
                        formatted_name = author["fullname"]
                    elif "name" in author:
                        formatted_name = author["name"]

                    creator = creator_service.formatted_name_to_creator(formatted_name, creator_type, role)
                if "sequence" in author and author["sequence"] in affiliations_dict:
                    creator["affiliation"] = affiliations_dict[author["sequence"]]