DouDou commited on
Upload data3/check_relationship.py with huggingface_hub
Browse files- data3/check_relationship.py +68 -0
data3/check_relationship.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Let's understand the relationship between the datasets by comparing a few records.
|
| 4 |
+
"""
|
| 5 |
+
import csv
|
| 6 |
+
import json
|
| 7 |
+
|
| 8 |
+
# Read function_dataset_v2.csv and check what each column represents
|
| 9 |
+
print("=== function_dataset_v2.csv structure ===")
|
| 10 |
+
with open('function_dataset_v2.csv', 'r', encoding='utf-8') as f:
|
| 11 |
+
reader = csv.DictReader(f)
|
| 12 |
+
headers = reader.fieldnames
|
| 13 |
+
print(f"Headers: {headers}")
|
| 14 |
+
|
| 15 |
+
# Get a row that HAS metadata
|
| 16 |
+
print("\nFinding a row with complete metadata...")
|
| 17 |
+
for row in reader:
|
| 18 |
+
if row['repo_name'] and row['path'] and row['language']:
|
| 19 |
+
print(f"\nSample row WITH metadata:")
|
| 20 |
+
print(f" original_index: {row['original_index']}")
|
| 21 |
+
print(f" function_index: {row['function_index']}")
|
| 22 |
+
print(f" repo_name: {row['repo_name']}")
|
| 23 |
+
print(f" path: {row['path']}")
|
| 24 |
+
print(f" language: {row['language']}")
|
| 25 |
+
print(f" function_name: {row['function_name']}")
|
| 26 |
+
break
|
| 27 |
+
|
| 28 |
+
# Now check programming_problems.jsonl
|
| 29 |
+
print("\n\n=== programming_problems.jsonl structure ===")
|
| 30 |
+
with open('programming_problems.jsonl', 'r', encoding='utf-8') as f:
|
| 31 |
+
# Find an entry with row_number that might match
|
| 32 |
+
for line in f:
|
| 33 |
+
data = json.loads(line.strip())
|
| 34 |
+
# Just show first entry
|
| 35 |
+
print(f"First entry:")
|
| 36 |
+
print(f" row_number: {data.get('row_number')}")
|
| 37 |
+
print(f" metadata.original_index: {data['metadata']['original_index']}")
|
| 38 |
+
print(f" metadata.function_name: {data['metadata']['function_name']}")
|
| 39 |
+
print(f" metadata.repo_name: '{data['metadata']['repo_name']}'")
|
| 40 |
+
print(f" metadata.path: '{data['metadata']['path']}'")
|
| 41 |
+
print(f" metadata.language: '{data['metadata']['language']}'")
|
| 42 |
+
break
|
| 43 |
+
|
| 44 |
+
# The key question: does row_number in JSONL match the row number in CSV?
|
| 45 |
+
print("\n\n=== Checking if row_number matches CSV row ===")
|
| 46 |
+
with open('programming_problems.jsonl', 'r', encoding='utf-8') as f:
|
| 47 |
+
data = json.loads(f.readline())
|
| 48 |
+
target_row = data.get('row_number')
|
| 49 |
+
print(f"JSONL row_number: {target_row}")
|
| 50 |
+
|
| 51 |
+
# Get that row from CSV (row_number is probably 1-indexed after header)
|
| 52 |
+
with open('function_dataset_v2.csv', 'r', encoding='utf-8') as f:
|
| 53 |
+
reader = csv.DictReader(f)
|
| 54 |
+
for i, row in enumerate(reader):
|
| 55 |
+
if i + 1 == target_row: # CSV rows are 1-indexed
|
| 56 |
+
print(f"\nCSV row {target_row}:")
|
| 57 |
+
print(f" original_index: {row['original_index']}")
|
| 58 |
+
print(f" repo_name: '{row['repo_name']}'")
|
| 59 |
+
print(f" path: '{row['path']}'")
|
| 60 |
+
print(f" language: '{row['language']}'")
|
| 61 |
+
print(f" function_name: '{row['function_name']}'")
|
| 62 |
+
|
| 63 |
+
# Check if function names match
|
| 64 |
+
if row['function_name'] == data['metadata']['function_name']:
|
| 65 |
+
print(f"\n✅ Function names match! We should use row_number as the key.")
|
| 66 |
+
else:
|
| 67 |
+
print(f"\n❌ Function names don't match.")
|
| 68 |
+
break
|