阿鲁纳是一组方法,可用于简单的NLP任务和机器学习文本预处理。
Aruana的Python项目详细描述
用于机器学习的Aruana NLP
aruana是可用于简单nlp任务的方法集合。它可以用于涉及机器学习的文本预处理的任务。aruana主要处理文本字符串和字符串列表。
这个库是用python 3开发的。
安装Aruana
PIP
$ pip3 install aruana
如果需要,还可以在虚拟环境中安装aruana:
$ python -m venv .env
$ source .env/bin/activate
$ pip3 install aruana
先决条件
aruana使用以下外部python库:
NLTK(3.3)
TQM(4.19.5)
PDOC(0.5.1)
它们都记录在requirements.txt文件中。
用法示例
要使用aruana,请通过选择三种可用语言之一(“en”、“fr”、“pt br”)对其进行初始化。
aruana_en = Aruana('en')
快速预处理
aruana有预处理方法,它对文本应用常用的预处理步骤。
text = "At the end of the day, you're solely responsible for your success and your failure. And the sooner you realize that, you accept that, and integrate that into your work ethic, you will start being successful. As long as you blame others for the reason you aren't where you want to be, you will always be a failure."
preprocessed_text = aruana_en.preprocess(text)
print(preprocessed_text)
>>> ['at', 'the', 'end', 'of', 'the', 'day', 'you', 'are', 'sole', 'respons', 'for', 'your', 'success', 'and', 'your', 'failur', 'and', 'the', 'sooner', 'you', 'realiz', 'that', 'you', 'accept', 'that', 'and', 'integr', 'that', 'into', 'your', 'work', 'ethic', 'you', 'will', 'start', 'be', 'success', 'as', 'long', 'as', 'you', 'blame', 'other', 'for', 'the', 'reason', 'you', 'are', 'not', 'where', 'you', 'want', 'to', 'be', 'you', 'will', 'alway', 'be', 'a', 'failur']
如果您愿意,可以选择:
标记句子
阻止它
删除停止符
用pos标记葡萄牙语句子
text = "At the end of the day, you're solely responsible for your success and your failure. And the sooner you realize that, you accept that, and integrate that into your work ethic, you will start being successful. As long as you blame others for the reason you aren't where you want to be, you will always be a failure." preprocessed_text = aruana_en.preprocess(text, stem=False, remove_stopwords=True) print(preprocessed_text) ['end', 'day', 'solely', 'responsible', 'success', 'failure', 'sooner', 'realize', 'that', 'accept', 'that', 'integrate', 'work', 'ethic', 'start', 'successful', 'long', 'blame', 'others', 'reason', 'want', 'be', 'always', 'failure']
列表预处理
如果您有一个句子列表或正在使用panda,则可以使用preprocess_list方法传递整个列表进行预处理。
list_of_strings = ['I love you',
'Please, never leave me alone',
'If you go, I will die',
'I am watching a lot of romantic comedy lately',
'I have to eat icecream' ]
list_processed = aruana_en.preprocess_list(list_of_strings, stem=False, remove_stopwords=True)
print(list_processed)
>>> [['love'], ['please', 'never', 'leave', 'alone'], ['go', 'die'], ['watching', 'lot', 'romantic', 'comedy', 'lately'], ['eat', 'icecream']]
定义自己的管道
使用单个可用方法创建自定义管道,而不是使用快速预处理功能。
text = "At the end of the day, @john you're solely responsible for your #success and your #failure. And the sooner you realize that, you accept that, and integrate that into your work ethic, you will start being #successful."
text = aruana_en.lower_remove_white(text)
text = aruana_en.expand_contractions(text)
text = aruana_en.replace_handles(text, 'HANDLE')
text = aruana_en.replace_hashtags(text, 'HASHTAG')
text = aruana_en.remove_stopwords(text)
text = aruana_en.replace_punctuation(text, placeholder='PUNCTUATION')
text = aruana_en.tokenize(text)
print(text)
>>> ['end', 'day', 'PUNCTUATION', 'HANDLE', 'solely', 'responsible', 'HASHTAG', 'HASHTAG', 'PUNCTUATION', 'sooner', 'realize', 'that', 'PUNCTUATION', 'accept', 'that', 'PUNCTUATION', 'integrate', 'work', 'ethic', 'PUNCTUATION', 'start', 'HASHTAG', 'PUNCTUATION']
开发
测试
创建一个干净的测试环境
导航到计算机上的Aruana项目并使用bdist_wheel生成包
$ python3 setup.py sdist bdist_wheel
安装软件包
$ python3 setup.py install
文件
导航到aruana/aruana并键入:
$ pdoc --html aruana
释放
在发布新版本之前,请执行以下步骤:
更新所有必要的文档
使用bdist生成包
在干净的环境中安装新版本以进行测试
如果一切正常,则使用p doc生成文档
贡献
请阅读CONTRIBUTING.md了解我们行为准则的详细信息,以及向我们提交请求的过程。
版本控制
使用SemVer进行版本控制。
作者
- wilame vallantin-initial work-Nhe'eng
许可证
此项目在apache许可下获得许可-有关详细信息,请参见LICENSE.md文件
第1.1.1节
新功能
- 添加随机分类方法,用于测试模型精度的随机文本分类
- 添加replace_with_blob方法,用于从语料库中创建blob,以测试方法的准确性
- 添加“字符串”模块,其中包含标点符号和变音符号字符串的列表
- 添加内部标记器
- 为葡萄牙语添加pos标记符(实验版,0.0.1)
改善
- expand_压缩现在可以识别更多葡萄牙语单词
- 预处理文本现在将表情符号转换为文本,而不是完全删除它们
- 删除nltk标记器并将其替换为内部标记器