Files
b2txt25/TTA-E/test_evaluate_syntax.py
2025-10-06 15:17:44 +08:00

50 lines
1.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
简单的语法测试脚本检查evaluate_model.py是否有语法错误
"""
import sys
import os
# 添加路径
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'model_training'))
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'model_training_lstm'))
try:
print("Testing imports...")
# 测试基本导入
import torch
import numpy as np
import pandas as pd
from omegaconf import OmegaConf
import time
from tqdm import tqdm
import editdistance
import argparse
print("✓ Basic imports successful")
# 测试模型导入
from model_training.rnn_model import GRUDecoder
from model_training_lstm.rnn_model import LSTMDecoder
from model_training.evaluate_model_helpers import *
print("✓ Model imports successful")
# 测试是否能解析evaluate_model.py文件语法
import ast
eval_file = os.path.join(os.path.dirname(__file__), 'evaluate_model.py')
with open(eval_file, 'r') as f:
code = f.read()
# 解析语法
ast.parse(code)
print("✓ evaluate_model.py syntax is valid")
print("\nAll tests passed! The modified code should work correctly.")
except SyntaxError as e:
print(f"✗ Syntax error in evaluate_model.py: {e}")
print(f"Line {e.lineno}: {e.text}")
except ImportError as e:
print(f"✗ Import error: {e}")
except Exception as e:
print(f"✗ Other error: {e}")