赞
踩
纠错帮【python文稿AI纠错工具】,由论坛大神制作的一个论文纠错工具,由Python语言编写,可以检查出文档内的语句,错字内容,选择好文件导入后就可以一键进行检测,能有效检查出一些基础错误,提高文章的准确率。本次放出大神制作的这个纠错帮小程序工具下载。
纠错帮工具使用
选择文件并加载
点击开始检测一键查询
查询结束后会显示错误点并自动纠正
纠错帮工具源码
import PySimpleGUI as sg
from aip import AipNlp
from docx import Document
from docx.shared import RGBColor
import os
import pickle
import random
import time
class TextAIAnalyse(object):
"""
:param
"""
def __init__(self, doc_path, app_id, api_key, secret_key):
"""
:param doc_path:文章路径
:param app_id: 应用id,自己去百度ai控制台构建一个应用,就会有id了
:param api_key:
:param secret_key:
"""
self.client = AipNlp(app_id, api_key, secret_key)
self.document = Document(doc_path)
self.doc_path = doc_path
text_list1 = self.filter_style()
self.text_list2 = self.filter_short_text(text_list1, 12)
def filter_style(self):
"""
样式过滤
:param
"""
delete_style = ['Title', 'Heading 1', 'Quote'] # 去除标题,一级标题,图表链接
list1 = [x.text for x in self.document.paragraphs if x.style.name not in delete_style]
return list1
@staticmethod
def filter_short_text(list1: list, length: int):
"""
去除短文本
:param list1: 列表格式的文本集
:param length:最短文本长度
"""
list2 = [x.strip() for x in list1] # 去除两边空格
list3 = [x for x in list2 if len(x) > length]
return list3
def split_text(self, list1: list):
"""
对段落进行分句,粗糙分词
:param
"""
list2 = []
for x in list1:
x_list1 = x.split('。') # 以句号进行分词,分号暂时不考虑
for xx in x_list1:
if xx[-1:] not in ['。', ';', ':']: # 如果本局不是以句号结尾,则给它加上句号
xx += '。'
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。