cast.pl


# This work is licensed under the Creative Commons
# Attribution-ShareAlike 3.0 Unported License. To view a copy of this
# license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send
# a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042,
# USA. 
# Reference: http://www.lombardinetworks.net
# (C) Robert Tolksdorf, http://www.robert-tolksdorf.de
use Data::Dumper;
require "/vhome/lombardinetworks.net/htdocs/bin/helper.pl";

&loadWorkIds();
&load_networks();
&load_aliases();
&load_actorids();

# replace all aliases
foreach $key (keys %alias) {
    $cast{$alias{$key}}.=" | ".$cast{$key};
    delete $cast{$key};
}


print "<ul>";
# iterate through all remaing §keys from $cast
foreach $key (sort { lc $a cmp lc $b || $a cmp $b } keys %cast) {
    if (&to_consider($key)) {
	print "<li>".&link_to_actor($key)." is in $cast{$key}</li>\n";
	# count the | for the number or networks in which $key occurs
	$occurences[scalar($cast{$key} =~ tr/|/|/)+1]++;
	# store $key
	$occurencesName[scalar($cast{$key} =~ tr/|/|/)+1].="<li>".&link_to_actor($key)."</li>";
	$totalnum++;
    }
}
print "</ul>\n";


# print a short distribution table
print "<p><p><a name=\"occurences\">Of</a> the $totalnum actors, \n<ul>\n";
for my $i (1 .. $#occurences) {
    if ($occurences[$i]>0) {
	print "<li>".$occurences[$i].
	    (($occurences[$i]==1) ? " actor occurs" : " actors occur").
	    " in $i network".(($i!=1) ? "s":"" );
	printf ("(%.2f",$occurences[$i]/$totalnum*100);
	# for the three best occuring categories print which actors they are
	print "%)".(($i ge $#occurences-2) ? " These are <ul>".$occurencesName[$i]."</ul>":"")."</li>\n";
    }
}
print " </ul>\n";

# print the aliases sorted by name
print "<p><p>Several actors are mentioned under different names in the drawings:<ul>";
foreach $key ( sort (keys %alias)) {
    print "<li>\"".$key."\" also is used for ".&link_to_actor($alias{$key})."</li>\n";
}
print "</ul>\n";