<commit_before>package BNet::Utils;

use strict;
use warnings;
use JSON;
use LWP::Simple;

sub downloadinfo($$$$) {
	my ($character, $server, $field, $apikey) = @_;
	my $retrievedinfo = BNet::Utils::apiget($character, $server, $field, $apikey);
	return $retrievedinfo;
}

sub apiget ($$$$){
	my ($character, $server, $field, $apikey) = @_;
	my $definedurl = "https://us.api.battle.net/wow/character/" . $server . "/" . $character . "?fields=" . $field . "&apikey=" . $apikey;
	my $url = get($definedurl);
	die "Couldn't get it! $character $server" unless defined $url;

	my $decoded = decode_json($url);
	return $decoded;
}

sub tableprint ($) {
	my ($decoded) = @_;
	
	if ($decoded eq 'begintable') {
		print "\t<table>\n";
	} elsif ($decoded eq 'endtable') {
		print "\t</table>\n";
	} elsif ($decoded eq 'beginrow') {
		print "\t\t<tr>\n";
	} elsif ($decoded eq 'endrow') {
		print "\t\t</tr>\n";
	} elsif ($decoded eq 'begintd') {
		print "\t\t<td>\n";
	} elsif ($decoded eq 'begintddk') {
		print "\t\t<td class=\"Death-Knight\">\n";
	} elsif ($decoded eq 'begintddh') {
		print "\t\t<td class=\"Demon-Hunter\">\n";
	} elsif ($decoded eq 'begintddr') {
		print "\t\t<td class=\"Druid\">\n";
	} elsif ($decoded eq 'begintdhr') {
		print "\t\t<td class=\"Hunter\">\n";
	} elsif ($decoded eq 'begintdmg') {
		print "\t\t<td class=\"Mage\">\n";
	} elsif ($decoded eq 'begintdmo') {
		print "\t\t<td class=\"Monk\">\n";
	} elsif ($decoded eq 'begintdpa') {
		print "\t\t<td class=\"Paladin\">\n";
	} elsif ($decoded eq 'begintdpr') {
		print "\t\t<td class=\"Priest\">\n";
	} elsif ($decoded eq 'begintdro') {
		print "\t\t<td class=\"Rogue\">\n";
	} elsif ($decoded eq 'begintdsh') {
		print "\t\t<td class=\"Shaman\">\n";
	} elsif ($decoded eq 'begintdwl') {
		print "\t\t<td class=\"Warlock\">\n";
	} elsif ($decoded eq 'begintdwr') {
		print "\t\t<td class=\"Warrior\">\n";
	} elsif ($decoded eq 'begintdcomplete') {
		print "\t\t<td class=\"Complete\">\n";
	} elsif ($decoded eq 'begintdincomplete') {
		print "\t\t<td class=\"Incomplete\">\n";
	} elsif ($decoded eq 'endtd') {
		print "\t\t</td>\n";
	} elsif ($decoded eq 'beginth') {
		print "\t\t<th>\n";
	} elsif ($decoded eq 'endth') {
		print "\t\t</th>\n";
	} elsif ($decoded eq 'thbeginspan') {
		print "\t\t<th colspan=\"17\">\n";
	}
}

sub determineclass ($) {
	my ($decoded) = @_;
#	print $decoded->{'level'} . "&nbsp;";
	my $class;

	if ($decoded->{'class'} == 1) {
		#"Warrior";
		$class ="begintdwr";
	} elsif ($decoded->{'class'} == 2) {
		#"Paladin";
		$class ="begintdpa";
	} elsif ($decoded->{'class'} == 3) {
		$class ="begintdhr";
	} elsif ($decoded->{'class'} == 4) {
		#"Rogue";
		$class ="begintdro";
	} elsif ($decoded->{'class'} == 5) {
		#"Priest";
		$class ="begintdpr";
	} elsif ($decoded->{'class'} == 6) {
		$class ="begintddk";
	} elsif ($decoded->{'class'} == 7) {
		#"Shaman";
		$class ="begintdsh";
	} elsif ($decoded->{'class'} == 8) {
		$class ="begintdmg";
	} elsif ($decoded->{'class'} == 9) {
		#"Warlock";
		$class ="begintdwl";
	} elsif ($decoded->{'class'} == 10) {
		$class ="begintdmo";
	} elsif ($decoded->{'class'} == 11) {
		$class ="begintddr";
	} elsif ($decoded->{'class'} == 12) {
		$class ="begintddh";
	}
	return $class;
}

