讗专讙讜谉 诪讞讚砖 砖诇 讛住驻专讬讛: 诪讞讬拽转 CreationDate, 讗专讙讜谉 诇驻讬 0_preprocessing, 1_frontend, 2_backend_llm
9a7cb3e
| import pandas as pd | |
| from app.analysis import detect_query_type, count_keyword_rows, THANKS_KEYWORDS, COMPLAINT_KEYWORDS | |
| def test_detect_query_type_thanks(): | |
| t = "讻诪讛 诪砖转诪砖讬诐 讻转讘讜 转讜讚讛 注诇 讛砖讬专讜转" | |
| qtype, target = detect_query_type(t) | |
| assert qtype == "count_thanks" | |
| def test_detect_query_type_complaint(): | |
| t = "讻诪讛 讗谞砖讬诐 诪讚讜讜讞讬诐 注诇 转拽诇讛 讘诪注专讻转" | |
| qtype, target = detect_query_type(t) | |
| assert qtype == "count_complaint" | |
| def test_count_keyword_rows_counts_thanks(): | |
| df = pd.DataFrame({"Text": ["转讜讚讛 注诇 讛砖讬专讜转", "诇讗 讟讜讘", "转讜讚讛 专讘讛!", "砖讚专讜讙 谞讞诪讚"]}) | |
| cnt = count_keyword_rows(df, THANKS_KEYWORDS, text_column="Text") | |
| assert cnt == 2 | |
| def test_count_keyword_rows_counts_complaints(): | |
| df = pd.DataFrame({"Text": ["讗讬谉 砖讙讬讗讛", "转讬拽讜谉 谞讚专砖", "讬砖 转拽诇讛", "谞讻砖诇 讘注讘讜讚讛"]}) | |
| # Notice: keywords are Hebrew complaint variants; expect matches >=1 | |
| cnt = count_keyword_rows(df, COMPLAINT_KEYWORDS, text_column="Text") | |
| assert cnt >= 1 | |