-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditrow.py
More file actions
55 lines (50 loc) · 1.94 KB
/
Copy patheditrow.py
File metadata and controls
55 lines (50 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding:utf-8 -*-
def separate_row(file, delimiter):
"""
日本語用
ファイルから句点ごとに変更したリストを返す
"""
new_file = []
for row_index, row in enumerate(file):
if(row_index==0):
continue
# delimiteerごとに文章を分割
sentences = row[2].split(delimiter)
sentences_length = len(sentences)
# 分割した文章数ごとの処理
if (len(row)==3):
if (sentences_length == 1):
new_sentence = check_quote(sentences[0]) + delimiter
new_row = [row[0], row[1], new_sentence]
new_file.append(new_row)
else:
for sentence in sentences:
if (sentence == '' or sentence == '"' or sentence==' "'):
continue
new_sentence = check_quote(sentence) + delimiter
new_row = [row[0], row[1], new_sentence]
new_file.append(new_row)
else:
if (sentences_length == 1):
new_sentence = check_quote(sentences[0]) + delimiter
new_row = [row[0], row[1], new_sentence, row[3]]
new_file.append(new_row)
else:
for sentence in sentences:
if (sentence == '' or sentence == '"' or sentence==' "'):
continue
new_sentence = check_quote(sentence) + delimiter
new_row = [row[0], row[1], new_sentence, row[3]]
new_file.append(new_row)
return new_file
def check_quote(sentence):
"""Meeting Assistの不要な文字列を削除"""
if sentence[:1] == '"':
sentence = sentence[1:]
if sentence[:2] ==' "':
sentence = sentence[2:]
if sentence[-1] == '"':
sentence = sentence [:-1]
if sentence[-2:] == ' "':
sentence = sentence [:-2]
return sentence