Skip to main content

A small example package from Hufengguo, CUC

Project description

扩展库介绍

这是中国传媒大学胡凤国老师上课分享的自定义函数库,其中包含几个常用的文本处理函数。发布本扩展库主要是方便上课学生练习Python程序,顺便分享给其他需要的Pythoner。

刚学会发布扩展库,PyPI很多东西还不熟,如有问题,请多提宝贵意见。

安装说明

pip install hufengguo

用法说明

具体用法见胡凤国老师的上课教材:《Python程序设计(基于计算思维和新文科建设)》,ISBN:9787121435577,胡凤国,电子工业出版社,2022年6月。

这里举一些简单的例子。

产生1到100之内的素数

from hufengguo import isprime
x = [i for i in range(101) if isprime(i)]
print(x)

去掉多行文本中的空白行和每行首尾空白符

s = " 12345\t\n  上山打老虎\n \n\n"
t = remove_white_from_text(s)
print("字符串s:", "-"*20, s, "-"*20, "\n字符串t:", "-"*20, t, "-"*20, sep="\n")

调用jieba扩展库对一个文本文件进行分词和词性标注,自动适应各种编码的文本文件

from hufengguo import segtag_by_jieba
segtag_by_jieba(r"in.txt", r"out.txt")

如果是分词且词性标注,可以导入 lseg_str_by_jieba 函数。

调用jieba扩展库对一个目录及子目录下的文本文件进行分词和词性标注

from hufengguo import my_path2path, segtag_by_jieba
my_path2path(r"in", [".txt"], r"out", segtag_by_jieba)

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

hufengguo-1.2.4.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

hufengguo-1.2.4-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file hufengguo-1.2.4.tar.gz.

File metadata

  • Download URL: hufengguo-1.2.4.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.8

File hashes

Hashes for hufengguo-1.2.4.tar.gz
Algorithm Hash digest
SHA256 1bb27fe04edd6ba60bffc5ff0b8cc94b1d5220427ef91390e80f3541d0f24d18
MD5 9d06cbf42a201f8effc1efbd4a590ec5
BLAKE2b-256 ac2b5b49054c18295535b7e081be745168edaac378077679d8b25a358fad9b97

See more details on using hashes here.

File details

Details for the file hufengguo-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: hufengguo-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.8

File hashes

Hashes for hufengguo-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bb37bc68fc934520d05e4deb67fb65c2e8719555b489deb5d4ca38d9a18448ba
MD5 6b27e49831ff669238b18170234ae87f
BLAKE2b-256 1fd606d5ae3203db1e5ec041b19fae07ccff35ad752aaa1ef5330ad228903eea

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