Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
505 views
in Technique[技术] by (71.8m points)

mediawiki - Finding subcategories of a wikipedia category using category and categorylinks table

I downloaded the category and categorylinks table sql.gz files from mediawiki and generated the required tables:

category and categorylinks

Manual for the tables: CategoryLinks Category

Consider the following category page of: NoSQL The parent category of this page is Database and Database management. How could I get this information from the two tables? The manual for category table says the following but I am unable to get that information: "

Note: The pages and sub-categories are stored in the categorylinks table."

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Categories alone have no hierachy. It’s the category pages that make the subcategorization work. So you will also have to get the page_id from the page table to be able to resolve this relation.

It essentially works like this:

  1. Category’s cat_title is a page title.
  2. Find that page_title in the page table, get the page_id
  3. Use the page_id to get the category link in cl_from
  4. Get the parent category title from cl_to
  5. Repeat from 2

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...