Skip to content

Instantly share code, notes, and snippets.

@aquemy
Created December 23, 2020 10:09
Show Gist options
  • Save aquemy/fc7e39abb85df4b4627b205f7239289e to your computer and use it in GitHub Desktop.
Save aquemy/fc7e39abb85df4b4627b205f7239289e to your computer and use it in GitHub Desktop.
import json
import pandas as ps
def get_json_data(file):
with open(file, 'r') as f:
return json.load(f)
obj = get_json_data('./echr-od/ECHR-OD_process/build/echr_database/unstructured/cases.json')
case = obj[0] # Test on the first case only
judgment = list(case['content'].values())[0] # Right now there is only one document per case
facts = judgment[1]
assert facts.get('section_name') == 'facts' # Just to be sure
# or
facts = next((e for e in judgment if e.get('section_name') == 'facts'))
# Now, to get only the text, without the subsection titles, we need a small recursive function
def json_to_text_(doc):
res = []
if not len(doc['elements']): # Remove this condition to add subsection titles
res.append(doc['content'])
for e in doc['elements']:
res.extend(json_to_text_(e))
return res
def json_to_text(doc):
return '\n'.join(json_to_text_(doc))
print(json_to_text(facts))
aquemy@workstation:~/projects$ python3 get_facts.py 
10.  The first applicant was born in 1941 and lives in Amman (Jordan). According to the Security Council of the United Nations (UN), he was head of finance for the Iraqi secret services under the regime of Saddam Hussein. The second applicant is a company incorporated under the laws of Panama and which has its registered office in Panama. The first applicant is its managing director.
11.  After Iraq invaded Kuwait on 2 August 1990, the UN Security Council adopted Resolution 661 (1990) of 6 August 1990 and Resolution 670 (1990) of 25 September 1990, calling upon UN member States and nonmember States to apply a general embargo against Iraq and on any Kuwaiti resources confiscated by the occupier, together with an embargo on air transport.
12.  On 7 August 1990 the Swiss Federal Council adopted an ordinance providing for economic measures against the Republic of Iraq (“the Iraq Ordinance”; see paragraph 36 below). The applicants alleged that since that date their assets in Switzerland had remained frozen.
13.  On 10 September 2002 Switzerland became a member of the United Nations.
14.  On 22 May 2003 the UN Security Council adopted Resolution 1483 (2003), superseding Resolution 661 (1990), among others (see paragraph 46 below). Paragraph 23 of Resolution 1483 (2003) reads as follows.
“The Security Council
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment