色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

你都用python做什么

呂致盈2年前19瀏覽0評論
你都用python做什么?

在律所里分析判決書!相當(dāng)有用!

上代碼:

import docx, csv, docxpyimport refrom get_file_path import all_file_listwith open('process_book' + '.csv', 'a+', encoding='utf-8') as file: writer = csv.writer(file) writer.writerow([ '案號', '法院名稱', '原審地' '再審申請人1', '再審申請人1住址', '再審申請人2', '再審申請人2住址', '再審申請人3', '再審申請人3住址', '再審申請人一審地位', '再審申請人二審地位', '被申請人1住址', '被申請人2住址', '被申請人3住址', '被申請人的類型,0自然人,1公司法人,2機關(guān)法人', '再審申請人是否有律師', '被申請人是否有律師', '合議庭人數(shù)', '審判長姓名', '審判員1', '審判員2' ])for read_docx in all_file_list: file = docx.Document(read_docx) print('------docx已經(jīng)順利讀出文件,開始處理中------') file2 = docxpy.process(read_docx) print('------docxpy已經(jīng)順利讀出文件,開始處理中------') # 案號 try: number = file.paragraphs[7].textexcept Exception as e: number = '出錯' print(number) ''' 找案件地域,注意最高院的情況 ''' # 提取再審法院名稱 court_name = re.findall(r'審理法院: (.*)', file2)[0] # 找不服哪級法院判決,然后丟出去 case_district = re.findall(r'(.*)不服(.*)人民法院', file2) for district in case_district: case_district = re.findall(r'[\u4e00-\u9fa5]{3}', district[1])[0] ''' 這里開始找再審申請人的信息 ''' appellant_name_list = [] appellant_name_0 = appellant_name_1 = appellant_name_2 = appellant_name_3 = '' instance_appellant_name = re.findall(r'再審申請人(.*):(.*),', file2) if instance_appellant_name: for name in instance_appellant_name: origin_list = name.split(',') if '男' in origin_list: appellant_name_list.append(origin_list[0]) elif '女' in origin_list: appellant_name_list.append(origin_list[0]) else: appellant_name_list.append(origin_list[0]) for get_appellant_name in range(len(appellant_name_list)): locals()['appellant_name_' + str(get_appellant_name)] = appellant_name_list[get_appellant_name] instance_appellant_name = re.findall(r'再審申請人(.*):(.*)。住所', file2) if len(appellant_name_0) == 0: # 稍微變態(tài)模式 for name in instance_appellant_name: appellant_name_list.append(name) for get_appellant_name in range(len(appellant_name_list)): locals()['appellant_name_' + str(get_appellant_name)] = appellant_name_list[get_appellant_name] if not appellant_name_list: # 超級變態(tài) instance_appellant_name = re.findall(r'再審申請人(.*):(.*)。\n', file2) for name in instance_appellant_name: appellant_name_list.append(name) for get_appellant_name in range(len(appellant_name_list)): locals()['appellant_name_' + str(get_appellant_name)] = appellant_name_list[get_appellant_name] # 判斷再審申請人是否有律師: appellant_have_lawyer = 0 appellant_have_lawyer_result = re.findall(r'再審申請人([\s\S]*委托訴訟代理人:.*', file2) for lawyer_is in appellant_have_lawyer_result: if '律師' in lawyer_is: appellant_have_lawyer = 1 else: appellant_have_lawyer = 0 # 判斷被申請人是否有律師: retrial_respondent_have_lawyer = 0 retrial_respondent_lawyer_result = re.findall(r'被申請人([\s\S]*委托訴訟代理人:.*', file2) for lawyer_is in retrial_respondent_lawyer_result: if '律師' in lawyer_is: retrial_respondent_have_lawyer = 1 else: retrial_respondent_have_lawyer = 0 # 定義空字符串用于接收循環(huán)體返回內(nèi)容 # 審判長 chief_judge = '' # 審判員列表 judge_list = [] # 審判員 judge_officer_0 = judge_officer_1 = '' # 合議庭總?cè)藬?shù) collegiate_bench_num = None # 找合議庭信息 for read_docx in file.paragraphs: ''' 這里先找合議庭成員的信息 ''' chief_judge_all = re.findall(r'審判長 (.+)', read_docx.text) for k in chief_judge_all: chief_judge = k.replace(' ', '') # 取到審判長名字 judge_officer_all = re.findall(r'審判員 (.+)', read_docx.text) for k in judge_officer_all: judge_list.append(k.replace(' ', '')) # 取到所有審判員列表 # 計算合議庭總?cè)藬?shù) collegiate_bench_num = 1 + len(judge_list) # 為審判員動態(tài)賦值 for get_judge_officer in range(len(judge_list)): locals()['judge_officer_' + str(get_judge_officer)] = judge_list[get_judge_officer] # 再審申請人的住址 appellant_address_list = [] appellant_address_0 = appellant_address_1 = appellant_address_2 = appellant_address_3 = '' appellant_address_result = re.findall(r'再審申請人(.*):.*住所地(.*)。', file2) # 法人住址,'住所地三字全' if appellant_address_result: for addr in appellant_address_result: appellant_address_list.append(addr.strip(':')) for detail_addr in range(len(appellant_address_list)): locals()['appellant_address_' + str(detail_addr)] = appellant_address_list[detail_addr] else: appellant_address_result = re.findall(r'再審申請人(.*):.*住(.+)。', file2) # 自然人住址,'住'開始 for addr in appellant_address_result: appellant_address_list.append(addr.strip(':')) for detail_addr in range(len(appellant_address_list)): locals()['appellant_address_' + str(detail_addr)] = appellant_address_list[detail_addr] # 被申請人住址: respondent_address_list = [] respondent_address_0 = respondent_address_1 = respondent_address_2 = respondent_address_3 = '' respondent_address_result = re.findall(r'被申請人(.*):.*住所地(.*)。', file2) # 法人住址,'住所地三字全' if respondent_address_result: for addr in respondent_address_result: respondent_address_list.append(addr.strip(':')) for detail_addr in range(len(respondent_address_list)): locals()['respondent_address_' + str(detail_addr)] = respondent_address_list[detail_addr] else: respondent_address_result = re.findall(r'被申請人(.*):.*住(.*)。', file2) # 自然人住址,只有'住' for addr in respondent_address_result: respondent_address_list.append(addr.strip(':')) for detail_addr in range(len(respondent_address_list)): locals()['respondent_address_' + str(detail_addr)] = respondent_address_list[detail_addr] # 被申請人中是否有法人 respondent_is_legal_person_list = [] respondent_is_legal_person = 0 ''' 0是自然人,1是公司法人,2是機關(guān)法人 ''' respondent_is_legal_person_result = re.findall(r'被申請人(.*):(.*),', file2) if respondent_is_legal_person_result: for person in respondent_is_legal_person_result: respondent_is_legal_person_list.append(person) for person2 in respondent_is_legal_person_list: if '公司' in person2: respondent_is_legal_person = 1 else: respondent_is_legal_person_result = re.findall(r'被申請人(.*):(.*)。', file2) for person in respondent_is_legal_person_result: respondent_is_legal_person_list.append(person) for person2 in respondent_is_legal_person_list: if '政府' in person2: respondent_is_legal_person = 2 # 取出再審申請人的一、二審地位 appellant_level_list = [] appellant_level_0 = appellant_level_1 = '' appellant_level_result = re.findall(r'再審申請人((.*)):', file2) if appellant_level_result: # appellant_level_list.append(appellant_level_result[0]) for detail in appellant_level_result[0].split('、'): appellant_level_list.append(detail) for get_detail in range(len(appellant_level_list)): locals()['appellant_level_' + str(get_detail)] = appellant_level_list[get_detail] with open('process_book' + '.csv', 'a+', encoding='utf-8') as file: writer = csv.writer(file) writer.writerow([ number, court_name, case_district, appellant_name_0, appellant_address_0, appellant_name_1, appellant_address_1, appellant_name_2, appellant_address_2, appellant_level_0, appellant_level_1, respondent_address_0, respondent_address_1, respondent_address_2, respondent_is_legal_person, appellant_have_lawyer, retrial_respondent_have_lawyer, collegiate_bench_num, chief_judge, judge_officer_0, judge_officer_1])