【问题标题】:Wikipedia: Processing from dumps, how to filter out hidden categories?维基百科:从转储中处理,如何过滤掉隐藏的类别?
【发布时间】:2026-02-13 04:15:02
【问题描述】:

我正在从这些转储中处理* [http://dumps.wikimedia.org/enwiki/20141208/]。

有关哪些类别与特定页面相关联的信息可从 [http://dumps.wikimedia.org/enwiki/20141208/enwiki-20141208-categorylinks.sql.gz],有关类别本身的元数据可从 [http://dumps.wikimedia.org/enwiki/20141208/enwiki-20141208-category.sql.gz] 获得。

但我无法将隐藏类别与可见类别分开。 例如,页面Anarchism 具有以下可见类别:

Anarchism
Political culture
Political ideologies
Social theories
Anti-fascism
Anti-capitalism
Far-left politics

虽然转储还暗示了许多其他垃圾标签,例如:

Articles_containing_Ancient_Greek-language_text
Articles_containing_Spanish-language_text
Articles_prone_to_spam_from_November_2014
Articles_with_DMOZ_links
Articles_with_French-language_external_links
Articles_with_inconsistent_citation_formats
CS1_French-language_sources_(fr)
CS1_German-language_sources_(de)
Good_articles
Use_British_English_from_January_2014
Wikipedia_indefinitely_move-protected_pages

与早期的一起。现在 Wikipedia 将它们称为“管理类别”或“隐藏类别”,但这些东西不会在转储中标记。

由于我已经过滤掉了这些标签,我的选择是通过模式匹配将它们过滤掉,或者直接从页面中获取可见标签(这是有问题的,因为类别在类别转储和页面中的书写方式不同)。

有什么建议吗?

【问题讨论】:

    标签: wikipedia


    【解决方案1】:

    所有隐藏的类别(或更具体地说,它们的页面)都直接位于(隐藏)类别Category:Hidden categories

    因此,您需要做的是获取每个类别页面的页面 id,然后查找该页面是否在隐藏类别中。要根据名称查找页面 id,您可能需要使用 page.sql 转储。

    例如,页面“Category:Articles contains Ancient Greek-language text”的页面 id 为 39721267,categorylinks.sql 确实包含条目:

    (39721267,'Hidden_categories','ANCIENT GREEK\nARTICLES CONTAINING ANCIENT GREEK-LANGUAGE TEXT','2013-06-25 09:42:34','Ancient Greek','uppercase','subcat')
    

    【讨论】: