| import sys | |
| import os | |
| # --- FIX IMPORT PATH (MẠNH HƠN) --- | |
| # Lấy đường dẫn tuyệt đối của file đang chạy (math_merge_eval.py) | |
| current_file_path = os.path.abspath(__file__) | |
| current_dir = os.path.dirname(current_file_path) | |
| parent_dir = os.path.dirname(current_dir) | |
| # Thêm đường dẫn vào sys.path để Python tìm thấy folder 'inference_math' | |
| # 1. Thêm chính thư mục chứa file này (nếu inference_math nằm cùng cấp) | |
| sys.path.insert(0, current_dir) | |
| # 2. Thêm thư mục cha (nếu file này nằm trong src/, còn inference_math nằm ngoài) | |
| sys.path.insert(0, parent_dir) | |
| # --- THỬ IMPORT VÀ DEBUG --- | |
| try: | |
| from inference_math import util | |
| from inference_math.grader import math_equal | |
| print("✅ Đã load thành công module: inference_math") | |
| except ImportError as e: | |
| print(f"❌ VẪN LỖI IMPORT: {e}") | |
| print(f"Python đang tìm kiếm trong các đường dẫn sau: {sys.path}") | |
| print("⚠️ Đang dùng hàm fallback (có thể sai kết quả đánh giá MATH).") | |
| # Fallback functions (như cũ) | |
| def math_equal(pred, ref): return float(pred) == float(ref) | |
| class util: | |
| def is_equiv(str1, str2): return str1 == str2 | |
| def last_boxed_only_string(s): return s |