Hi:
I have been using the API (http://en.wikipedia.org/w/api.php) and found some problem. I would like to get a random article of a category or child categories. I mean if I need a random article of "Science" category, so the result can be an article in "Astronomy" category, or "Biology" category.
"random" command just have namespace not category, and "categorymembers" has not recursivity. The problems is categories are not nested so I guess there's no command that give that recursivity since an article has just "parent categories" and not all the jerarchy information.
I have tried to mix "random" and "categorymembers" with generators: http://en.wikipedia.org/w/api.php?action=query&list=random&generator... http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&...
... but no luck
The only solution i'm thinking is to code some random depth search in the category I want to get the random article, and then search in that category any random article. So, I can use "categorymembers" command to deep a random number of levels, and then take the article there.
Is there any nice solution ?
Thank you
On Sat, Dec 12, 2009 at 9:49 PM, Skiiiks skiiiks@gmail.com wrote:
The only solution i'm thinking is to code some random depth search in the category I want to get the random article, and then search in that category any random article. So, I can use "categorymembers" command to deep a random number of levels, and then take the article there.
Is there any nice solution ?
No. The solution you mentioned is the only one.
Bryan
Bryan Tong Minh escribió:
No. The solution you mentioned is the only one.
Well, clear as water :)
The problem is that, once you deep into a "X" level of depth category from the one you start, not all of them has articles. I've found some categories that has just caterogies ... Interesting function to code :)
Thank you for the fast response
Skiiiks escribió:
Bryan Tong Minh escribió:
No. The solution you mentioned is the only one.
Well, clear as water :)
The problem is that, once you deep into a "X" level of depth category from the one you start, not all of them has articles. I've found some categories that has just caterogies ... Interesting function to code :)
Thank you for the fast response
Then the category tree is not too well organised. Having only categories on the first levels and then articles in then would be much more logical.
The issue with child categories is that the category organization is up to the wiki community. There may be loops. The articles may be both in the parent and child categories, it may have hundreds of descendants... ...and the operation would need to be efficient.
Platonides escribió:
Then the category tree is not too well organised. Having only categories on the first levels and then articles in then would be much more logical.
The issue with child categories is that the category organization is up to the wiki community. There may be loops. The articles may be both in the parent and child categories, it may have hundreds of descendants... ...and the operation would need to be efficient.
Platonides, as you said, the categories are a mess in the Wikipedia. The "Categorization" proyect just try to put, at least, one category holding each article, but the category tree is hand work of the wikipedians. There's no tree, there's a lot of orphans categories, duplicated ones, and a lot of loops and crosses.
That's because I assume a simple recursive depth search is the only solution for getting a random article in a category (or their childs)
mediawiki-api@lists.wikimedia.org