Talk:List of United Kingdom locations/A/script
Appearance
#!/usr/bin/perl -w #just paste some of this list into a file called "UKList" in the same folder and run "script > wikified" or something. Also: $checkWP=1; #if 0, doesn't try to correct links over the web. if you want to, install #http://search.cpan.org/~esummers/WWW-Wikipedia-1.8/lib/WWW/Wikipedia.pm %hashy;#number of occurrences of each place name @all; $wpcount=0;# of links corrected $wpchecked=0; $numlinked=0;# of places bracketed $alreadylinked=0; open(FD, "UKList"); #* Yeabridge - Somerset 50.93N 02.79W ST4415 while(<FD>){ if (/\* \[\[/) { $alreadylinked++ } else{ if (s/\* (.*) \- /\* \[\[$1\]\] \- /) { $numlinked++ } } push(@all, $_); #count occurances of place name, and try to correct #multiple links using "wikipedia" script. chomp $_; $_ =~ s/\* \[\[(.*)\]\] \- .*/$1/; if(defined($hashy{$_})) {$hashy{$_}++;} else {$hashy{$_} = 1;} #print $hashy{$_} || "0" } foreach (@all){ unless($checkWP){ print; next; } $place = $_; $container = $_; $newstring = $_; $place =~ s/\* \[\[(.*)\]\] \- .*/$1/; chomp $place; if ($hashy{$place} > 1){ $container =~ s/\* \[\[.*\]\] \- (.*) [\d][\d]\..*\..*\n/$1/; $wpchecked++; if(onWikipedia($place, $container)){ $newstring =~ s/.* (\d+\.\d+[NS] .*\n)/* [[$place, $container]] \- $container $1/; $wpcount++; } } print $newstring; } print "\n\nlinked $numlinked places\n"; print "There were already $alreadylinked place links.\n"; print "automatically fixed $wpcount links\n"; print "checked wikipedia for $wpchecked articles\n"; sub onWikipedia{ my $wp = `wikipedia \'$_[0], $_[1]\'`; if ($wp =~ /not found in wikipedia/){ return 0; } return 1; }
Talk pages are where people discuss how to make content on Wikipedia the best that it can be. You can use this page to start a discussion with others about how to improve the "List of United Kingdom locations/A/script" page.