Skip to main content

A package for processing complex text with mixed Chinese and English characters

Project description

Complex Text Tools

PyPI version PyPI - Python Version PyPI - License

一个用于处理包含中英文混合字符的复杂文本的Python包,能够移除多余空格并根据特定规则计算文本长度。

功能特性

  • 移除中文字符之间的多余空格
  • 移除中英文字符之间的多余空格
  • 正确处理标点符号周围的间距
  • 根据特定规则计算文本长度(中文字符、英文单词、数字、等式等)
  • 修复中文文本中的标点符号(将英文标点转换为中文标点)
  • 高效处理混合语言文本

安装

pip install complex-text-tools

使用方法

移除多余空格

from complex_text_tools import remove_extra_spaces

text = "这 是  中文 测试  文本 ,  mixed  English  text  here , 还 有   symbols :  ;  !  "
clean_text = remove_extra_spaces(text)
print(clean_text)
# 输出: "这是中文测试文本,mixed English text here,还有 symbols:;!"

计算有效文本长度

from complex_text_tools import count_eff_len

text = "这是一段包含 English words 和 123.45 数字的 mixed 文本"
result = count_eff_len(text)
print(result)
# 输出:15

修复标点符号

from complex_text_tools import fix_punctuation

text = "这是中文文本,但使用了英文标点.这看起来不太自然,对吗?"
fixed_text = fix_punctuation(text)
print(fixed_text)
# 输出: "这是中文文本,但使用了中文标点。这看起来不太自然,对吗?"

许可证

该项目基于 MIT 许可证 - 详情请见 LICENSE 文件。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

complex_text_tools-0.2.3.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

complex_text_tools-0.2.3-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file complex_text_tools-0.2.3.tar.gz.

File metadata

  • Download URL: complex_text_tools-0.2.3.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for complex_text_tools-0.2.3.tar.gz
Algorithm Hash digest
SHA256 449c5fb9783774bd4857339844f2b83d927b01a1d9f617cc246c45fee66c2599
MD5 00ba51f3d2e67deb5e003a91f2f96a52
BLAKE2b-256 a388fecc4b79196470a4867dda58bafeb067734983e5af74d28c4f30828b2a28

See more details on using hashes here.

File details

Details for the file complex_text_tools-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for complex_text_tools-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7faa506d67cc1b7e7bded236d02b9b425a9f31c95bfc8714c14e731aef0501d1
MD5 4d8ce8cfc381f3b48e1219d0c0fde30f
BLAKE2b-256 8264fdc7c01932d2013b0563f47dc6ed8b269faf6ee86bc4f2aa4cf48d7552b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page