Skip to content

Commit 4c03db1

Browse files
Update compression.py
Pathing confirmation added for input / output
1 parent bea8937 commit 4c03db1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

compression/compression.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import sys
12
import json
2-
from collections import defaultdict
33
import os
4+
from collections import defaultdict
5+
6+
# Ensure a file path is provided
7+
if len(sys.argv) != 2:
8+
raise ValueError("Please provide the path to 'python_code_knowledge_graph.json' as an argument.")
9+
10+
input_file = sys.argv[1]
411

512
# Load the knowledge graph from the JSON file
6-
with open("python_code_knowledge_graph.json", "r") as f:
13+
if not os.path.exists(input_file):
14+
raise FileNotFoundError(f"File not found: {input_file}")
15+
16+
with open(input_file, "r") as f:
717
knowledge_graph = json.load(f)
818

919
# Function to generate abbreviations for all unique terms

0 commit comments

Comments
 (0)