Wikipedia:List of Wikipedians by featured article nominations/script

This is the script currently run by user:Rick Bot to produce the content of Wikipedia:List of Wikipedians by featured article nominations from the by year nomation lists (which are updated separately and assumed to be in the files FAnoms.2007 FAnoms.2006 FAnoms.2005 FAnoms.2004 FAnoms.2003). This script also uses as input preprocessed versions of WP:FA and WP:FFA assumed to be in the files "featureds" and "formers". -- Rick Block (talk) 17:02, 29 May 2007 (UTC)[reply]

#!/bin/bash

cat FAnoms.2007 FAnoms.2006 FAnoms.2005 FAnoms.2004 FAnoms.2003 | awk '
function nomd(nom, article) {

  sub("^ *","",nom)
  sub(" *$","",nom)
  sub("^ *","",article)
  sub(" *$","",article)
  sub("^<.>","",article)
  sub("</.>$","",article)
  user = nom
  if (sub("\\|.*]]","",user) > 0) {
    sub("^..[uU][sS][eE][rR]:","",user)
  }
  user = toupper(substr(user,1,1)) substr(user,2,length(user)-1)
  if (fulluser[user] == "") {
    fulluser[user] = nom
  }
  if (sub("^'"''"'*\\[","[",article) > 0) {
    sub("'"'"'* *$","",article)
  }
  noms[user] = noms[user] "||" article
  nomcount[user] = nomcount[user] + 1
}

BEGIN {
  FS="\\|\\|"
}

/^\|\|/ {
  if ($4 ~ /]] & /) {
    split($4,multinoms," & ")
    for (nom in multinoms) {
      nomd(multinoms[nom],$2)
    }
  } else {
    nomd($4,$2)
  }
}

END {
  for (nom in nomcount) {
    if (nom != "") {
      print nomcount[nom] "||" fulluser[nom] noms[nom]
    } else {
      print nomcount[nom] "||MISSING" noms[nom]
    }
  }
}
' | sort -t'|' +0rn +2f| tee nomlist | cat featureds formers - | awk >WBFAN.table '
BEGIN {
  FS="\\|\\|"
}

/^FEATURED/ {
  featured[$2] = 1
  next
} 

/^FORMER/ {
  former[$2] = 1
  next
} 

{
  if ( $2 != "MISSING" ) {
    print "|-"
    print "| " $2 
  }
  numarts = 0
  for ( i=3; i<=NF; i=i+1) {
    sub("\\|.*]]","]]",$i)
    numarts = numarts + 1
    if (numarts > 20) {
      if ( $2 != "MISSING") {
        printf "|-\n||\n"
      }
      numarts = 1
    }
    sub("]] *$","",$i)
    sub("^[[][[]","",$i)
    if (former[$i] > 0) {
      if ( $2 != "MISSING") {
        print "| [[" $i "|<span style=\"color: #B7410E;\">★</span>]]"
      }
      former[$i] = 2
    } else {
      if ( $2 != "MISSING") {
        print "|  [[" $i "|★]]"
      }
      if (featured[$i] > 0) {
        featured[$i] = 2
      } else {
        neverfeatured[$i] = 1
      }
    }
  }
}

END {

  for (art in featured) {
    if (featured[art] == 1 ) {
      if (fanonom == 0) {
        print "<!--"
        print "== FAs with no nomination history =="
        fanonom = 1
      }
      print "* [[" art "]]"
    }
  }
  if (fanonom == 1) {
    print "--!>"
  }

  for (art in former) {
    if (former[art] == 1 ) {
      if (ffanonom == 0) {
        print "<!--"
        print "== FFAs with no nomination history =="
        ffanonom = 1
      }
      print "* [[" art "]]"
    }
  }
  if (ffanonom == 1) {
    print "--!>"
  }

  for (art in neverfeatured) {
    if (art != "Pumping lemma" && art != "Provinces of Thailand") {
      if (histonly == 0) {
        print "<!--"
        print "== Nomination history but neither FA or FFA =="
        histonly = 1
      }
      print "* [[" art "]]"
    }
  }
  if (histonly == 1) {
    print "--!>"
  }

}'


/usr/bin/curl "http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_Wikipedians_by_featured_article_nominations&action=raw" | awk >WBFAN '
/^[|]-$/ {
  skip=1
}

/^[|]}/ {
  skip=0
  while ( getline <"WBFAN.table" ) {
    print $0
  }
  print "|}"
  next
}

{
  if (skip == 1) {
    next
  }
  print $0
}'