From b48717a023ce7c485bf1aade50cd9d08efc75006 Mon Sep 17 00:00:00 2001 From: Theodor Vogl Date: Fri, 9 Jun 2023 13:49:01 +0200 Subject: [PATCH] fix, ipcs vor 2006 wurden falsch eingelesen --- xml_to_json.py | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/xml_to_json.py b/xml_to_json.py index ca407c1..e179f83 100644 --- a/xml_to_json.py +++ b/xml_to_json.py @@ -262,20 +262,33 @@ def parse(xml_dict, filename, tree): # patent classification tags from 2005 and earlier # ipc if sdobi.get("B500").get("B510") != None: - es_dict["ipc"] = [sdobi.get("B500").get("B510")] - es_dict["ipc_text"] = sdobi.get("B500").get("B510") + # es_dict["ipc"] = [sdobi.get("B500").get("B510")] + # es_dict["ipc_text"] = sdobi.get("B500").get("B510") + classis = [] if sdobi.get("B500").get("B510").get("B511") != None: - es_dict["section"] = [sdobi.get("B500").get("B510").get("B511")] + try: + if sdobi.get("B500").get("B510").get("B511") != None: + classis.append(sdobi.get("B500").get("B510").get("B511")) + except: + for i in range(len(sdobi.get("B500").get("B510").get("B511"))): + classis.append(sdobi.get("B500").get("B510").get("B511")[i]) if sdobi.get("B500").get("B510").get("B512") != None: - es_dict["class"] = [sdobi.get("B500").get("B510").get("B512")] - if sdobi.get("B500").get("B510").get("B513") != None: - es_dict["subclass"] = [sdobi.get("B500").get("B510").get("B513")] - if sdobi.get("B500").get("B510").get("B514") != None: - es_dict["linked_indexing_code"] = sdobi.get("B500").get("B510").get("B514") - if sdobi.get("B500").get("B510").get("B515") != None: - es_dict["unlinked_indexing_code"] = sdobi.get("B500").get("B510").get("B515") - if sdobi.get("B500").get("B510").get("B517EP") != None: - es_dict["non_obligatory_suppl_class"] = sdobi.get("B500").get("B510").get("B517EP") + b512 = sdobi.get("B500").get("B510").get("B512") + if isinstance(b512, str): + classis.append(b512) + elif isinstance(b512, list): + for i in range(len(b512)): + classis.append(b512[i]) + + es_dict["ipc"] = classis + text_combi = "" + for text in classis: + if text is not None: + text_combi += text + " - " + if text_combi != "": + text_combi = text_combi[:-3] + + es_dict["ipc_text"] = text_combi # patent classification tags from 2006 and later # its one string that needs to be splittet into the classification parts