python-3.x - 为 NLP 预处理 .txt 文件
问题描述
我有超过一百个非结构化 .txt 文件(文章)需要对 NLP 进行预处理,我必须先将 .txt 文件转换为 .csv 文件吗?或者我可以开始使用原始文本文件进行清理吗?如果是这样,有人可以帮助我使用 Python 进行批处理文件类型转换吗?
解决方案
不,不需要将文本文件转换为 csv。您可以使用 python.docx 轻松读取 word 文件。首先,您需要安装 python.docx。在python 3中:
!pip install python.docx //install python docx
from docx import Document //import docx
doc=open("TextFileName.docx","rb") //creating a word file object
document=docx.Document(doc) //creating word reader object
推荐阅读
- django - 无法使用 CentOS 8、Nginx 和 Django-Rest-Framework 在 VirtualBox 上启动 gunicorn.service
- asp.net-mvc - 如何诊断 asp.net mvc 中的 ScriptBundle 错误
- javascript - 使用返回的 JSON 数据更改状态
- java - 如何仅更新可能已经为空的某些字段(使用 JSON 补丁)
- python-3.x - 如何使用 av.open() 访问我的网络摄像头麦克风中的音频流?
- python - Pandas 使用第一个有效索引按组删除 nan
- python - 计算多个字典键的 Pythonic 方法
- python - 将多行字符串的每一行发送到 for 循环中的列表
- wordpress - Wordpress - 如何让 tag_id 与 post_type 一起使用?
- sql-server - SQL Server 中这两个循环删除查询有什么区别