VOC_Monitor/test/test_report_inference.py

43 lines
1.6 KiB
Python

import sys
from pathlib import Path
# 프로젝트 루트와 app 디렉토리를 path에 추가
current_dir = Path(__file__).parent
project_root = current_dir.parent
app_dir = project_root / "app"
sys.path.append(str(app_dir))
from services.report_service import ReportService
import json
def test_inference():
print("=== Report Service Inference Test ===")
service = ReportService()
print(f"Loaded stations count: {len(service.stations)}")
if service.stations:
print(f"Sample stations: {service.stations[:5]} ... {service.stations[-5:]}")
# 테스트 데이터: 열차번호는 없지만 역(노포)과 시간(06시 32분)이 있음
# 평일/주말에 따라 결과가 다를 수 있음 (현재 시각 기준 실행됨)
test_title = "노포역 에어컨 미작동"
test_content = "06시 32분쯤 노포역에서 다대포 방향으로 가는 열차를 탔는데 너무 더워요."
print(f"\n[Test Case] title: {test_title}")
print(f" content: {test_content}")
parsed = service._parse_voc_info(test_title, test_content)
print("\n[Parsed Results]")
print(f" Line: {parsed['line_str']}")
print(f" Train Number: {parsed['train_str']} (Inferred!)")
print(f" Direction: {parsed['train_details']['direction']}")
print(f" Type: {parsed['train_details']['type']}")
if parsed['train_str']:
print("\nSuccess: Train number inferred using timetable!")
else:
print("\nFailure: Train number not inferred. Check if current day diag matches timetable.")
if __name__ == "__main__":
test_inference()