How to make a list of user's reputation ? :)
Afficher commentaires plus anciens
?:

3 commentaires
Andrew Newell
le 8 Fév 2011
Well, how did you do it?
Vieniava
le 8 Fév 2011
Mark Shore
le 8 Fév 2011
At a glance, it's missing a few well-known significant contributors. And since the MATLAB newsgroup (unlike the FEX) doesn't allow comment rating, it's hard to say how one would go about this process.
Réponse acceptée
Plus de réponses (3)
Greg Bacon
le 24 Fév 2011
9 votes
A new Contributor page was added to MATLAB Answers today. The Contributor page lists user reputation and is sortable along a few different axis.
You can get to the new page by clicking on the new Contributor link in the left nav. The url is http://www.mathworks.com/matlabcentral/answers/contributors
Kenneth Eaton
le 9 Fév 2011
Here's yet another variation that uses Walter's idea of going through the pages of questions, fetching the question links, then fetching user Reputation data from each question page. It's fully automated and takes about 3 minutes to run on my machine.
NOTE: This code will only find users who have posted at least one question, answer, or comment. Users who have an Answers account but haven't posted anything (like this guy or this guy) will not show up in the ranking list, but they should have 0 Rep anyway so it doesn't really matter. ;)
function [userData,nQuestions] = answers_rankings
% Initializations:
userData = cell(0,2);
nQuestions = 0;
pagesLeft = true;
iPage = 1;
% Loop over question pages:
while pagesLeft
nextPage = ['http://www.mathworks.com/matlabcentral/answers/' ...
'?dir=asc&sort=asked&page=' int2str(iPage)];
[pageText,pageFound] = urlread(nextPage);
questionLinks = regexp(pageText,['href="(/matlabcentral/answers/' ...
'\d+[^"]+)"'],'tokens');
if pageFound && ~isempty(questionLinks)
questionLinks = strcat('http://www.mathworks.com',...
vertcat(questionLinks{:}));
for iQuestion = 1:numel(questionLinks)
[pageText,pageFound] = urlread(questionLinks{iQuestion});
if pageFound
nQuestions = nQuestions+1;
data = regexp(pageText,'title="Reputation: (\d+)">([^<]+)<',...
'tokens');
userData = [userData; vertcat(data{:})]; %#ok<AGROW>
end
end
iPage = iPage+1;
else
pagesLeft = false;
end
end
updateTime = now;
% Format the user data:
userReps = cellfun(@str2double,userData(:,1)); % Convert Rep to integer
[userNames,~,index] = unique(userData(:,2)); % Find unique user names
userReps = accumarray(index,userReps,[],@max); % Take the max Rep found
[userReps,sortIndex] = sort(userReps,'descend'); % Sort by Rep
userNames = userNames(sortIndex);
userData = [userNames num2cell(userReps)].';
% Display the results:
maxLength = max([9; cellfun('prodofsize',userNames)]);
fprintf('\nMATLAB Answers user rankings as of %s:\n\n',...
datestr(updateTime));
fprintf('%*s: %s\n',maxLength,'User name','Reputation');
fprintf('%s\n',repmat('-',1,maxLength+13));
fprintf(['%' int2str(maxLength) 's: %4d\n'],userData{:});
end
Vieniava
le 9 Fév 2011
Catégories
En savoir plus sur Historical Contests dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!