-
Notifications
You must be signed in to change notification settings - Fork 0
/
schulze_optional.py
120 lines (100 loc) · 3.68 KB
/
schulze_optional.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from igdb_credentials import download_latest_credentials
from load_ballots import load_ballots
from match_names import standardize_ballots
from parsing_params import get_optional_categories
from schulze_goty import (
compute_schulze_ranking,
print_ballot_distribution_for_top_ranked_games,
print_schulze_ranking,
print_voter_stats,
try_to_break_ties_in_schulze_ranking,
)
def apply_pipeline_for_optional_categories(
input_filename: str,
release_year: str = "2020",
*,
try_to_break_ties: bool = True,
use_igdb: bool = True,
retrieve_igdb_data_from_scratch: bool = True,
apply_hard_coded_extension_and_fixes: bool = True,
use_levenshtein_distance: bool = True,
goty_field: str = "goty_preferences",
year_constraint: str = "equality",
print_matches: bool = True,
num_app_id_groups_to_display: int = 3,
must_be_available_on_pc: bool = False,
must_be_a_game: bool = False,
verbose: bool = False,
) -> bool:
ballots = load_ballots(input_filename)
# Standardize ballots
(standardized_ballots, _matches) = standardize_ballots(
ballots,
release_year,
print_after_sort=False,
use_igdb=use_igdb,
retrieve_igdb_data_from_scratch=retrieve_igdb_data_from_scratch,
apply_hard_coded_extension_and_fixes=apply_hard_coded_extension_and_fixes,
use_levenshtein_distance=use_levenshtein_distance,
must_be_available_on_pc=must_be_available_on_pc,
must_be_a_game=must_be_a_game,
goty_field=goty_field,
year_constraint=year_constraint,
print_matches=print_matches,
)
# Apply Schulze method
schulze_ranking = compute_schulze_ranking(standardized_ballots)
if try_to_break_ties:
schulze_ranking = try_to_break_ties_in_schulze_ranking(
schulze_ranking,
standardized_ballots,
)
print_schulze_ranking(
schulze_ranking,
target_release_year=release_year,
use_igdb=use_igdb,
)
if verbose:
print_ballot_distribution_for_top_ranked_games(
schulze_ranking,
standardized_ballots,
num_app_id_groups_to_display=num_app_id_groups_to_display,
)
print_voter_stats(
schulze_ranking,
standardized_ballots,
num_app_id_groups_to_display=num_app_id_groups_to_display,
)
return True
if __name__ == "__main__":
from load_ballots import get_ballot_file_name
ballot_year = "2024"
input_filename = get_ballot_file_name(ballot_year, is_anonymized=True)
update_credentials = False
if update_credentials:
download_latest_credentials(verbose=False)
# Optional Categories of the Year
release_year = ballot_year
retrieve_igdb_data_from_scratch = False
apply_hard_coded_extension_and_fixes = True
print_matches = False
for categorie in get_optional_categories():
goty_field = f"{categorie}_preferences"
year_constraint = "equality"
must_be_available_on_pc = False
must_be_a_game = False
print("Category: " + categorie)
apply_pipeline_for_optional_categories(
input_filename,
release_year=release_year,
try_to_break_ties=True,
retrieve_igdb_data_from_scratch=retrieve_igdb_data_from_scratch,
apply_hard_coded_extension_and_fixes=apply_hard_coded_extension_and_fixes,
use_levenshtein_distance=True,
goty_field=goty_field,
year_constraint=year_constraint,
print_matches=print_matches,
must_be_available_on_pc=must_be_available_on_pc,
must_be_a_game=must_be_a_game,
)
print()