adding Json file including context file

The goal of this file is to work on the dataset of more than 600 sections on the domain of insurance law.
This commit is contained in:
mmpouya 2025-01-26 12:01:32 +00:00
parent 8d1d72fa21
commit 716dc46804

30
Context_update/main.py Normal file
View File

@ -0,0 +1,30 @@
import json
input_file_path = '' #path
with open(input_file_path, 'r', encoding='utf-8') as file:
data = json.load(file)
for item in data:
if isinstance(item, dict):
name = item.get("qanon_title", "")
item.update({
"context": {
"qanon_name": name,
"parents_content": "parent_content_value",
"meaning_change": [{
"term": "str1",
"meaning" : "def"
}],
"referential term" : [{
"term": "this",
"referent" : "that"
}]
}
})
print("done")
output_file_path = 'output_data.json'
with open(output_file_path, 'w', encoding='utf-8') as file:
json.dump(data, file, indent=4, ensure_ascii=False)
print(f"Modified data has been saved to {output_file_path}")