Exemplo n.º 1
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import img_utils
import json
import solve_utils
import config
import problem_utils

result = problem_utils.get_result()
question = result[0]
answer = result[1]

print u"问题 :" + question
#选项
for i in range(0, len(answer)):
    print u"选项" + str(i + 1) + u" : " + answer[i]

solve_utils.open_wabpage(question)

#判断否定
is_min = (question.find(u"不") != -1)

#两种方式进行判断
r1 = solve_utils.words_count(question, answer)
r2 = solve_utils.search_count(question, answer)

#根据两种方式的结果选出最佳答案
select1 = 0
select2 = 0
if is_min == False:
Exemplo n.º 2
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import solve_utils
import problem_utils
import config
import time
import re
from sys import stdout

time_start = time.time()

question, answers = problem_utils.get_result()

print(u"问题 :" + question)
if not answers:
    raise ValueError(u'未能识别出答案选项'.encode(stdout.encoding))

# 选项
for i in range(0, len(answers)):
    print(u"选项" + str(i + 1) + u" : " + answers[i])

if config.OPEN_BROWSER:
    solve_utils.open_webpage(question)

# 判断否定
is_opposite = (question.find(u"不") != -1)
# 验证否定是否合法
if is_opposite:
    # 不字前后没有未闭合的双引号或者书名号
    if re.match(u'^[^"《]*?((("[^"]+")|(《[^》]+》))[^"《]*)*不([^"》]*(("[^"]+")|(《[^》]+》)))*[^"》]*$',