Coder Social home page Coder Social logo

Version Python3 star this repo fork this repo


Author Email
Victor [email protected]
Yinjun [email protected]
海蜇 [email protected]

Install 安装

通过pip安装

pip install smoothnlp>=0.4.0

通过源代码安装最新版本

git clone https://github.com/smoothnlp/SmoothNLP.git
cd SmoothNLP
python setup.py install

知识图谱

仅支持SmoothNLP V0.3.0以后的版本; 以下展示为V0.4版本后样例:

调用示例&可视化

from smoothnlp.algorithm import kg
from kgexplore import visual
ngrams = kg.extract_ngram(["SmoothNLP在V0.3版本中正式推出知识抽取功能",
                            "SmoothNLP专注于可解释的NLP技术",
                            "SmoothNLP支持Python与Java",
                            "SmoothNLP将帮助工业界与学术界更加高效的构建知识图谱",
                            "SmoothNLP是上海文磨网络科技公司的开源项目",
                            "SmoothNLP在V0.4版本中推出对图谱节点的分类功能",
                            "KGExplore是SmoothNLP的一个子项目"])
visual.visualize(ngrams,width=12,height=10)

SmoothNLP_KG_Demo

功能说明

  • V0.4版本中支持的边关系(edge-type), 包括: 事件触发, 状态描述, 属性描述, 数值描述.
  • V0.4版本中支持的节点种类(node-type), 包括: 产品地区公司与品牌货品机构人物修饰短语其他.

NLP基础Pipelines

1.Tokenize分词

>> import smoothnlp 
>> smoothnlp.segment('欢迎在Python中使用SmoothNLP')
['欢迎', '在', 'Python', '中', '使用', 'SmoothNLP']

2.Postag词性标注

词性标注标签解释wiki

>> smoothnlp.postag('欢迎使用smoothnlp的Python接口')
[{'token': '欢迎', 'postag': 'VV'},
 {'token': '在', 'postag': 'P'},
 {'token': 'Python', 'postag': 'NN'},
 {'token': '中', 'postag': 'LC'},
 {'token': '使用', 'postag': 'VV'},
 {'token': 'SmoothNLP', 'postag': 'NN'}]

3.NER 实体识别

>> smoothnlp.ner("**平安2019年度长期服务计划于2019年5月7日至5月14日通过二级市场完成购股" )
[{'charStart': 0, 'charEnd': 4, 'text': '**平安', 'nerTag': 'COMPANY_NAME', 'sTokenList': {'1': {'token': '**平安', 'postag': None}}, 'normalizedEntityValue': '**平安'},
{'charStart': 4, 'charEnd': 9, 'text': '2019年', 'nerTag': 'NUMBER', 'sTokenList': {'2': {'token': '2019年', 'postag': 'CD'}}, 'normalizedEntityValue': '2019年'},
{'charStart': 17, 'charEnd': 26, 'text': '2019年5月7日', 'nerTag': 'DATETIME', 'sTokenList': {'8': {'token': '2019年5月', 'postag': None}, '9': {'token': '7日', 'postag': None}}, 'normalizedEntityValue': '2019年5月7日'},
{'charStart': 27, 'charEnd': 32, 'text': '5月14日', 'nerTag': 'DATETIME', 'sTokenList': {'11': {'token': '5月', 'postag': None}, '12': {'token': '14日', 'postag': None}}, 'normalizedEntityValue': '5月14日'}]

4. 金融实体识别

>> smoothnlp.company_recognize("旷视科技预计将在今年9月在港IPO")
[{'charStart': 0,
  'charEnd': 4,
  'text': '旷视科技',
  'nerTag': 'COMPANY_NAME',
  'sTokenList': {'1': {'token': '旷视科技', 'postag': None}},
  'normalizedEntityValue': '旷视科技'}]

5. 依存句法分析

注意, smoothnlp.dep_parsing返回的Index=0 为 dummy的roottoken.

依存句法分析标签解释wiki

smoothnlp.dep_parsing("特斯拉是全球最大的电动汽车制造商。")
> [{'relationship': 'top', 'dependentIndex': 2, 'targetIndex': 1},
  {'relationship': 'root', 'dependentIndex': 0, 'targetIndex': 2},
  {'relationship': 'dep', 'dependentIndex': 5, 'targetIndex': 3},
  {'relationship': 'advmod', 'dependentIndex': 5, 'targetIndex': 4},
  {'relationship': 'ccomp', 'dependentIndex': 2, 'targetIndex': 5},
  {'relationship': 'cpm', 'dependentIndex': 5, 'targetIndex': 6},
  {'relationship': 'amod', 'dependentIndex': 8, 'targetIndex': 7},
  {'relationship': 'attr', 'dependentIndex': 2, 'targetIndex': 8},
  {'relationship': 'attr', 'dependentIndex': 2, 'targetIndex': 9},
  {'relationship': 'punct', 'dependentIndex': 2, 'targetIndex': 10}]

6. 切句

smoothnlp.split2sentences("句子1!句子2!")
> ['句子1!', '句子2!']

7. 多线程支持

SmoothNLP 默认使用2个Thread进行服务调用;

from smoothnlp import config
config.setNumThreads(2)

8. 日志

from smoothnlp import config
config.setLogLevel("DEBUG")  ## 设定日志级别

无监督学习

新词挖掘

算法介绍 | 使用说明

事件聚类

该功能我们目前仅支持商业化的解决方案支持, 与线上服务. 详情可联系 [email protected]

效果演示

[
  {
    "url": "https://36kr.com/p/5167309",
    "title": "Facebook第三次数据泄露,可能导致680万用户私人照片泄露",
    "pub_ts": 1544832000
  },
  {
    "url": "https://www.pencilnews.cn/p/24038.html",
    "title": "热点 | Facebook将因为泄露700万用户个人照片 面临16亿美元罚款",
    "pub_ts": 1544832000
  },
  {
    "url": "https://finance.sina.com.cn/stock/usstock/c/2018-12-15/doc-ihmutuec9334184.shtml",
    "title": "Facebook再曝新数据泄露 6800万用户或受影响",
    "pub_ts": 1544844120
  }
]

吐槽: 新浪小编数据错误... 夸大事实, 真实情况Facebook并没有泄露6800万张照片

有监督学习

(资讯)事件分类

该功能我们目前仅支持商业化的解决方案支持, 与线上服务. 详情可联系 [email protected]; 线上服务支持API输出

效果

事件名称 AUC Precision
投资并购 0.996 0.982
企业合作 0.977 0.885
董监高管 0.982 0.940
营收报导 0.994 0.960
企业签约 0.993 0.904
商业拓展 0.968 0.869
产品报道 0.977 0.911
产业政策 0.990 0.879
经营不善 0.981 0.765
违规约谈 0.951 0.890

参考文献


Tutorial

服务说明

声明

  1. SmoothNLP通过云端微服务提供完整的REST文本解析及相关服务应用. 对于开源爱好者等一般用户, 目前我们提供qps<=5的服务支持; 对于商业用户, 我们提供部不受限制的云端账号或本地部署方案.
  2. 包括:切词,词性标注,依存句法分析等基础NLP任务由java代码实现, 在文件夹smoothnlp_maven下. 可通过 maven编译打包
  3. 如果您寻求商业化的NLP或知识图谱解决方案, 欢迎邮件至 [email protected]

Pro 专业版本

SmoothNLP Pro 支持稳定可靠的企业级用户, 使用文档; 如需试用或购买, 请联系 [email protected]

常见问题

  1. 注意, 在0.2.20版本调整后, 以下基础Pipeline功能仅对字符串长度做出了限制(不超过200). 如对较长corpus进行处理, 请先试用smoothnlp.split2sentences 进行切句预处理
  2. 知识图谱可视化部分(V0.4版本以前)默认支持字体SimHei,大多数环境下的matplotlib不支持中文字体, 我们提供字体包的下载链接; 您可以通过运行以下代码, 将Simhei字体加载入matplotlib字体库
import matplotlib.pyplot as plt
import matplotlib.font_manager as font_manager
## 设置字体
font_dirs = ['simhei/']
font_files = font_manager.findSystemFonts(fontpaths=font_dirs)
font_list = font_manager.createFontList(font_files)
font_manager.fontManager.ttflist.extend(font_list)
plt.rcParams['font.family'] = "SimHei"

彩蛋

  1. 如果你对本项目, 有任何建议或者想成为联合开发者, 欢迎提交issue或pull request; 作为回赠, 我们会提供数据分享或 kgexplore 的免费数据体验
  2. 如果你对NLP相关算法或引用场景感兴趣, 但是却缺少实现数据, 我们提供免费的数据支持, 下载.
  3. 如果你是高校学生, 寻求NLP知识图谱相关的研究素材, 甚至是实习机会. 欢迎邮件到 [email protected]

SmoothNLP's Projects

chinese-xinhua icon chinese-xinhua

:orange_book: 中华新华字典数据库。包括歇后语,成语,词语,汉字。

circle icon circle

让网页赏心悦目、让阅读回归初心。Circle 阅读模式提供更隐私、更轻松、更舒适的网页阅读体验

codebox icon codebox

Code highlighting tool for Editor.js

district icon district

**省/自治区/直辖市、市/自治州、区/县/旗数据,包含名称、拼音、拼音首字母、行政代码、区号

domainwords icon domainwords

SmoothNLP领域词汇示例 - 基于复旦公开新闻资讯库

editor.js icon editor.js

A block-styled editor with clean JSON output

fa2l icon fa2l

Force Atlas 2 graph layout

financialdatasets icon financialdatasets

SmoothNLP 金融文本数据集(公开) Public Financial Datasets for NLP Researches Only

flashtext icon flashtext

Extract Keywords from sentence or Replace keywords in sentences.

forceatlas2 icon forceatlas2

Fastest Gephi's ForceAtlas2 graph layout algorithm implemented for Python and NetworkX

funnlp icon funnlp

中英文敏感词、语言检测、中外手机/电话归属地/运营商查询、名字推断性别、手机号抽取、身份证抽取、邮箱抽取、中日文人名库、中文缩写库、拆字词典、词汇情感值、停用词、反动词表、暴恐词表、繁简体转换、英文模拟中文发音、汪峰歌词生成器、职业名称词库、同义词库、反义词库、否定词库、汽车品牌词库、汽车零件词库、连续英文切割、各种中文词向量、公司名字大全、古诗词库、IT词库、财经词库、成语词库、地名词库、历史名人词库、诗词词库、医学词库、饮食词库、法律词库、汽车词库、动物词库、中文聊天语料、中文谣言数据、百度中文问答数据集、句子相似度匹配算法集合、bert资源、文本生成&摘要相关工具、cocoNLP信息抽取工具、国内电话号码正则匹配、清华大学XLORE:中英文跨语言百科知识图谱、清华大学人工智能技术系列报告、自然语言生成、NLU太难了系列、自动对联数据及机器人、用户名黑名单列表、罪名法务名词及分类模型、微信公众号语料、cs224n深度学习自然语言处理课程、中文手写汉字识别、中文自然语言处理 语料/数据集、变量命名神器、分词语料库+代码、任务型对话英文数据集、ASR 语音数据集 + 基于深度学习的中文语音识别系统、笑声检测器、Microsoft多语言数字/单位/如日期时间识别包、中华新华字典数据库及api(包括常用歇后语、成语、词语和汉字)、文档图谱自动生成、SpaCy 中文模型、Common Voice语音识别数据集新版、神经网络关系抽取、基于bert的命名实体识别、关键词(Keyphrase)抽取包pke、基于医疗领域知识图谱的问答系统、基于依存句法与语义角色标注的事件三元组抽取、依存句法分析4万句高质量标注数据、cnocr:用来做中文OCR的Python3包、中文人物关系知识图谱项目、中文nlp竞赛项目及代码汇总、中文字符数据、speech-aligner: 从“人声语音”及其“语言文本”产生音素级别时间对齐标注的工具、AmpliGraph: 知识图谱表示学习(Python)库:知识图谱概念链接预测、Scattertext 文本可视化(python)、语言/知识表示工具:BERT & ERNIE、中文对比英文自然语言处理NLP的区别综述、Synonyms中文近义词工具包、HarvestText领域自适应文本挖掘工具(新词发现-情感分析-实体链接等)、word2word:(Python)方便易用的多语言词-词对集:62种语言/3,564个多语言对、语音识别语料生成工具:从具有音频/字幕的在线视频创建自动语音识别(ASR)语料库、构建医疗实体识别的模型(包含词典和语料标注)、单文档非监督的关键词抽取、Kashgari中使用gpt-2语言模型、开源的金融投资数据提取工具、文本自动摘要库TextTeaser: 仅支持英文、人民日报语料处理工具集、一些关于自然语言的基本模型、基于14W歌曲知识库的问答尝试--功能包括歌词接龙and已知歌词找歌曲以及歌曲歌手歌词三角关系的问答、基于Siamese bilstm模型的相似句子判定模型并提供训练数据集和测试数据集、用Transformer编解码模型实现的根据Hacker News文章标题自动生成评论、用BERT进行序列标记和文本分类的模板代码、LitBank:NLP数据集——支持自然语言处理和计算人文学科任务的100部带标记英文小说语料、百度开源的基准信息抽取系统、虚假新闻数据集、Facebook: LAMA语言模型分析,提供Transformer-XL/BERT/ELMo/GPT预训练语言模型的统一访问接口、CommonsenseQA:面向常识的英文QA挑战。

glove icon glove

GloVe model for distributed word representation

link icon link

Link Tool for Editor.js 2.0

python-readability icon python-readability

fast python port of arc90's readability tool, updated to match latest readability.js!

seq2ftr icon seq2ftr

一款性能极高的序列数据特征工程框架 - A high-performance sequence feature engineering framework

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.