sync: 鍚屾灞€鍩熺綉鏈€鏂颁唬鐮?(source master @ b69568e4)
This commit is contained in:
1 parent
4f7f07504a
commit
8bc8b0e082
1651 files changed
+278599
-11416
No files matched your search
@@ -0,0 +1,33 @@
|
||||
from deerflow.integrations.weknora.local_index.ranking import (
|
||||
title_boosted_rrf_score,
|
||||
title_match_strength,
|
||||
)
|
||||
|
||||
|
||||
def test_exact_chinese_title_is_strongest_match() -> None:
|
||||
exact = title_match_strength("海湖庄园", "海湖庄园")
|
||||
broad = title_match_strength("海湖庄园", "特朗普")
|
||||
assert exact == 1.0
|
||||
assert broad == 0.0
|
||||
|
||||
|
||||
def test_question_wrappers_do_not_hide_title_phrase() -> None:
|
||||
assert title_match_strength("请介绍一下海湖庄园的历史", "海湖庄园") == 1.0
|
||||
|
||||
|
||||
def test_title_inside_longer_natural_language_question_is_retained() -> None:
|
||||
assert title_match_strength("请查找海湖庄园最新消息", "海湖庄园") > 0.7
|
||||
|
||||
|
||||
def test_possessive_character_inside_real_title_is_not_deleted() -> None:
|
||||
assert title_match_strength("党的二十大", "党的二十大") == 1.0
|
||||
|
||||
|
||||
def test_alias_match_is_discounted_but_still_useful() -> None:
|
||||
assert 0 < title_match_strength("Mar-a-Lago", "美国总统官邸", ["Mar-a-Lago"]) < 1
|
||||
|
||||
|
||||
def test_rrf_title_boost_is_weighted_and_can_be_disabled() -> None:
|
||||
base = 1 / 62
|
||||
assert title_boosted_rrf_score(base, 1.0, weight=0.25) == base * 1.25
|
||||
assert title_boosted_rrf_score(base, 1.0, enabled=False, weight=1.0) == base
|
||||
Reference in new issue
Block a user