fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 修复语法错误(运算符空格问题) - 修复类型注解格式
This commit is contained in:
@@ -10,9 +10,9 @@ import sys
|
||||
# 添加 backend 目录到路径
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
print("=" * 60)
|
||||
print(" = " * 60)
|
||||
print("InsightFlow 多模态模块测试")
|
||||
print("=" * 60)
|
||||
print(" = " * 60)
|
||||
|
||||
# 测试导入
|
||||
print("\n1. 测试模块导入...")
|
||||
@@ -42,7 +42,7 @@ except ImportError as e:
|
||||
print("\n2. 测试模块初始化...")
|
||||
|
||||
try:
|
||||
processor = get_multimodal_processor()
|
||||
processor = get_multimodal_processor()
|
||||
print(" ✓ MultimodalProcessor 初始化成功")
|
||||
print(f" - 临时目录: {processor.temp_dir}")
|
||||
print(f" - 帧提取间隔: {processor.frame_interval}秒")
|
||||
@@ -50,14 +50,14 @@ except Exception as e:
|
||||
print(f" ✗ MultimodalProcessor 初始化失败: {e}")
|
||||
|
||||
try:
|
||||
img_processor = get_image_processor()
|
||||
img_processor = get_image_processor()
|
||||
print(" ✓ ImageProcessor 初始化成功")
|
||||
print(f" - 临时目录: {img_processor.temp_dir}")
|
||||
except Exception as e:
|
||||
print(f" ✗ ImageProcessor 初始化失败: {e}")
|
||||
|
||||
try:
|
||||
linker = get_multimodal_entity_linker()
|
||||
linker = get_multimodal_entity_linker()
|
||||
print(" ✓ MultimodalEntityLinker 初始化成功")
|
||||
print(f" - 相似度阈值: {linker.similarity_threshold}")
|
||||
except Exception as e:
|
||||
@@ -67,20 +67,20 @@ except Exception as e:
|
||||
print("\n3. 测试实体关联功能...")
|
||||
|
||||
try:
|
||||
linker = get_multimodal_entity_linker()
|
||||
linker = get_multimodal_entity_linker()
|
||||
|
||||
# 测试字符串相似度
|
||||
sim = linker.calculate_string_similarity("Project Alpha", "Project Alpha")
|
||||
sim = linker.calculate_string_similarity("Project Alpha", "Project Alpha")
|
||||
assert sim == 1.0, "完全匹配应该返回1.0"
|
||||
print(f" ✓ 字符串相似度计算正常 (完全匹配: {sim})")
|
||||
|
||||
sim = linker.calculate_string_similarity("K8s", "Kubernetes")
|
||||
sim = linker.calculate_string_similarity("K8s", "Kubernetes")
|
||||
print(f" ✓ 字符串相似度计算正常 (不同字符串: {sim:.2f})")
|
||||
|
||||
# 测试实体相似度
|
||||
entity1 = {"name": "Project Alpha", "type": "PROJECT", "definition": "核心项目"}
|
||||
entity2 = {"name": "Project Alpha", "type": "PROJECT", "definition": "主要项目"}
|
||||
sim, match_type = linker.calculate_entity_similarity(entity1, entity2)
|
||||
entity1 = {"name": "Project Alpha", "type": "PROJECT", "definition": "核心项目"}
|
||||
entity2 = {"name": "Project Alpha", "type": "PROJECT", "definition": "主要项目"}
|
||||
sim, match_type = linker.calculate_entity_similarity(entity1, entity2)
|
||||
print(f" ✓ 实体相似度计算正常 (相似度: {sim:.2f}, 类型: {match_type})")
|
||||
|
||||
except Exception as e:
|
||||
@@ -90,7 +90,7 @@ except Exception as e:
|
||||
print("\n4. 测试图片处理器功能...")
|
||||
|
||||
try:
|
||||
processor = get_image_processor()
|
||||
processor = get_image_processor()
|
||||
|
||||
# 测试图片类型检测(使用模拟数据)
|
||||
print(f" ✓ 支持的图片类型: {list(processor.IMAGE_TYPES.keys())}")
|
||||
@@ -103,7 +103,7 @@ except Exception as e:
|
||||
print("\n5. 测试视频处理器配置...")
|
||||
|
||||
try:
|
||||
processor = get_multimodal_processor()
|
||||
processor = get_multimodal_processor()
|
||||
|
||||
print(f" ✓ 视频目录: {processor.video_dir}")
|
||||
print(f" ✓ 帧目录: {processor.frames_dir}")
|
||||
@@ -129,11 +129,11 @@ print("\n6. 测试数据库多模态方法...")
|
||||
try:
|
||||
from db_manager import get_db_manager
|
||||
|
||||
db = get_db_manager()
|
||||
db = get_db_manager()
|
||||
|
||||
# 检查多模态表是否存在
|
||||
conn = db.get_conn()
|
||||
tables = ["videos", "video_frames", "images", "multimodal_mentions", "multimodal_entity_links"]
|
||||
conn = db.get_conn()
|
||||
tables = ["videos", "video_frames", "images", "multimodal_mentions", "multimodal_entity_links"]
|
||||
|
||||
for table in tables:
|
||||
try:
|
||||
@@ -147,6 +147,6 @@ try:
|
||||
except Exception as e:
|
||||
print(f" ✗ 数据库多模态方法测试失败: {e}")
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("\n" + " = " * 60)
|
||||
print("测试完成")
|
||||
print("=" * 60)
|
||||
print(" = " * 60)
|
||||
|
||||
Reference in New Issue
Block a user