Spaces:
Sleeping
Sleeping
| import json | |
| text = """```json | |
| [ | |
| ["Sunday", "Thursday"], | |
| ["two millions", "one million"], | |
| ["north", "east"], | |
| ["Japan", "UK"], | |
| ["Sunday", "Thursday"] | |
| ] | |
| ``` | |
| """ | |
| def read_json(json_string) -> list[list[str]]: | |
| try: | |
| entities = json.loads(json_string) | |
| # Remove duplicates pair of entities | |
| unique_data = [] | |
| for inner_list in entities: | |
| if inner_list not in unique_data: | |
| unique_data.append(inner_list) | |
| return unique_data | |
| except json.JSONDecodeError as e: | |
| print(f"Error decoding JSON: {e}") | |
| return [] | |
| print(read_json(text.replace("```json", "").replace("```", ""))) |