...私はときにCSV形式の文書に名前を交換する必要がのPython:sre_constants.errorのエラー:比類のないグループ
{SPEAKER}または{SPEAKERS}のタグに従ってください。
File "/usr/lib/python2.7/re.py", line 291, in filter
return sre_parse.expand_template(template, match)
File "/usr/lib/python2.7/sre_parse.py", line 831, in expand_template
raise error, "unmatched group"
sre_constants.error: unmatched group
私のスクリプトの一部は次のとおりです:しかし、私は、次のエラーメッセージが表示さ
list_speakers = re.compile(r'^\{GROUP OF SPEAKERS\}\t(.*)|^\{SPEAKER\}\t(.*)')
usernames = set()
for f in corpus:
with open(f, "r", encoding=encoding) as fin:
line = fin.readline()
while line:
line = line.rstrip()
if not line:
line = fin.readline()
continue
if not list_speakers.match(line):
line = fin.readline()
continue
names = list_speakers.sub(r'\1', line)
names = names.split(", ")
for name in names:
usernames.add(name)
line = fin.readline()
試してみてください。\\({スピーカーグループ|スピーカー)\} \ t(。*) '' –
素晴らしい作品です!どうもありがとうございました !! – Lili
私は答えを投稿しました、upvoting/acceptingを検討してください。 –