同一句话有不同的表达方式,有时候需要翻译翻译。
- 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
from siaw import SayItAnotherWay
sentence_pinyin = SayItAnotherWay("阿伟死了")
result = sentence_pinyin.translate('pinyin')
print(result)
输出
'ā wěi sǐ le'
from siaw import SayItAnotherWay
sentence_sequence = SayItAnotherWay("汉字的顺序并不一定能影响阅读")
result = sentence_sequence.translate('sequence', use_jieba=False)
print(result)
输出
'汉的字序顺不并定一影能阅响读'
from siaw import SayItAnotherWay
sentence_reverse = SayItAnotherWay("汉字的顺序并不一定能影响阅读")
result = sentence_reverse.translate('reverse', use_jieba=False)
print(result)
输出
'读阅响影能定一不并序顺的字汉'
from siaw import SayItAnotherWay
sentence_filter = SayItAnotherWay("违禁词会被过滤,比如巨乳,懂了吗?")
result = sentence_filter.translate('filter')
print(result)
输出
'违禁词会被过滤,比如**,懂了吗?'
from siaw import SayItAnotherWay
sentence_space_mark = SayItAnotherWay("这里会加入一些间隔符号。")
result = sentence_space_mark.translate('space_mark', use_jieba=False, space_mark='+')
print(result)
输出
'这+里+会+加+入+一+些+间+隔+符+号+。'
from siaw import SayItAnotherWay
sentence_chaizi = SayItAnotherWay("测试拆字结果。")
result = sentence_chaizi.translate('chaizi', use_jieba=False)
print(result)
输出
'水则 言式 手斥 宀子 丝吉 日木 。'
from siaw import SayItAnotherWay
sentence_antonym = SayItAnotherWay("Python从入门到放弃。")
result = sentence_antonym.translate('antonym')
print(result)
输出
'Python主入门到坚持。'
from siaw import SayItAnotherWay
sentence_synonym = SayItAnotherWay("Python从入门到放弃。")
result = sentence_synonym.translate('synonym')
print(result)
输出
'Python打入库及割舍。'
from siaw import SayItAnotherWay
sentence_homophone = SayItAnotherWay("苟利国家生死以,岂因福祸避趋之。")
result = sentence_homophone.translate('homophone')
print(result)
输出
'煹鷅濄扴狌蟖齮,埼音俘获比娶支。'
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ù。'
- 提高同、反义词的准确性和词量。
- 提供更简明便捷通用的 API 接口。
- 降低打包后的文件体积。
- ...