TakeMessageCleaner是一个用于预处理消息的工具
TakeMessageCleaner的Python项目详细描述
接受消息清除器
TakeMessageCleaner是一个用于预处理消息的工具。 它可以用于将邮件转换为小写、更正拼写、删除标点符号、emoji、whatapp的emoji、重音、数字、cpf、url、电子邮件、金钱、代码、时间、日期和小对话等元素。 此外,它还可以预处理数据帧、序列、列表或csv文件中的数据。
messagecleaner.from_dataframe:从数据帧创建构造函数
- 配置文件路径:str config_file_path是配置为
- 数据帧:pd.core.frame.dataframe dataframe是需要处理的pandas数据帧。
- 内容栏:str content_column是具有要处理的信息的数据帧的列名。
messagecleaner.from_series:从序列创建构造函数
- 配置文件路径:str config_file_path是具有预处理的json文件的路径
- 系列:pd.core.frame.series 系列是需要处理的熊猫系列。
- 配置文件路径:str config_file_path是配置为
- lst:list lst是需要处理的字符串列表。
- 配置文件路径:str config_file_path是配置为
- 文件路径:strt 文件路径是需要处理的csv文件的路径。
- 内容栏:str content_column是具有要处理的信息的数据帧的列名。如果未设置文件分隔符,则将使用值“content”。
- 九月:str sep是csv文件分隔符。如果未设置文件分隔符,则将使用值“;”。
- 编码:str encoding是csv文件的编码。如果未设置文件编码,则将使用值“utf-8”。
messagecleaner.from_list:从列表创建构造函数
messagecleaner.from_file:从csv文件创建构造函数
文件路径:str,内容列:str='内容',编码:str='utf-8',sep:str=';'
messagecleaner.pre_process:使用配置的json文件预处理消息。
预处理步骤能够将句子转换成小写,纠正拼写并删除诸如标点符号、表情符号、whatapp表情符号、重音符号、数字、cpf、url、电子邮件、金钱、代码、时间、日期和小对话等元素。 或者,可以激活“使用占位符”在删除元素的位置插入占位符。例如:“我要2个苹果”将转换为“我要数字苹果”。
配置json
{
"use_placeholder": true,
"verbose": true,
"processing": {
"lower": true,
"punctuation": true,
"emoji": true,
"wa_emoji": true,
"accentuation": true,
"number": true,
"cpf": true,
"url": true,
"email": true,
"money": true,
"code": true,
"time": true,
"date": true,
"spelling": true
},
"output": {
"file_name": "output_file.csv",
"file_encoding" : "utf-8",
"file_sep": ";",
"remove_duplicates": true,
"remove_empty": true,
"sort_by_length": true
}
}
安装
使用包管理器pip安装takeMessageCleaner
pip install TakeMessageCleaner
用法
importMessageCleanerasmccleaner=mc.MessageCleaner.from_file(config_file_path='C:/Documents/config.json',file_path='C:/Users/mydata.csv',sep=';',encoding='latin-1')result=cleaner.clean()print(result)
作者
卡丽娜·蒂米·加藤