-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_test.py
More file actions
47 lines (38 loc) · 1.6 KB
/
debug_test.py
File metadata and controls
47 lines (38 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
import sys
sys.path.insert(0, 'src')
from chinese_graphrag.embeddings.chinese_optimized import ChineseOptimizedEmbeddingService, ChineseEmbeddingConfig
from unittest.mock import patch, AsyncMock
import numpy as np
def debug_test():
"""調試測試"""
try:
# 創建配置
config = ChineseEmbeddingConfig(
primary_model="test-model",
fallback_models=["fallback-model"],
enable_preprocessing=True,
apply_chinese_weighting=True
)
print(f"Config created: {config}")
print(f"enable_preprocessing: {config.enable_preprocessing}")
# 創建服務
with patch('chinese_graphrag.embeddings.chinese_optimized.SENTENCE_TRANSFORMERS_AVAILABLE', True):
service = ChineseOptimizedEmbeddingService(config=config, device="cpu")
print(f"Service created: {service}")
print(f"text_processor: {service.text_processor}")
print(f"text_processor type: {type(service.text_processor)}")
if service.text_processor:
# 測試 evaluate_text_quality 方法
test_text = "這是一個測試文本"
quality = service.text_processor.evaluate_text_quality(test_text)
print(f"Quality result: {quality}")
print(f"Overall score: {quality.get('overall_score', 'NOT FOUND')}")
else:
print("text_processor is None!")
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
debug_test()