Skip to main content

中文 | English

说明

这是一些NLP/数据工作人员常用的函数组成的包,可以简化一些读写操作,使代码更加可读。主要包括两个部分:基本的读写工具和机器学习/深度学习工作中常用的数据处理函数。

它解决了什么问题:

  • 很多函数是记不住的, 每次写都要搜问大模型 ,例如pandas排序
  • 刷题的时候,树结构的题目很难调试
nlpertools
 ├── mkdocs.yml # used in doc
 ├── .readthedocs.yml # used in doc
 ├── pyproject.toml # used in pypi
 └── setup.cfg # used in pypi

最常用/喜欢的功能(使用示例)

# 读txt, json文件
import nlpertools

txt_data = nlpertools.readtxt_list_all_strip('res.txt')
json_data = nlpertools.load_json('res.json')
## git, 连接github不稳定的时候非常有用
ncli git pull
## 带有参数时,加上--以避免-u被解析
ncli -- git push -u origin main

# 生成pypi双因素认证的实时密钥(需要提供key)
ncli --get_2fa --get_2fa_key your_key

安装

Install the latest release version

pip install nlpertools

📢[ 推荐 ] 安装git最新版本

pip install git+https://github.com/lvzii/nlpertools

文档

https://nlpertools.readthedocs.io/en/latest/

开发指南

  • import都放在了utils/package.py里,通过脚本可自动生成

  • 类似paddle、ltp的import需要判断是否使用才import,因为import的时间太长,例如:

    class STEM(object):
        from ltp import LTP
    
        def __init__(self, IPT_MODEL_PATH):
            self.ltp = LTP(IPT_MODEL_PATH)
    

    通过pyinstrument判断,超过1s的包即采用这种方式

    • 2s+ happybase、seaborn、torch、jieba、nltk
    • 1s+ /
    • 0.5s+ pandas elasticsearch transformers xgboost nltk mongo
  • git commit guide

  • readthedoc 检查文档构建状况

  • 打包发布指南

  • 发布版本需要加tag git push origin <tag_name>

开发哲学

针对读取文件的方法,是将一些参数直接写在函数里,以实现快速使用。

原则是:写过一遍的函数,绝不写第二遍!

一些可能需要配置才能用的函数,写上示例

贡献

https://github.com/bigscience-workshop/data-preparation

Metadata

Release files for nlpertools 1.0.19

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

Source distribution (sdist)

Source distribution for nlpertools 1.0.19
File Size Uploaded
nlpertools-1.0.19.tar.gz 70.9 kB Details

Built distribution (wheel)

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

Total release size: 153.2 kB

Release files / nlpertools-1.0.19.tar.gz

Download URL nlpertools-1.0.19.tar.gz
Size 70.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1f80686561a5a098a51bf8f6790b999566e96bc14b90bc9a217263839c3fc242
BLAKE2b-256 checksum
How to use checksums
dae47cbc5ac5a5c33563b67789b2d9f9c8d968f8ab6e106d2403ff2593846783
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / nlpertools-1.0.19-py3-none-any.whl

Download URL nlpertools-1.0.19-py3-none-any.whl
Size 82.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7c97d91e0b9b2d733c05395578439f4c082b064c5b47cfc24ab4a028ba71bb4
BLAKE2b-256 checksum
How to use checksums
f5bc29c5826abc90fc048b9f8a35435ca3c389685f10fca288c89fbacafb2db8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release history Release notifications | RSS feed

This release

1.0.19 This release

2 release files

1.0.18

2 release files

1.0.14

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

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