Esempio n. 1
0
def get_sum_list(paper_part):
    """
	get sum_list_p from paper_argu, or get sum_list_c from paper_opinion + paper_fact
	:return: <list> sum_list_p or sum_list_c
	"""
    sum_list = []
    sum_list_gongji, sum_list_not_gongji = [], []
    sum_matchs = constant.sum_pattern.finditer(paper_part)
    for match in sum_matchs:
        # 转化为浮点数
        sum_float = tools.convert_to_arabic(
            tools.reserve_only_in(match.group(1), constant.SUM_CHARS))
        # 向前看10字符
        look_ahead_context = paper_part[match.start(1) - 10:match.start(1)]
        # 寻找'共计'
        if constant.sum_total_pattern.search(look_ahead_context):
            # 总结句中的'共计'
            if tools.look_ahead_back(paper_part,
                                     match.span(0),
                                     ahead_dict={
                                         'num': 20,
                                         'char': '收受',
                                         'request_have': True
                                     },
                                     back_dict={
                                         'num': 50,
                                         'char': '受贿罪',
                                         'request_have': True
                                     }):
                sum_list.append(sum_float)
                return sum_list  # 退出函数
            # 非总结句中的'共计'
            else:
                if sum_float not in sum_list_gongji and sum_float < 1000000000:  # 大于10亿直接排除
                    sum_list_gongji.append(sum_float)
        # 非'共计'
        else:
            if sum_float not in sum_list_not_gongji and sum_float < 1000000000:  # 大于10亿直接排除
                sum_list_not_gongji.append(sum_float)
    # 取总和较小、非空的list
    if len(sum_list_gongji) > 0 and len(sum_list_not_gongji) > 0:
        sum_list = sum_list_gongji if sum(sum_list_gongji) < sum(
            sum_list_not_gongji) else sum_list_not_gongji
    else:
        sum_list = sum_list_gongji if len(
            sum_list_gongji) > 0 else sum_list_not_gongji

    return sum_list
Esempio n. 2
0
def decide_zhufan(opinion):
	"""
	decide zhufan
	:param opinion: <str> paper_opinion
	:return: <bool> True or False
	"""
	decide_zhufan_tag = False
	zhufan_match = constant.zhufan_pattern.search(opinion)
	if zhufan_match:
		if tools.look_ahead_back(
			opinion,
			zhufan_match.span(0),
			ahead_dict={'num': 10, 'char': '不', 'request_have': False},
			back_dict={'num': 10, 'char': '意见', 'request_have': False}
		):
			decide_zhufan_tag = True

	return decide_zhufan_tag
Esempio n. 3
0
def get_tag_ligong(opinion):
	"""
	get tag_ligong from paper_opinion
	:param opinion: <str> paper_opinion
	:return: <int> 0 for no, 1 for yes
	"""
	tag_ligong = 0
	ligong_match = constant.ligong_pattern.search(opinion)
	if ligong_match:
		if tools.look_ahead_back(
			opinion,
			ligong_match.span(0),
			ahead_dict={'num': 10, 'char': '不', 'request_have': False},
			back_dict={'num': 25, 'char': '不', 'request_have': False}
		) and tools.look_back(
			opinion,
			ligong_match.span(0)[1],
			back_dict={'num': 25, 'char': '误', 'request_have': False}
		):
			tag_ligong = 1

	return tag_ligong