MCPcopy Index your code
hub / github.com/going-doer/Paper2Code / content_to_json3

Function content_to_json3

codes/utils.py:70–98  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

68 return content_to_json3(data)
69
70def content_to_json3(data):
71 # remove [CONTENT] [/CONTENT]
72 clean_data = re.sub(r'\[CONTENT\]|\[/CONTENT\]', '', data).strip()
73
74 # "~~~~", #comment -> "~~~~",
75 clean_data = re.sub(r'(".*?"),\s*#.*', r'\1,', clean_data)
76
77 # "~~~~" #comment → "~~~~"
78 clean_data = re.sub(r'(".*?")\s*#.*', r'\1', clean_data)
79
80 # remove ("~~~~",] -> "~~~~"])
81 clean_data = re.sub(r',\s*\]', ']', clean_data)
82
83 clean_data = re.sub(r'\n\s*', '', clean_data)
84 clean_data = re.sub(r'"""', '"', clean_data) # Replace triple double quotes
85 clean_data = re.sub(r"'''", "'", clean_data) # Replace triple single quotes
86 clean_data = re.sub(r"\\", "'", clean_data) # Replace \
87
88 # JSON parsing
89 try:
90 json_data = json.loads(f"""{clean_data}""")
91 return json_data
92
93 except json.JSONDecodeError as e:
94 # print(e)
95
96 # print(f"[DEBUG] utils.py > content_to_json3 ")
97 # return None
98 return content_to_json4(data)
99
100def content_to_json4(data):
101 # 1. Extract Logic Analysis, Task list

Callers 1

content_to_json2Function · 0.85

Calls 1

content_to_json4Function · 0.85

Tested by

no test coverage detected