sub determinegender ($) {
	my ($decoded) = @_;
	if ($decoded->{'gender'} == 1) {
		print "Female";
	} else {
		print "Male";
	}
}

sub determinerace ($) {
	my ($decoded) = @_;
	
	if ($decoded->{'race'} == 1) {
		print "Human&nbsp;";
	} elsif ($decoded->{'race'} == 2) {
		print "Orc&nbsp;";
	} elsif ($decoded->{'race'} == 3) {
		print "Dwarf&nbsp;";
	} elsif ($decoded->{'race'} == 4) {
		print "Night Elf&nbsp;";
	} elsif ($decoded->{'race'} == 5) {
		print "Undead&nbsp;";
	} elsif ($decoded->{'race'} == 6) {
		print "Tauren&nbsp;";
	} elsif ($decoded->{'race'} == 7) {
		print "Gnome&nbsp;";
	} elsif ($decoded->{'race'} == 8) {
		print "Troll&nbsp;";
	} elsif ($decoded->{'race'} == 9) {
		print "Goblin&nbsp;";
	} elsif ($decoded->{'race'} == 10) {
		print "Blood Elf&nbsp;";
	} elsif ($decoded->{'race'} == 11) {
		print "Draenei&nbsp;";
	} elsif ($decoded->{'race'} == 22) {
		print "Worgen&nbsp;";
	} elsif ($decoded->{'race'} == 24) {
		print "Pandaren&nbsp;";
	} elsif ($decoded->{'race'} == 25) {
		print "Pandaren&nbsp;";
	} elsif ($decoded->{'race'} == 26) {
		print "Pandaren&nbsp;";
	}

}

sub printcharacter($$) {
	my ($server, $char) = @_;
	my $url = "https://worldofwarcraft.com/en-us/character/" . $server . "/" . $char . "/";
#	print "\t\t\t\t$columns[0]\n";
#	print "\t\t\t\t</br>\n";
#	print "\t\t\t\t$columns[1]\n";
	print "\t\t\t\t<a href=\"";
	print $url;
	print "\">";
	print $char;
	print "</a>";
	
}
sub percharachievementscriteria ($) {
	my ($decoded) = @_;
	my @raids = @{ $decoded->{'achievements'}{'criteria'} };
	return @raids;
}

sub percharachievementscriteriaquantity ($) {
	my ($decoded) = @_;
	my @raids = @{ $decoded->{'achievements'}{'criteriaQuantity'} };
	return @raids;
}

sub percharquests ($) {
	my ($decoded) = @_;
	my @raids = @{ $decoded->{'quests'} };
	return @raids;
}

sub reputationtojson ($) {
	my ($reputation) = @_;
	my @raids = @{ $reputation->{'reputation'} };
	return @raids;
}

sub reputationtohash ($%) {
	my (@raids, %rephash) = @_;

	foreach my $f ( @raids ) {
	
	}

}

sub preprint ($$$%) {
	my ($count, $qid, $ql, %multiuserquests) = @_;
	my %qc;<commit_msg>profession start<commit_after>package BNet::Utils;

use strict;
use warnings;
use JSON;
use LWP::Simple;

sub downloadinfo($$$$) {
	my ($character, $server, $field, $apikey) = @_;
	my $retrievedinfo = BNet::Utils::apiget($character, $server, $field, $apikey);
	return $retrievedinfo;
}

sub apiget ($$$$){
	my ($character, $server, $field, $apikey) = @_;
	my $definedurl = "https://us.api.battle.net/wow/character/" . $server . "/" . $character . "?fields=" . $field . "&apikey=" . $apikey;
	my $url = get($definedurl);
	die "Couldn't get it! $character $server" unless defined $url;

	my $decoded = decode_json($url);
	return $decoded;
}

sub tableprint ($) {
	my ($decoded) = @_;
	
	if ($decoded eq 'begintable') {
		print "\t<table>\n";
	} elsif ($decoded eq 'endtable') {
		print "\t</table>\n";
	} elsif ($decoded eq 'beginrow') {
		print "\t\t<tr>\n";
	} elsif ($decoded eq 'endrow') {
		print "\t\t</tr>\n";
	} elsif ($decoded eq 'begintd') {
		print "\t\t<td>\n";
	} elsif ($decoded eq 'begintddk') {
		print "\t\t<td class=\"Death-Knight\">\n";
	} elsif ($decoded eq 'begintddh') {
		print "\t\t<td class=\"Demon-Hunter\">\n";
	} elsif ($decoded eq 'begintddr') {
		print "\t\t<td class=\"Druid\">\n";
	} elsif ($decoded eq 'begintdhr') {
		print "\t\t<td class=\"Hunter\">\n";
	} elsif ($decoded eq 'begintdmg') {
		print "\t\t<td class=\"Mage\">\n";
	} elsif ($decoded eq 'begintdmo') {
		print "\t\t<td class=\"Monk\">\n";
	} elsif ($decoded eq 'begintdpa') {
		print "\t\t<td class=\"Paladin\">\n";
	} elsif ($decoded eq 'begintdpr') {
		print "\t\t<td class=\"Priest\">\n";
	} elsif ($decoded eq 'begintdro') {
		print "\t\t<td class=\"Rogue\">\n";
	} elsif ($decoded eq 'begintdsh') {
		print "\t\t<td class=\"Shaman\">\n";
	} elsif ($decoded eq 'begintdwl') {
		print "\t\t<td class=\"Warlock\">\n";
	} elsif ($decoded eq 'begintdwr') {
		print "\t\t<td class=\"Warrior\">\n";
	} elsif ($decoded eq 'begintdcomplete') {
		print "\t\t<td class=\"Complete\">\n";
	} elsif ($decoded eq 'begintdincomplete') {
		print "\t\t<td class=\"Incomplete\">\n";
	} elsif ($decoded eq 'endtd') {
		print "\t\t</td>\n";
	} elsif ($decoded eq 'beginth') {
		print "\t\t<th>\n";
	} elsif ($decoded eq 'endth') {
		print "\t\t</th>\n";
	} elsif ($decoded eq 'thbeginspan') {
		print "\t\t<th colspan=\"17\">\n";
	}
}

sub determineclass ($) {
	my ($decoded) = @_;
#	print $decoded->{'level'} . "&nbsp;";
	my $class;

	if ($decoded->{'class'} == 1) {
		#"Warrior";
		$class ="begintdwr";
	} elsif ($decoded->{'class'} == 2) {
		#"Paladin";
		$class ="begintdpa";
	} elsif ($decoded->{'class'} == 3) {
		$class ="begintdhr";
	} elsif ($decoded->{'class'} == 4) {
		#"Rogue";
		$class ="begintdro";
	} elsif ($decoded->{'class'} == 5) {
		#"Priest";
		$class ="begintdpr";
	} elsif ($decoded->{'class'} == 6) {
		$class ="begintddk";
	} elsif ($decoded->{'class'} == 7) {
		#"Shaman";
		$class ="begintdsh";
	} elsif ($decoded->{'class'} == 8) {
		$class ="begintdmg";
	} elsif ($decoded->{'class'} == 9) {
		#"Warlock";
		$class ="begintdwl";
	} elsif ($decoded->{'class'} == 10) {
		$class ="begintdmo";
	} elsif ($decoded->{'class'} == 11) {
		$class ="begintddr";
	} elsif ($decoded->{'class'} == 12) {
		$class ="begintddh";
	}
	return $class;
}

sub determinegender ($) {
	my ($decoded) = @_;
	if ($decoded->{'gender'} == 1) {
		print "Female";
	} else {
		print "Male";
	}
}

sub determinerace ($) {
	my ($decoded) = @_;
	
	if ($decoded->{'race'} == 1) {
		print "Human&nbsp;";
	} elsif ($decoded->{'race'} == 2) {
		print "Orc&nbsp;";
	} elsif ($decoded->{'race'} == 3) {
		print "Dwarf&nbsp;";
	} elsif ($decoded->{'race'} == 4) {
		print "Night Elf&nbsp;";
	} elsif ($decoded->{'race'} == 5) {
		print "Undead&nbsp;";
	} elsif ($decoded->{'race'} == 6) {
		print "Tauren&nbsp;";
	} elsif ($decoded->{'race'} == 7) {
		print "Gnome&nbsp;";
	} elsif ($decoded->{'race'} == 8) {
		print "Troll&nbsp;";
	} elsif ($decoded->{'race'} == 9) {
		print "Goblin&nbsp;";
	} elsif ($decoded->{'race'} == 10) {
		print "Blood Elf&nbsp;";
	} elsif ($decoded->{'race'} == 11) {
		print "Draenei&nbsp;";
	} elsif ($decoded->{'race'} == 22) {
		print "Worgen&nbsp;";
	} elsif ($decoded->{'race'} == 24) {
		print "Pandaren&nbsp;";
	} elsif ($decoded->{'race'} == 25) {
		print "Pandaren&nbsp;";
	} elsif ($decoded->{'race'} == 26) {
		print "Pandaren&nbsp;";
	}

}

sub printcharacter($$) {
	my ($server, $char) = @_;
	my $url = "https://worldofwarcraft.com/en-us/character/" . $server . "/" . $char . "/";
#	print "\t\t\t\t$columns[0]\n";
#	print "\t\t\t\t</br>\n";
#	print "\t\t\t\t$columns[1]\n";
	print "\t\t\t\t<a href=\"";
	print $url;
	print "\">";
	print $char;
	print "</a>";
	
}
sub percharachievementscriteria ($) {
	my ($decoded) = @_;
	my @raids = @{ $decoded->{'achievements'}{'criteria'} };
	return @raids;
}

sub percharachievementscriteriaquantity ($) {
	my ($decoded) = @_;
	my @raids = @{ $decoded->{'achievements'}{'criteriaQuantity'} };
	return @raids;
}

sub percharquests ($) {
	my ($decoded) = @_;
	my @raids = @{ $decoded->{'quests'} };
	return @raids;
}
#$reputation->{'professions'}{'primary'}{'recipes'} };


#sub percharquests ($) {
#	my ($decoded) = @_;
#	my @raids = @{ $decoded->{'quests'} };
#	return @raids;
#}

sub reputationtojson ($) {
	my ($reputation) = @_;
	my @raids = @{ $reputation->{'reputation'} };
	return @raids;
}

sub reputationtohash ($%) {
	my (@raids, %rephash) = @_;

	foreach my $f ( @raids ) {
	
	}

}

sub preprint ($$$%) {
	my ($count, $qid, $ql, %multiuserquests) = @_;
	my %qc;
{'fraction_non_alphanumeric': 0.2618566176470588, 'fraction_numerical': 0.007536764705882353, 'mean_word_length': 3.780755711775044, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 123, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3162684', 'n_tokens_mistral': 4995, 'n_tokens_neox': 4790, 'n_words': 940}