update test.
This commit is contained in:
parent
6fdbdf775b
commit
159a3580e1
3
.github/workflows/ubuntu.yml
vendored
3
.github/workflows/ubuntu.yml
vendored
@ -47,6 +47,7 @@ jobs:
|
||||
run: |
|
||||
pip install -r requirements.txt
|
||||
pip install .
|
||||
pip install pytest
|
||||
- name: PKG-TEST
|
||||
run: |
|
||||
python -m unittest discover tests/
|
||||
python -m pytest
|
@ -439,7 +439,7 @@ version = {1.0.1}
|
||||
项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
|
||||
|
||||
- 在`tests`添加相应的单元测试
|
||||
- 使用`python setup.py test`来运行所有单元测试,确保所有单测都是通过的
|
||||
- 使用`python -m pytest`来运行所有单元测试,确保所有单测都是通过的
|
||||
|
||||
之后即可提交PR。
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
text2vec>=1.1.5
|
||||
jieba>=0.39
|
||||
loguru
|
||||
transformers>=4.6.0
|
||||
transformers
|
||||
Pillow
|
||||
hnswlib
|
||||
annoy
|
||||
|
2
setup.py
2
setup.py
@ -42,7 +42,7 @@ setup(
|
||||
keywords='similarities,Chinese Text Similarity Calculation Tool,similarity,word2vec',
|
||||
install_requires=[
|
||||
"text2vec>=1.1.5",
|
||||
"transformers>=4.6.0",
|
||||
"transformers",
|
||||
"jieba>=0.39",
|
||||
"loguru",
|
||||
"Pillow",
|
||||
|
@ -36,6 +36,22 @@ class SimScoreTestCase(unittest.TestCase):
|
||||
self.assertEqual(len(r), 2)
|
||||
self.assertEqual(len(r[0]), 0)
|
||||
|
||||
def test_case(self):
|
||||
cases = [("牙疼有蛀牙怎么办", "手机前十名排行榜"),
|
||||
("小游戏,下载", "干洗机什么牌子的好"),
|
||||
("如何恢复微信里面的聊天记录", "吸氢气机"),
|
||||
("胃病症状的早期表现", "胃溃疡症状"), ]
|
||||
for i in cases:
|
||||
print(i)
|
||||
r = m.similarity(i[0], i[1])
|
||||
print(r)
|
||||
print("-" * 50)
|
||||
new_m = Similarity(model_name_or_path="sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")
|
||||
for i in cases:
|
||||
print(i)
|
||||
r = new_m.similarity(i[0], i[1])
|
||||
print(r)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user