Skip to content

Commit 159a358

Browse files
committed
update test.
1 parent 6fdbdf7 commit 159a358

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

.github/workflows/ubuntu.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
run: |
4848
pip install -r requirements.txt
4949
pip install .
50+
pip install pytest
5051
- name: PKG-TEST
5152
run: |
52-
python -m unittest discover tests/
53+
python -m pytest

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ version = {1.0.1}
439439
项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
440440

441441
-`tests`添加相应的单元测试
442-
- 使用`python setup.py test`来运行所有单元测试,确保所有单测都是通过的
442+
- 使用`python -m pytest`来运行所有单元测试,确保所有单测都是通过的
443443

444444
之后即可提交PR。
445445

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
text2vec>=1.1.5
22
jieba>=0.39
33
loguru
4-
transformers>=4.6.0
4+
transformers
55
Pillow
66
hnswlib
77
annoy

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
keywords='similarities,Chinese Text Similarity Calculation Tool,similarity,word2vec',
4343
install_requires=[
4444
"text2vec>=1.1.5",
45-
"transformers>=4.6.0",
45+
"transformers",
4646
"jieba>=0.39",
4747
"loguru",
4848
"Pillow",

tests/test_sim_score.py

+16
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ def test_empty(self):
3636
self.assertEqual(len(r), 2)
3737
self.assertEqual(len(r[0]), 0)
3838

39+
def test_case(self):
40+
cases = [("牙疼有蛀牙怎么办", "手机前十名排行榜"),
41+
("小游戏,下载", "干洗机什么牌子的好"),
42+
("如何恢复微信里面的聊天记录", "吸氢气机"),
43+
("胃病症状的早期表现", "胃溃疡症状"), ]
44+
for i in cases:
45+
print(i)
46+
r = m.similarity(i[0], i[1])
47+
print(r)
48+
print("-" * 50)
49+
new_m = Similarity(model_name_or_path="sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")
50+
for i in cases:
51+
print(i)
52+
r = new_m.similarity(i[0], i[1])
53+
print(r)
54+
3955

4056
if __name__ == '__main__':
4157
unittest.main()

0 commit comments

Comments
 (0)