MaRDI4NFDI / python-zbMathRest2Oai

Read data from the zbMATH Open API https://api.zbmath.org/docs and feed it to the OAI-PMH server https://oai.portal.mardi4nfdi.de/oai/
GNU General Public License v3.0
4 stars 0 forks source link

Add sets #103

Open physikerwelt opened 1 month ago

physikerwelt commented 1 month ago

old code


def is_jfm(hit) -> bool:

    try:

        return hit["_source"]["database"] == "JFM"

    except KeyError:

        return False

def append_set_info(hit, parent, doc):

    classification = collect_info_for_hit(hit, "classification")

    sets = {""}

    for v in str(classification).split(";"):

        sets.add(v.strip()[0:2])

    sets.remove("")

    if is_jfm(hit):

        sets.add("JFM")

    # sorted is required for integration tests

    for s in sorted(sets):

        node = doc.createElement("setSpec")

        node.appendChild(doc.createTextNode(s))

        parent.appendChild(node)