WikiExtractorが実はbulletを落としている
久々にWikipediaのdumpファイルを処理しようとWikiExtractorを動かそうとしたのですが、 GitHubからcloneしただけでは動かず。
ここにあるように、詳しくは調査していませんがPythonを3.7にしたら動きました。
それより大事なこととして、初期状態ではbulletが落ちてしまいます。
bulletまで落とさず残しておくには、L230~L260付近を主に2箇所(最初と最後)編集する必要があります。
私は著作と参考文献のbulletはいらなかったので、落としていますが入っても良い場合はif節が不要になります。
変更前:
# handle indents elif line[0] == ':': # page.append(line.lstrip(':*#;')) continue # handle lists elif line[0] in '*#;:': if Extractor.HtmlFormatting: i = 0 for c, n in zip_longest(listLevel, line, fillvalue=''): if not n or n not in '*#;:': if c: page.append(listClose[c]) listLevel = listLevel[:-1] continue else: break # n != '' if c != n and (not c or (c not in ';:' and n not in ';:')): if c: # close level page.append(listClose[c]) listLevel = listLevel[:-1] listLevel += n page.append(listOpen[n]) i += 1 n = line[i - 1] # last list char line = line[i:].strip() if line: # FIXME: n is '"' page.append(listItem[n] % line) else: continue
変更後:
# handle indents elif line[0] == ':': if 'title' in locals() and title not in ['著作.', '参考文献.']: page.append(line.lstrip(':*#;')) # continue # handle lists elif line[0] in '*#;:': if Extractor.HtmlFormatting: i = 0 for c, n in zip_longest(listLevel, line, fillvalue=''): if not n or n not in '*#;:': if c: page.append(listClose[c]) listLevel = listLevel[:-1] continue else: break # n != '' if c != n and (not c or (c not in ';:' and n not in ';:')): if c: # close level page.append(listClose[c]) listLevel = listLevel[:-1] listLevel += n page.append(listOpen[n]) i += 1 n = line[i - 1] # last list char line = line[i:].strip() if line: # FIXME: n is '"' page.append(listItem[n] % line) else: if 'title' in locals() and title not in ['著作.', '参考文献.']: page.append(line.lstrip(':*#;')) # continue
昨年Wikipediaから抽出したコードが残っていないのだけれど、多分抜け落ちているなあ、、、
生データを見ながら確認していくことは、やはり大事です。