Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
$get1 = (New-Object Net.WebClient).DownloadString("http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Languages&cmlimit=700&format=json")
|
||||
$get2 = (New-Object Net.WebClient).DownloadString("http://www.rosettacode.org/w/index.php?title=Special:Categories&limit=5000")
|
||||
$match1 = [regex]::matches($get1, "`"title`":`"Category:(.+?)`"")
|
||||
$match2 = [regex]::matches($get2, "title=`"Category:([^`"]+?)`">[^<]+?</a>[^\(]*\((\d+) members\)")
|
||||
$r = 1
|
||||
$langs = $match1 | foreach { $_.Groups[1].Value.Replace("\","") }
|
||||
$res = $match2 | sort -Descending {[Int]$($_.Groups[2].Value)} | foreach {
|
||||
if ($langs.Contains($_.Groups[1].Value))
|
||||
{
|
||||
[pscustomobject]@{
|
||||
Rank = "$r"
|
||||
Members = "$($_.Groups[2].Value)"
|
||||
Language = "$($_.Groups[1].Value)"
|
||||
}
|
||||
$r++
|
||||
}
|
||||
}
|
||||
1..30 | foreach{
|
||||
[pscustomobject]@{
|
||||
"Rank 1..30" = "$($_)"
|
||||
"Members 1..30" = "$($res[$_-1].Members)"
|
||||
"Language 1..30" = "$($res[$_-1].Language)"
|
||||
"Rank 31..60" = "$($_+30)"
|
||||
"Members 31..60" = "$($res[$_+30].Members)"
|
||||
"Language 31..60" = "$($res[$_+30].Language)"
|
||||
}
|
||||
}| Format-Table -AutoSize
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
$response = (New-Object Net.WebClient).DownloadString("http://rosettacode.org/wiki/Category:Programming_Languages")
|
||||
$languages = [regex]::matches($response,'title="Category:(.*?)">') | foreach {$_.Groups[1].Value}
|
||||
|
||||
$response = [Net.WebClient]::new().DownloadString("http://rosettacode.org/w/index.php?title=Special:Categories&limit=5000")
|
||||
$response = [regex]::Replace($response,'(\d+),(\d+)','$1$2')
|
||||
|
||||
$members = [regex]::matches($response,'<li><a[^>]+>([^<]+)</a>[^(]*[(](\d+) member[s]?[)]</li>') | foreach { [pscustomobject]@{
|
||||
Members = [Int]($_.Groups[2].Value)
|
||||
Language = [String]($_.Groups[1].Value)
|
||||
}} | where {$languages.Contains($_.Language)} | sort -Descending Members
|
||||
|
||||
Get-Date -UFormat "Sample output on %d %B %Y at %R %Z"
|
||||
$members | Select-Object -First 10 | foreach -Begin {$r, $rank, $count = 0, 0,-1} {
|
||||
$r++
|
||||
if ($count -ne $_.Members) {$rank = $r}
|
||||
$count = $_.Members
|
||||
$x = $_.Members.ToString("N0",[System.Globalization.CultureInfo]::CreateSpecificCulture('en-US'))
|
||||
$entry = "($x entries)"
|
||||
[String]::Format("Rank: {0,2} {1,15} {2}",$rank,$entry,$_.Language)
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
$languages = @{}
|
||||
$Body = @{
|
||||
format = 'json'
|
||||
action = 'query'
|
||||
generator = 'categorymembers'
|
||||
gcmtitle = 'Category:Programming Languages'
|
||||
gcmlimit = '200'
|
||||
gcmcontinue = ''
|
||||
continue = ''
|
||||
prop = 'categoryinfo'
|
||||
}
|
||||
$params = @{
|
||||
Method = 'Get'
|
||||
Uri = 'http://rosettacode.org/mw/api.php'
|
||||
Body = $Body
|
||||
}
|
||||
while ($true) {
|
||||
$response = Invoke-RestMethod @params
|
||||
$response.query.pages.PSObject.Properties | ForEach-Object {
|
||||
if (($_.value.PSObject.Properties.Name -Contains 'title') -and ($_.value.PSObject.Properties.Name -Contains 'categoryinfo')) {
|
||||
$languages[$_.value.title.replace('Category:', '')] = $_.value.categoryinfo.size
|
||||
}
|
||||
}
|
||||
if ($response.PSObject.Properties.Name -Contains 'continue') {
|
||||
$gcmcontinue = $response.continue.gcmcontinue
|
||||
$params.Body.gcmcontinue = $gcmcontinue
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
$members = $languages.GetEnumerator() | sort -Descending value
|
||||
Get-Date -UFormat "Sample output on %d %B %Y at %R %Z"
|
||||
$members | Select-Object -First 10 | foreach -Begin {$r, $rank, $count = 0, 0,-1} {
|
||||
$r++
|
||||
if ($count -ne $_.Members) {$rank = $r}
|
||||
$count = $_.Value
|
||||
$x = $_.Value.ToString("N0",[System.Globalization.CultureInfo]::CreateSpecificCulture('en-US'))
|
||||
$entry = "($x entries)"
|
||||
[String]::Format("Rank: {0,2} {1,15} {2}",$rank, $entry, $_.Name)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue