解析维基百科的Pagelink数据集

时间:2014-01-24 01:06:48

标签: database hadoop dataset wikipedia pagerank

我下载了Wikipedia Pagelinks数据集(可在Wiki Dumps上找到 - http://dumps.wikimedia.org/enwiki/20140102/)。我想在数据集上运行PageRank算法,但是,我无法解析数据,因为它没有很好地记录。

这是下载的数据集的示例。给出的字段是p1_from,p1_namespace和p1_title。在线查看,p1_namespace是一个表示文章类型的数字,但我不知道p1_from是什么。为了实现pagerank算法,我想要链接到特定文章的文章数量,但是,我不知道p1_from代表什么。根据它的名字,它听起来就像是远离那篇文章的链接数量,而不是相反。是这样的吗?而且,如果是,如何在给定数据的情况下反转图形,因此我可以找到正确的数字。

DROP TABLE IF EXISTS `pagelinks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pagelinks` (
  `pl_from` int(8) unsigned NOT NULL DEFAULT '0',
  `pl_namespace` int(11) NOT NULL DEFAULT '0',
  `pl_title` varbinary(255) NOT NULL DEFAULT '',
  UNIQUE KEY `pl_from` (`pl_from`,`pl_namespace`,`pl_title`),
  KEY `pl_namespace` (`pl_namespace`,`pl_title`,`pl_from`)
) ENGINE=InnoDB DEFAULT CHARSET=binary;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `pagelinks`
--

/*!40000 ALTER TABLE `pagelinks` DISABLE KEYS */;
INSERT INTO `pagelinks` VALUES (10,0,'Computer_accessibility'),(12,0,'-ism'),(12,0,'1848_Revolution'),(12,0,'1917_October_Revolution'),

(12,0,'1919_United_States_anarchist_bombings'),(12,0,'19th_century_philosophy'),
(12,0,'6_February_1934_crisis'),(12,0,'A._K._Press'),(12,0,'A._S._Neill'),(12,0,'AK_Press'),(12,0,'A_Greek–English_Lexicon'),(12,0,'A_Language_Older_Than_Words'),
(12,0,'A_Vindication_of_Natural_Society'),(12,0,'A_las_Barricadas'),(12,0,'Abbie_Hoffman'),(12,0,'Absolute_idealism'),(12,0,'Abstentionism'),(12,0,'Action_theory_(philosophy)'),
(12,0,'Adam_Smith'),(12,0,'Adolf_Brand'),(12,0,'Adolf_Hitler'),(12,0,'Adolphe_Thiers'),(12,0,'Aesthetic_emotions'),(12,0,'Aesthetics'),(12,0,'Affinity_group'),(12,0,'Affinity_groups'),
(12,0,'African_philosophy'),(12,0,'Against_Civilization:_Readings_and_Reflections'),(12,0,'Against_His-Story,_Against_Leviathan'),(12,0,'Age_of_Enlightenment'),(12,0,'Agriculturalism'),
(12,0,'Agriculture'),(12,0,'Al-Ghazali'),(12,0,'Alain_Badiou'),(12,0,'Alain_de_Benoist'),(12,0,'Albert_Camus'),(12,0,'Albert_Libertad'),(12,0,'Albert_Meltzer'),(12,0,'Aleister_Crowley'),
(12,0,'Alex_Comfort'),(12,0,'Alexander_Berkman'),(12,0,'Alexandre_Christoyannopoulos'),(12,0,'Alexandre_Skirda'),(12,0,'Alfredo_M._Bonanno')

1 个答案:

答案 0 :(得分:3)

  

我无法解析数据,因为它没有很好的文档记录。

SQL转储直接包含MediaWiki使用的MySQL表中的数据。这些表格记录在mediawiki.org上,在您的情况下是the pagelinks table

  

给出的字段是p1_from,p1_namespace和p1_title。

不,这不是1(头号),它是l(字母L),plpagelinks的缩写。

  

我不知道p1_from是什么。

从文档中,这是“包含链接的页面的page_id的关键字。”要查找链接所在页面的名称,您需要the page table