前言
总结一下自己使用的文本处理python库。
一、jieba
“结巴”中文分词:做最好的 Python 中文分词组件
参考网站:
https://github.com/fxsjy/jieba
https://www.jb51.net/article/243626.htm
主要功能
- 分词
支持四种分词模式
支持繁体分词
支持自定义词典 - 关键词提取
基于 TF-IDF 算法的关键词抽取
基于TextRank 算法的关键词抽取 - 词性标注
- 并行分词
- Tokenize:返回词语在原文的起止位置
- ChineseAnalyzer for Whoosh 搜索引擎
- 命令行分词
总结
在对中文文本进行处理时使用。个人经常使用的功能:自定义词典进行分词、词性标注。
二、MeCab
MeCab: Yet Another Part-of-Speech and Morphological Analyzer
参考网站:
日文介绍网页:https://taku910.github.io/mecab/
日翻中网页:日文分词器 Mecab 文档
主要功能
- 分词
- 词法解析
- ……
总结
在对日语文本进行处理时使用。个人使用较少。
三、Polyglot
Polyglot is a natural language pipeline that supports massive multilingual applications.
参考网站:
https://polyglot.readthedocs.io/en/latest/
主要功能
- 分词分句——Tokenization (165 Languages)
- 语种检测——Language detection (196 Languages)
- 命名实体识别——Named Entity Recognition (40 Languages)
- 词性标注——Part of Speech Tagging (16 Languages)
- 情感分析——Sentiment Analysis (136 Languages)
- 词嵌入——Word Embeddings (137 Languages)
- 形态分析——Morphological analysis (135 Languages)
- 翻译——Transliteration (69 Languages)
总结
支持语言种类比较多。个人经常使用的功能:语种检测、分词、分句。
三、NLTK
NLTK has been called “a wonderful tool for teaching, and working in, computational linguistics using Python,” and “an amazing library to play with natural language.”
参考网站:
官方文档:https://www.nltk.org/index.html
主要功能
分词分句、去除停用词、词性标注、词干提取、命名实体识别、句法分析、文本分类、情感分析……
总结
NLTK库功能强大易于使用,它提供了大量的文本处理工具和算法,适用于从简单的文本处理任务到复杂的自然语言分析和理解任务。
总结
记录下没使用过但是未来可能会用到的工具:
SpaCy
https://spacy.io/usage/models
https://github.com/explosion/spaCy
StanfordNLP(Stanza)
https://github.com/stanfordnlp/stanfordnlp
https://github.com/stanfordnlp/stanza
TextBlob
https://textblob.readthedocs.io/en/dev/
https://pypi.org/project/textblob/
https://github.com/sloria/textblob