Say the same sentence in another way.
Project description
换种说法
同一句话有不同的表达方式,有时候需要翻译翻译。
- GitHub: https://github.com/SnailZSJ/SayItAnotherWay
- License: MIT license
- PyPI: https://pypi.org/project/siaw/
- Python version: pypy3, 3.6, 3.7, 3.8
已支持功能列表
| 功能 | 参数 |
|---|---|
| 拼音转换 | pinyin |
| 顺序转换 | sequence |
| 逆序转换 | reverse |
| 过滤敏感词转换 | filter |
| 添加间隔符转换 | space_mark |
| 拆字转换 | chaizi |
| 反义词转换 | antonym |
| 同义词转换 | synonym |
| 同音转换 | homophone |
安装
pip3 install siaw
使用示例
1. 拼音转换
from siaw import SayItAnotherWay
sentence_pinyin = SayItAnotherWay("阿伟死了")
result = sentence_pinyin.translate('pinyin')
print(result)
输出
'ā wěi sǐ le'
2. 乱序转换
from siaw import SayItAnotherWay
sentence_sequence = SayItAnotherWay("汉字的顺序并不一定能影响阅读")
result = sentence_sequence.translate('sequence', use_jieba=False)
print(result)
输出
'汉的字序顺不并定一影能阅响读'
3. 逆序转换
from siaw import SayItAnotherWay
sentence_reverse = SayItAnotherWay("汉字的顺序并不一定能影响阅读")
result = sentence_reverse.translate('reverse', use_jieba=False)
print(result)
输出
'读阅响影能定一不并序顺的字汉'
4. 过滤敏感词转换
from siaw import SayItAnotherWay
sentence_filter = SayItAnotherWay("违禁词会被过滤,比如巨乳,懂了吗?")
result = sentence_filter.translate('filter')
print(result)
输出
'违禁词会被过滤,比如**,懂了吗?'
5. 添加间隔符转换
from siaw import SayItAnotherWay
sentence_space_mark = SayItAnotherWay("这里会加入一些间隔符号。")
result = sentence_space_mark.translate('space_mark', use_jieba=False, space_mark='+')
print(result)
输出
'这+里+会+加+入+一+些+间+隔+符+号+。'
6. 拆字转换
from siaw import SayItAnotherWay
sentence_chaizi = SayItAnotherWay("测试拆字结果。")
result = sentence_chaizi.translate('chaizi', use_jieba=False)
print(result)
输出
'水则 言式 手斥 宀子 丝吉 日木 。'
7. 反义转换
from siaw import SayItAnotherWay
sentence_antonym = SayItAnotherWay("Python从入门到放弃。")
result = sentence_antonym.translate('antonym')
print(result)
输出
'Python主入门到坚持。'
8. 同义转换
from siaw import SayItAnotherWay
sentence_synonym = SayItAnotherWay("Python从入门到放弃。")
result = sentence_synonym.translate('synonym')
print(result)
输出
'Python打入库及割舍。'
9. 同音转换
from siaw import SayItAnotherWay
sentence_homophone = SayItAnotherWay("苟利国家生死以,岂因福祸避趋之。")
result = sentence_homophone.translate('homophone')
print(result)
输出
'煹鷅濄扴狌蟖齮,埼音俘获比娶支。'
10. 测试混合模式转换
from siaw import SayItAnotherWay
sentence_mixed = SayItAnotherWay("测试多种模式混合结果。")
result = sentence_mixed.translate('mixed', use_jieba=False, space_mark=' ', ways=['chaizi', 'pinyin'])
print(result)
输出
'shuǐzéyánshìxīxīhézhōngmùmòyìgōngshuǐkūnrényīkǒusījírìmù。'
TODO
- 提高同、反义词的准确性和词量。
- 提供更简明便捷通用的 API 接口。
- 降低打包后的文件体积。
- ...
致谢
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
siaw-0.0.2.tar.gz
(13.6 MB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
siaw-0.0.2-py3-none-any.whl
(13.6 MB
view details)
File details
Details for the file siaw-0.0.2.tar.gz.
File metadata
- Download URL: siaw-0.0.2.tar.gz
- Upload date:
- Size: 13.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ccbedb8087df339340ddaab3a7412154c9277f195fc8492154d9dff648a694c
|
|
| MD5 |
65930779b78349de15c44d642997f700
|
|
| BLAKE2b-256 |
76656b2ee24b183893e1604d7b776a957e2bb8766cb75bc5e6406b6ea1ed7257
|
File details
Details for the file siaw-0.0.2-py3-none-any.whl.
File metadata
- Download URL: siaw-0.0.2-py3-none-any.whl
- Upload date:
- Size: 13.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15ee0f95ba1137afca761fdd3868693d93ce336ee35e1ff78ce7d1198b9bbb3e
|
|
| MD5 |
3eb8e7223fc87f478a3a38ad4088bf59
|
|
| BLAKE2b-256 |
cac7e823b990044f62a717444823e296ab685bad3b44e97309be6b3ff5a28265
|