资源简介
直播答题助手 自动检测出题、搜索答案 支持(冲顶大会、优酷视频、知识超人等平台)
代码片段和文件信息
#!/usr/bin/env python
# encoding: utf-8
from PIL import Image
from pymouse import PyMouse PyMouseEvent
import os
import time
import codecs
from datetime import datetime
from argparse import ArgumentParser
import operator
from terminaltables import AsciiTable
from termcolor import colored
from core.crawler.query import abquery
from core.crawler.baiduzhidao import baidu_count
from core.ocr import get_text_from_image_hanwang get_text_from_image_baidu
import configparser
import sys
conf = configparser.ConfigParser()
conf.read(“config.ini“encoding=“utf8“)
# ocr_engine = ‘baidu‘
ocr_engine = conf.get(‘config‘“ocr_engine“)
### baidu orc
app_id = conf.get(‘config‘“app_id“)
app_key = conf.get(‘config‘“app_key“)
app_secret = conf.get(‘config‘“app_secret“)
### 0 表示普通识别
### 1 表示精确识别
api_version = conf.get(‘config‘“api_version“)
set_plat = conf.get(‘config‘“setplat“)
set_area_cd = conf.get(‘config‘“setarea_cd“)
set_area_xg = conf.get(‘config‘“setarea_xg“)
set_area_bw = conf.get(‘config‘“setarea_bw“)
set_area_zs = conf.get(‘config‘“setarea_zs“)
# set_area_yzb = conf.get(‘config‘“setarea_yzb“)
set_area_uc = conf.get(‘config‘“setarea_uc“)
set_area_bd = conf.get(‘config‘“setarea_bd“)
set_area_qe = conf.get(‘config‘“setarea_qe“)
set_area_cs = conf.get(‘config‘“setarea_cs“)
set_area_now = conf.get(‘config‘“setarea_now“)
setdely = conf.get(‘config‘“setdely“)
# set_area = conf.get(‘config‘“setarea“)
### hanwang orc
hanwan_appcode = conf.get(‘config‘“hanwan_appcode“)
def RGBToHTMLColor(rgb_tuple):
“““ convert an (R G B) tuple to #RRGGBB “““
hexcolor = str.upper(‘#%02x%02x%02x‘ % rgb_tuple)
# that‘s it! ‘%02x‘ means zero-padded 2-digit hex values
return hexcolor
def parse_args():
parser = ArgumentParser(description=“Hiro_QA_Helper“)
parser.add_argument(
“-t“ “--timeout“
type=int
default=5
help=“default http request timeout“
)
return parser.parse_args()
def extraContext(strf1f2):
left = str.find(f1)
right = str.rfind(f2)
return str[left+1:right]
def pre_process_question(qus):
“““
strip charactor and strip ?
:param question:
:return:
“““
now = datetime.today()
for char repl in [(“““ ““) (“”“ ““) (“?“ ““) (“《“ ““) (“》“ ““) (“我国“ “中国“)
(“今天“ “{0}年{1}月{2}日“.format(now.year now.month now.day))
(“今年“ “{0}年“.format(now.year))
(“这个月“ “{0}年{1}月“.format(now.year now.month))]:
qus = qus.replace(char repl)
return qus
def is_number(s):
try:
float(s)
return True
except ValueError:
pass
try:
import unicodedata
unicodedata.numeric(s)
return True
except (TypeError ValueError):
pass
return False
def get_area_data(text_area_file):
“““
:param text_area_file:
:return:
“““
with open(text_area_file “rb“) as fp:
image_data = fp.read()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\
文件 8196 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\.DS_Store
目录 0 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\.idea\
文件 522 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\.idea\Hiro for mac.iml
目录 0 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\.idea\dictionaries\
文件 88 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\.idea\dictionaries\NUAA_Hiro.xm
文件 1468 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\.idea\misc.xm
文件 276 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\.idea\modules.xm
文件 20554 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\.idea\workspace.xm
文件 3010 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\README.md
文件 790 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\config.ini
目录 0 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\
文件 6148 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\.DS_Store
文件 0 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\__init__.py
目录 0 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\__pycache__\
文件 148 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\__pycache__\__init__.cpython-36.pyc
文件 2036 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\__pycache__\ocr.cpython-36.pyc
目录 0 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\crawler\
文件 6148 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\crawler\.DS_Store
文件 0 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\crawler\__init__.py
目录 0 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\crawler\__pycache__\
文件 156 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\crawler\__pycache__\__init__.cpython-36.pyc
文件 2068 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\crawler\__pycache__\baiduzhidao.cpython-36.pyc
文件 2929 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\crawler\__pycache__\html_tools.cpython-36.pyc
文件 1626 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\crawler\__pycache__\query.cpython-36.pyc
文件 1559 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\crawler\baiduzhidao.py
文件 2704 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\crawler\html_tools.py
文件 2074 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\crawler\query.py
文件 1887 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\core\ocr.py
文件 323697 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\cut_image.png
目录 0 2018-02-02 12:52 Hiro_QAzhushou_for_MAC-master\dict\
............此处省略11个文件信息
评论
共有 条评论