Skip to main content

换种说法

同一句话有不同的表达方式,有时候需要翻译翻译。

已支持功能列表

功能 参数
拼音转换 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

  1. 提高同、反义词的准确性和词量。
  2. 提供更简明便捷通用的 API 接口。
  3. 降低打包后的文件体积。
  4. ...

致谢

Metadata

Release files for siaw 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for siaw 0.0.2
File Size Uploaded Provenance Actions
siaw-0.0.2.tar.gz 13.6 MB Without provenance Details for siaw-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for siaw 0.0.2
File Interpreter ABI Platform Actions
siaw-0.0.2-py3-none-any.whl Python 3 none any Details for siaw-0.0.2-py3-none-any.whl

Total release size: 27.3 MB

Release files / siaw-0.0.2.tar.gz

Download URL siaw-0.0.2.tar.gz
Size 13.6 MB
Tags Source
SHA-256 checksum
How to use checksums
4ccbedb8087df339340ddaab3a7412154c9277f195fc8492154d9dff648a694c
BLAKE2b-256 checksum
How to use checksums
76656b2ee24b183893e1604d7b776a957e2bb8766cb75bc5e6406b6ea1ed7257
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / siaw-0.0.2-py3-none-any.whl

Download URL siaw-0.0.2-py3-none-any.whl
Size 13.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
15ee0f95ba1137afca761fdd3868693d93ce336ee35e1ff78ce7d1198b9bbb3e
BLAKE2b-256 checksum
How to use checksums
cac7e823b990044f62a717444823e296ab685bad3b44e97309be6b3ff5a28265
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for siaw 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page