Skip to main content

AuroraNLP - 专业级中文自然语言处理工具包

Project description

AuroraNLP

专业级中文自然语言处理工具包

PyPI Python Versions CI Codecov License

简介

AuroraNLP 是一个专业级的中文自然语言处理工具包,提供从分词、词性标注、命名实体识别、句法分析到企业级支持的全栈功能。

特性

🚀 核心功能

  • 分词: 支持 HMM/CRF/感知机/词格/混合多种策略
  • 词性标注: 基于统计模型和深度学习的词性标注
  • 命名实体识别: 支持 PER/LOC/ORG 等实体类型,嵌套实体识别
  • 句法分析: 依存分析(ArcEager算法)和成分分析(CFG)
  • 关键词提取: TF-IDF/TextRank 算法
  • 文本相似度: 余弦/Jaccard/编辑距离
  • 新词发现: 互信息 + 左右熵

📚 丰富的词典资源

  • 百万级通用中文词典
  • 医疗/法律/电商/新闻等领域词库
  • 人名词库、地名词库、机构名词库
  • 搜狗细胞词库集成
  • 开放词林(同义词/近义词)

🔬 深度学习支持

  • BiLSTM-CRF 模型
  • BERT 预训练模型集成
  • 轻量级模型(ALBERT/DistilBERT)
  • 模型微调、迁移学习、知识蒸馏
  • 模型量化、ONNX 导出、热加载

🏗️ 企业级架构

  • 类 spaCy 的 Pipeline 系统
  • Doc/Span/Token 统一数据结构
  • REST API / gRPC 接口
  • 异步处理和流式处理
  • 插件系统支持

⚡ 性能优化

  • 对象池/内存池
  • 批量处理
  • 混合精度推理
  • 内存映射文件
  • 词典压缩
  • 缓存机制

🏢 企业级功能

  • 结构化日志系统
  • 健康检查
  • Prometheus 指标
  • Docker & Kubernetes 支持
  • 限流熔断
  • 认证授权
  • 配置管理
  • 灰度发布
  • 灾备方案

📦 轻量设计

  • 纯 Python 实现,无强制外部依赖
  • 零配置开箱即用
  • Python 3.8+ 支持

安装

基本安装

pip install aurora-nlp

完整安装(包含深度学习支持)

pip install aurora-nlp[full]

开发安装

git clone https://github.com/AuroraNLP/AuroraNLP.git
cd AuroraNLP
pip install -e .[dev]

快速开始

基础分词

from AuroraNLP import Segmentor

# 初始化分词器
seg = Segmentor(use_hybrid=True)

# 分词
text = "人工智能正在改变世界"
words = seg.segment(text)
print(words)  # ['人工智能', '正在', '改变', '世界']

# 词性标注
words_with_pos = seg.segment_with_pos(text)
print(words_with_pos)
# [('人工智能', 'n'), ('正在', 'd'), ('改变', 'v'), ('世界', 'n')]

命名实体识别

from AuroraNLP import NERRecognizer

ner = NERRecognizer(use_bert=True)
text = "张三在阿里巴巴位于杭州的总部工作"
entities = ner.recognize(text)
print(entities)
# [
#   Entity(text='张三', type='PERSON', start=0, end=2),
#   Entity(text='阿里巴巴', type='ORGANIZATION', start=3, end=7),
#   Entity(text='杭州', type='LOCATION', start=9, end=11)
# ]

Pipeline 系统

from AuroraNLP import Pipeline, Segmentor, POSTagger, NERRecognizer

# 创建 Pipeline
nlp = Pipeline()
nlp.add_component(Segmentor())
nlp.add_component(POSTagger())
nlp.add_component(NERRecognizer())

# 处理文本
doc = nlp("中国北京是一座美丽的城市")

# 获取分词结果
print(doc.tokens)

# 获取词性标注
print([(token.text, token.pos) for token in doc.tokens])

# 获取命名实体
print(doc.ents)

使用领域词典

from AuroraNLP import Segmentor, DomainDictionaryManager

# 加载医疗领域词典
dict_manager = DomainDictionaryManager()
dict_manager.load_domain("medical")

seg = Segmentor(dictionary=dict_manager.combined_dictionary)
text = "患者出现发热咳嗽症状,医生建议做CT检查"
words = seg.segment(text)
print(words)

文档

示例

查看 examples/ 目录获取更多示例:

性能

功能 准确率 速度
分词 ~93% 50万字/秒
词性标注 ~92% 40万字/秒
NER ~88% 30万字/秒

贡献指南

欢迎贡献!请查看 CONTRIBUTING.md 了解详情。

许可证

本项目采用 Apache 2.0 许可证 - 详见 LICENSE 文件。

致谢

  • 参考项目:HanLP、spaCy、jieba、pkuseg、THULAC
  • 数据资源:人民日报语料库、搜狗细胞词库、开放词林

联系方式

路线图

查看 ROADMAP.md 了解我们的发展计划。

项目统计

项目进度

已完成 90/100 步(90%)

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

auroranlp_core-1.0.0.tar.gz (260.3 kB view details)

Uploaded Source

Built Distribution

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

auroranlp_core-1.0.0-py3-none-any.whl (282.5 kB view details)

Uploaded Python 3

File details

Details for the file auroranlp_core-1.0.0.tar.gz.

File metadata

  • Download URL: auroranlp_core-1.0.0.tar.gz
  • Upload date:
  • Size: 260.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for auroranlp_core-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ac657ae1d1483037997c793b18f43a54a2e6dcbab974490f6b770f5f4249719b
MD5 bff227d09c1ce5f29afb0598a7294008
BLAKE2b-256 71c9f92620698dededa5ebcdb73903812a6530492d179e261780ae67344aef12

See more details on using hashes here.

File details

Details for the file auroranlp_core-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: auroranlp_core-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 282.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for auroranlp_core-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 687ed2f3d8c00220394f1239c270ca4845134ec8508a920d8f77de98b8c4cc61
MD5 0dd4ea25bfa7d3456437807422f4105d
BLAKE2b-256 6760bb6d1ca48d0180f9ba5ebe53fc29b332dc7d71a7ac47b34fa31375db0015

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