- Timestamp:
- 2021-03-09T23:30:43+13:00 (3 years ago)
- Location:
- main/trunk/model-sites-dev/eurovision-lod/collect/eurovision
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/etc/collectionConfig.xml
r34943 r34960 82 82 </xsl:if> 83 83 84 <gsf:switch> 85 <gsf:metadata name='FinishingPos'/> 86 <gsf:when test='exists'> 87 <br /> 88 <font style="font-size: 80%;"> 89 Place: <gsf:metadata name='FinishingPos' /> 90 (Total Score: <gsf:metadata name="VoteGrandTotal"/>) 91 </font> 92 </gsf:when> 93 </gsf:switch> 94 84 95 </gsf:template> 85 96 … … 156 167 </gsf:choose-metadata> 157 168 </gsf:link> 169 170 <gsf:switch> 171 <gsf:metadata name='Creator'/> 172 <gsf:when test='exists'> 173 174 <gsf:switch> 175 <gsf:metadata name="Creator"/> 176 <gsf:when test="notEquals" test-value="Unknown"> 177 178 by <gsf:metadata name='Creator'/> 179 </gsf:when> 180 </gsf:switch> 181 182 </gsf:when> 183 </gsf:switch> 184 185 <gsf:switch> 186 <gsf:metadata name='Country'/> 187 <gsf:when test='exists'> 188 representing <gsf:metadata name='Country'/> 189 </gsf:when> 190 </gsf:switch> 191 192 <gsf:switch> 193 <gsf:metadata name='Year'/> 194 <gsf:when test='exists'> 195 (<gsf:metadata name='Year'/>) 196 </gsf:when> 197 </gsf:switch> 198 199 <gsf:switch> 200 <gsf:metadata name='FinishingPos'/> 201 <gsf:when test='exists'> 202 <br /> 203 <font style="font-size: 80%;"> 204 Place: <gsf:metadata name='FinishingPos' /> 205 (Total Score: <gsf:metadata name="VoteGrandTotal"/>) 206 </font> 207 </gsf:when> 208 </gsf:switch> 209 158 210 </td> 159 211 … … 163 215 164 216 <search type="jenaTDB" orthogonal="true"/> 217 165 218 166 219 <infodb type="jdbm"/> … … 481 534 <gsf:metadata name="FromCountryType"/> 482 535 <gsf:metadata name="FromCountryYear"/> 536 483 537 <gsf:metadata name="VotesCountryJSON-J" /> 484 538 <gsf:metadata name="VotesCountryJSON-T" /> 539 <gsf:metadata name="VotesCountryJSON-C" /> 540 <gsf:metadata name="VotesCountryJSON-S" /> 541 485 542 <gsf:metadata name="VotesPointsJSON-J" /> 486 543 <gsf:metadata name="VotesPointsJSON-T" /> 544 <gsf:metadata name="VotesPointsJSON-C" /> 545 <gsf:metadata name="VotesPointsJSON-S" /> 487 546 488 547 <gsf:metadata name="dc.Title"/> … … 505 564 <gsf:metadata name="WikipediaURL_uri"/> 506 565 566 <gsf:metadata name="VoteMode" /> 567 <gsf:metadata name="VoteGrandTotal" /> 568 <gsf:metadata name="FinishingPos" /> 569 507 570 <gsf:metadata name="JuryVotesJSON" /> 508 571 <gsf:metadata name="TeleVotesJSON" /> 572 <gsf:metadata name="CombVotesJSON" /> 573 <gsf:metadata name="SingVotesJSON" /> 574 509 575 <gsf:metadata name="JuryVotesTotal" /> 510 576 <gsf:metadata name="TeleVotesTotal" /> 577 <gsf:metadata name="CombVotesTotal" /> 578 <gsf:metadata name="SingVotesTotal" /> 579 580 <!-- boolean as to whether finalist or not --> 511 581 <gsf:metadata name="Final" /> 512 582 … … 610 680 <gsf:metadata name="Ukraine-T" /> 611 681 <gsf:metadata name="UnitedKingdom-T" /> 682 683 <gsf:metadata name="Albania-C" /> 684 <gsf:metadata name="Andorra-C" /> 685 <gsf:metadata name="Armenia-C" /> 686 <gsf:metadata name="Austria-C" /> 687 <gsf:metadata name="Azerbaijan-C" /> 688 <gsf:metadata name="Belarus-C" /> 689 <gsf:metadata name="Belgium-C" /> 690 <gsf:metadata name="BosniaandHerzegovina-C" /> 691 <gsf:metadata name="Bulgaria-C" /> 692 <gsf:metadata name="Croatia-C" /> 693 <gsf:metadata name="Cyprus-C" /> 694 <gsf:metadata name="CzechRepublic-C" /> 695 <gsf:metadata name="Denmark-C" /> 696 <gsf:metadata name="Estonia-C" /> 697 <gsf:metadata name="Finland-C" /> 698 <gsf:metadata name="France-C" /> 699 <gsf:metadata name="Georgia-C" /> 700 <gsf:metadata name="Germany-C" /> 701 <gsf:metadata name="Greece-C" /> 702 <gsf:metadata name="Hungary-C" /> 703 <gsf:metadata name="Iceland-C" /> 704 <gsf:metadata name="Ireland-C" /> 705 <gsf:metadata name="Israel-C" /> 706 <gsf:metadata name="Italy-C" /> 707 <gsf:metadata name="Latvia-C" /> 708 <gsf:metadata name="Lithuania-C" /> 709 <gsf:metadata name="Macedonia-C" /> 710 <gsf:metadata name="Malta-C" /> 711 <gsf:metadata name="Moldova-C" /> 712 <gsf:metadata name="Monaco-C" /> 713 <gsf:metadata name="Montenegro-C" /> 714 <gsf:metadata name="Netherlands-C" /> 715 <gsf:metadata name="Norway-C" /> 716 <gsf:metadata name="Poland-C" /> 717 <gsf:metadata name="Portugal-C" /> 718 <gsf:metadata name="Romania-C" /> 719 <gsf:metadata name="Russia-C" /> 720 <gsf:metadata name="SanMarino-C" /> 721 <gsf:metadata name="Serbia-C" /> 722 <gsf:metadata name="SerbiaandMontenegro-C" /> 723 <gsf:metadata name="Slovakia-C" /> 724 <gsf:metadata name="Slovenia-C" /> 725 <gsf:metadata name="Spain-C" /> 726 <gsf:metadata name="Sweden-C" /> 727 <gsf:metadata name="Switzerland-C" /> 728 <gsf:metadata name="Turkey-C" /> 729 <gsf:metadata name="Ukraine-C" /> 730 <gsf:metadata name="UnitedKingdom-C" /> 731 732 <gsf:metadata name="Austria-S" /> 733 <gsf:metadata name="Belgium-S" /> 734 <gsf:metadata name="BosniaandHerzegovina-S" /> 735 <gsf:metadata name="Croatia-S" /> 736 <gsf:metadata name="Cyprus-S" /> 737 <gsf:metadata name="Denmark-S" /> 738 <gsf:metadata name="Estonia-S" /> 739 <gsf:metadata name="Finland-S" /> 740 <gsf:metadata name="France-S" /> 741 <gsf:metadata name="Germany-S" /> 742 <gsf:metadata name="Greece-S" /> 743 <gsf:metadata name="Hungary-S" /> 744 <gsf:metadata name="Iceland-S" /> 745 <gsf:metadata name="Ireland-S" /> 746 <gsf:metadata name="Israel-S" /> 747 <gsf:metadata name="Italy-S" /> 748 <gsf:metadata name="Latvia-S" /> 749 <gsf:metadata name="Lithuania-S" /> 750 <gsf:metadata name="Luxembourg-S" /> 751 <gsf:metadata name="Macedonia-S" /> 752 <gsf:metadata name="Malta-S" /> 753 <gsf:metadata name="Monaco-S" /> 754 <gsf:metadata name="Morocco-S" /> 755 <gsf:metadata name="Netherlands-S" /> 756 <gsf:metadata name="Norway-S" /> 757 <gsf:metadata name="Poland-S" /> 758 <gsf:metadata name="Portugal-S" /> 759 <gsf:metadata name="Romania-S" /> 760 <gsf:metadata name="Russia-S" /> 761 <gsf:metadata name="Slovakia-S" /> 762 <gsf:metadata name="Slovenia-S" /> 763 <gsf:metadata name="Spain-S" /> 764 <gsf:metadata name="Sweden-S" /> 765 <gsf:metadata name="Switzerland-S" /> 766 <gsf:metadata name="Turkey-S" /> 767 <gsf:metadata name="UnitedKingdom-S" /> 768 <gsf:metadata name="Yugoslavia-S" /> 612 769 613 770 </gsf:headMetaTags> -
main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/js/eurovision.js
r34956 r34960 60 60 if (trans_i < num_countries) { 61 61 var from_country = VotesJSON[trans_i]; 62 63 // map -C and -S to -J for now 64 from_country = from_country.replace(/-C$/,"-J"); 65 from_country = from_country.replace(/-S$/,"-J"); 66 62 67 var from_country_points = gs.documentMetadata[from_country]; 63 68 var year = gs.documentMetadata["Year"]; … … 206 211 function ssq_load(query_text_id) 207 212 { 208 $('#sample-sparql-query'). text($('#'+query_text_id).text().trim());213 $('#sample-sparql-query').val($('#'+query_text_id).text().trim()); 209 214 $('.exec-ssq').hide(); 210 215 $('#exec-'+query_text_id).show(); … … 263 268 function ssv_load(query_text_id) 264 269 { 265 $('#sample-data-sgvizler-query').text($('#'+query_text_id).text().trim()); 270 //$('#sample-data-sgvizler-query').text($('#'+query_text_id).text().trim()); 271 $('#sample-data-sgvizler-query').val($('#'+query_text_id).text().trim()); 266 272 $('.exec-ssq').hide(); 267 273 $('#exec-'+query_text_id).show(); -
main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/prepare/voting-excel/xlsx-fromcountry-jsonmetadata.py
r34910 r34960 122 122 tl_from_country_id = "FromCountry-" + re.sub(r'\s+', '', tl_from_country) + str(tl_year) + "-" + tl_vote_type 123 123 124 vote_mode = xlsxutil.voting_mode(tl_year) 125 nuanced_vote_type = xlsxutil.nuanced_voting_type(tl_from_country,tl_year) 126 124 127 metadata_array.append({"name": "Identifier", "content" : tl_from_country_id}) 125 128 metadata_array.append({"name": "FromCountry", "content" : tl_from_country}) 126 129 metadata_array.append({"name": "FromCountryYear", "content" : tl_year}) 127 130 metadata_array.append({"name": "FromCountryType", "content" : tl_vote_type}) 131 132 metadata_array.append({"name": "FromCountryVoteMode", "content" : vote_mode}) 133 metadata_array.append({"name": "FromCountryNuancedType", "content" : nuanced_vote_type}) 128 134 129 135 for from_country_year_vote in from_country_year_votes: -
main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/prepare/voting-excel/xlsx-tocountry-jsonmetadata.py
r34957 r34960 17 17 jury_from_countries = {} 18 18 tele_from_countries = {} 19 20 19 comb_from_countries = {} 20 sing_from_countries = {} 21 22 # 1997: 23 # Televoting by 24 # Austria, Germany, Sweeden, Switzerland, United Kingdom 25 26 # 1998-2000: Televote, with Jury voting as backup plan 27 28 # 2001-2002: All televote, or 50-50 mix if country so chooses, Jury backup 29 # 2001: Jury: Bosnia & Herzegovina, Turkey, Russia 30 # 2001: Mix: Croatia, Greece, Malta 31 # 32 # 2002: Jury: Bosnia & Herzegovina, Turkey, Russia, FYR Macedonia, Romania 33 # 2002: Mix: Cyprus, Greece, Spain, Croatia, Finland, Malta, Slovenia, Lithuania 34 35 # 2003: back to all Televote, with Jury voting as backup 36 # 2004-2008: same as 2003 37 38 # 2009-2012: Combined, except San Marino which was 100% Jury (due to size), Jury as backup 39 40 # 2013-2015: As before, but how two types of votes combined different 41 42 # 2016- Jury and Tele given separately, added in 43 44 def XXXXvoting_mode(year): 45 46 vote_mode = None 47 48 if (year>=2013): 49 # Separate voting: Jury and Tele 50 vote_mode = "Separated" 51 elif ((year>=2001) and (year<=2012)): 52 vote_mode = "Combined" 53 else: 54 vote_mode = "Single" 55 56 return vote_mode 57 58 59 def XXXXnuanced_voting_type(country,year): 60 61 vote_type = None 62 63 if (year>=2013): 64 # Separate voting: Jury and Tele 65 vote_type = "JT" 66 67 elif ((year>=2009) and (year<=2012)): 68 if (country=="San Marino"): 69 vote_type = "J" 70 else: 71 # Combined Jury and Tele 72 vote_type = "C" 73 elif ((year>=2003) and (year<=2008)): 74 vote_type = "T" 75 elif (year==2002): 76 jury_list = [ "Bosnia & Herzegovina", "Turkey", "Russia", "FYR Macedonia", "Romania"] 77 comb_list = [ "Cyprus", "Greece", "Spain", "Croatia", "Finland", "Malta", "Slovenia", "Lithuania" ] 78 if (country in jury_list): 79 vote_type = "J" 80 elif (country in comb_list): 81 vote_type = "C" 82 else: 83 vote_type = "T" 84 elif (year==2001): 85 jury_list = [ "Bosnia & Herzegovina", "Turkey", "Russia" ] 86 comb_list = [ "Croatia", "Greece", "Malta" ] 87 if (country in jury_list): 88 vote_type = "J" 89 elif (country in comb_list): 90 vote_type = "C" 91 elif ((year>=1998) and (year<=2000)): 92 vote_type = "T" 93 elif (year==1997): 94 tele_list = [ "Austria", "Germany", "Sweeden", "Switzerland", "United Kingdom" ] 95 if (country in tele_list): 96 vote_type = "T" 97 else: 98 vote_type = "J" 99 else: 100 vote_type = "J" 101 102 return vote_type 103 104 105 21 106 def create_to_country_voting_groups(data_hashmap_array): 22 107 … … 68 153 69 154 70 def fileset_voting_for_esc_country_in_year(to_country_year_votes,countrylabel_to_uri_mapping): 155 def create_to_year_then_country_voting_groups(data_hashmap_array): 156 157 # Example values for header-names 158 # (semi-) final: f, sf 159 # Jury or Televoting: J, T 160 # Year: 1975, ... 161 # To country: Belgium 162 # From country: Belgium 163 # Edition: 1975f, 1975sf 164 165 # Build array of year groups 166 # A year group contains within it a country grouping that in turn 167 # includes all the votes that country receive that year 168 year_groups = [] 169 170 # Rely on sorting as done in first line of create_to_country_voting_groups, 171 # which is the (innermost) place where the sorting is needed 172 country_groups = create_to_country_voting_groups(data_hashmap_array) 173 174 prev_to_country_votes = country_groups[0] 175 year_group = [ ] 176 177 i = 1 178 num_rows = len(country_groups) 179 180 while (i < num_rows): 181 year_group.append(prev_to_country_votes) 182 to_country_votes = country_groups[i] 183 184 if (to_country_votes[0].get('Year') != prev_to_country_votes[0].get('Year')): 185 # moving on to a new year group 186 ## print("**** year change from:" + str(to_country_votes[0].get('Year')) + " to " + str(prev_to_country_votes[0].get('Year'))) 187 year_groups.append(year_group) 188 year_group = [ ] 189 190 prev_to_country_votes = to_country_votes 191 i = i + 1 192 193 year_group.append(prev_to_country_votes) 194 year_groups.append(year_group) 195 196 print("****") 197 print("Number of years voting is available for: " + str(len(year_groups))); 198 print("****") 199 200 return year_groups 201 202 203 204 def augment_voting_for_esc_country_in_year(to_country_year_votes,countrylabel_to_uri_mapping): 205 206 jury_metadata_vals = [] 207 tele_metadata_vals = [] 208 comb_metadata_vals = [] 209 sing_metadata_vals = [] 210 211 to_country_jury_total = 0 212 to_country_tele_total = 0 213 to_country_comb_total = 0 214 to_country_sing_total = 0 215 216 to_country_grand_total = 0 217 218 # Use the first record to be a representative for 'top level' (tl) 219 # metadata about the votes cast 'To country' 220 tl_rec = to_country_year_votes[0] 221 222 tl_to_country = tl_rec.get('To country') 223 tl_year = tl_rec.get('Year') 224 tl_final = tl_rec.get("(semi-) final") == "f" 225 226 tl_to_country_id = re.sub(r'\s+', '', tl_to_country) + str(tl_year) 227 228 tl_rec["Final"] = tl_final 229 230 # tl_to_country_lc = tl_to_country.lower() 231 tl_to_country_uri = countrylabel_to_uri_mapping.get(tl_to_country) 232 if (tl_to_country_uri != None): 233 tl_rec["CountryDBURI"] = tl_to_country_uri 234 else: 235 util.eprint("Warning: Failed to find DBpedia Country URI match for: " + tl_to_country) 236 237 for to_country_year_vote in to_country_year_votes: 238 # to_country = to_country_year_vote.get('To country') 239 year = to_country_year_vote.get('Year') 240 from_country = to_country_year_vote.get('From country') 241 vote_type = to_country_year_vote.get('Jury or Televoting') 242 points = to_country_year_vote.get('Points') 243 244 id_from_country = re.sub(r'\s+', '', from_country) 245 246 # tl_rec[id_from_country+"-"+vote_type] = points 247 248 vote_mode = xlsxutil.voting_mode(year) 249 nuanced_vote_type = xlsxutil.nuanced_voting_type(from_country,year) 250 251 if (vote_mode == "Separated"): 252 253 if (vote_type == "J"): 254 jury_metadata_vals.append(id_from_country+"-J") 255 jury_from_countries[id_from_country] = 1 256 to_country_jury_total = to_country_jury_total + points 257 258 elif (vote_type == "T"): 259 tele_metadata_vals.append(id_from_country+"-T") 260 tele_from_countries[id_from_country] = 1 261 to_country_tele_total = to_country_tele_total + points 262 else: 263 util.eprint("Warning: Unrecognized voting type: " + vote_type) 264 265 elif (vote_mode == "Combined"): 266 comb_metadata_vals.append(id_from_country+"-C") 267 comb_from_countries[id_from_country] = 1 268 to_country_comb_total = to_country_comb_total + points 269 else: 270 # Single 271 sing_metadata_vals.append(id_from_country+"-S") 272 sing_from_countries[id_from_country] = 1 273 to_country_sing_total = to_country_sing_total + points 274 275 to_country_grand_total = to_country_grand_total + points 276 277 tl_rec["VoteMode"] = vote_mode 278 279 if (len(jury_metadata_vals)>0): 280 tl_rec["JuryVotesJSON"] = jury_metadata_vals 281 tl_rec["JuryVotesTotal"] = to_country_jury_total 282 if (len(tele_metadata_vals)>0): 283 tl_rec["TeleVotesJSON"] = tele_metadata_vals 284 tl_rec["TeleVotesTotal"] = to_country_tele_total 285 if (len(comb_metadata_vals)>0): 286 tl_rec["CombVotesJSON"] = comb_metadata_vals 287 tl_rec["CombVotesTotal"] = to_country_comb_total 288 if (len(sing_metadata_vals)>0): 289 tl_rec["SingVotesJSON"] = sing_metadata_vals 290 tl_rec["SingVotesTotal"] = to_country_sing_total 291 292 tl_rec["VoteGrandTotal"] = to_country_grand_total 293 294 def fileset_voting_for_esc_country_in_year(to_country_year_votes): 71 295 72 296 # Looking to build data-structure (for output as JSON) in the form … … 89 313 metadata_array = [] 90 314 91 jury_metadata_vals = []92 tele_metadata_vals = []93 94 to_country_jury_total = 095 to_country_tele_total = 0315 # jury_metadata_vals = [] 316 # tele_metadata_vals = [] 317 318 # to_country_jury_total = 0 319 # to_country_tele_total = 0 96 320 97 321 # Use the first record to be a representative for 'top level' (tl) … … 101 325 tl_to_country = tl_rec.get('To country') 102 326 tl_year = tl_rec.get('Year') 103 tl_final = tl_rec.get("(semi-) final") == "f"327 # tl_final = tl_rec.get("(semi-) final") == "f" 104 328 105 329 tl_to_country_id = re.sub(r'\s+', '', tl_to_country) + str(tl_year) 106 330 331 tl_final = tl_rec["Final"] 332 tl_to_country_uri = tl_rec.get("CountryDBURI") 333 334 vote_mode = tl_rec.get("VoteMode") 335 336 jury_metadata_vals = tl_rec.get("JuryVotesJSON") 337 tele_metadata_vals = tl_rec.get("TeleVotesJSON") 338 comb_metadata_vals = tl_rec.get("CombVotesJSON") 339 sing_metadata_vals = tl_rec.get("SingVotesJSON") 340 341 to_country_jury_total = tl_rec.get("JuryVotesTotal") 342 to_country_tele_total = tl_rec.get("TeleVotesTotal") 343 to_country_comb_total = tl_rec.get("CombVotesTotal") 344 to_country_sing_total = tl_rec.get("SingVotesTotal") 345 346 to_country_grand_total = tl_rec.get("VoteGrandTotal") 347 to_country_finishing_pos = tl_rec.get("FinishingPos") 348 107 349 # Country and Year are set as metadata elsewhere so don't need 108 350 # to set them here -- however, do want DBpedia *Country* *URI* … … 115 357 metadata_array.append({ "name": "Final", "content": tl_final }) 116 358 117 # tl_to_country_lc = tl_to_country.lower()118 tl_to_country_uri = countrylabel_to_uri_mapping.get(tl_to_country)359 ## tl_to_country_lc = tl_to_country.lower() 360 #tl_to_country_uri = countrylabel_to_uri_mapping.get(tl_to_country) 119 361 if (tl_to_country_uri != None): 120 362 metadata_array.append({ "name": "CountryDBURI","content": tl_to_country_uri }) 121 else:122 util.eprint("Warning: Failed to find DBpedia Country URI match for: " + tl_to_country)123 363 # else: 364 # util.eprint("Warning: Failed to find DBpedia Country URI match for: " + tl_to_country) 365 124 366 for to_country_year_vote in to_country_year_votes: 125 367 to_country = to_country_year_vote.get('To country') … … 135 377 metadata_array.append(voting_rec) 136 378 137 if (vote_type == "J"): 138 jury_metadata_vals.append(id_from_country+"-J") 139 jury_from_countries[id_from_country] = 1 140 to_country_jury_total = to_country_jury_total + points 141 142 elif (vote_type == "T"): 143 tele_metadata_vals.append(id_from_country+"-T") 144 tele_from_countries[id_from_country] = 1 145 to_country_tele_total = to_country_tele_total + points 146 else: 147 util.eprint("Warning: Unrecognized voting type: " + vote_type) 148 149 if (len(jury_metadata_vals)>0): 379 # if (vote_type == "J"): 380 # jury_metadata_vals.append(id_from_country+"-J") 381 # jury_from_countries[id_from_country] = 1 382 # to_country_jury_total = to_country_jury_total + points 383 # 384 # elif (vote_type == "T"): 385 # tele_metadata_vals.append(id_from_country+"-T") 386 # tele_from_countries[id_from_country] = 1 387 # to_country_tele_total = to_country_tele_total + points 388 # else: 389 # util.eprint("Warning: Unrecognized voting type: " + vote_type) 390 391 metadata_array.append({ "name": "VoteMode", "content": vote_mode }) 392 393 if ((jury_metadata_vals != None) and len(jury_metadata_vals)>0): 150 394 metadata_array.append({ "name": "JuryVotesJSON", "content": json.dumps(jury_metadata_vals) }) 151 395 metadata_array.append({ "name": "JuryVotesTotal", "content": to_country_jury_total}) 152 if ( len(tele_metadata_vals)>0):396 if ((tele_metadata_vals != None) and len(tele_metadata_vals)>0): 153 397 metadata_array.append({ "name": "TeleVotesJSON", "content": json.dumps(tele_metadata_vals) }) 154 398 metadata_array.append({ "name": "TeleVotesTotal", "content": to_country_tele_total}) 155 399 if ((comb_metadata_vals != None) and len(comb_metadata_vals)>0): 400 metadata_array.append({ "name": "CombVotesJSON", "content": json.dumps(comb_metadata_vals) }) 401 metadata_array.append({ "name": "CombVotesTotal", "content": to_country_comb_total}) 402 if ((sing_metadata_vals != None) and len(sing_metadata_vals)>0): 403 metadata_array.append({ "name": "SingVotesJSON", "content": json.dumps(sing_metadata_vals) }) 404 metadata_array.append({ "name": "SingVotesTotal", "content": to_country_sing_total}) 405 406 metadata_array.append({ "name": "VoteGrandTotal", "content": to_country_grand_total}) 407 metadata_array.append({ "name": "FinishingPos", "content": to_country_finishing_pos}) 408 156 409 filename_id = tl_to_country_id + "\\.nul" 157 410 … … 193 446 194 447 for to_country_year_votes in to_country_year_voting_groups: 195 196 fileset = fileset_voting_for_esc_country_in_year(to_country_year_votes,countrylabel_to_uri_mapping) 448 449 augment_voting_for_esc_country_in_year(to_country_year_votes,countrylabel_to_uri_mapping) 450 fileset = fileset_voting_for_esc_country_in_year(to_country_year_votes) 197 451 directory_metadata.append(fileset) 198 452 … … 201 455 202 456 print(" " + filename_id.ljust(28) + ": " + str(num_countries_voting_data) + " votes") 457 458 459 greenstone_metadata_json = { "DirectoryMetadata": directory_metadata } 460 461 return greenstone_metadata_json 462 463 464 465 def augment_voting_in_year_then_country(to_country_year_votes,countrylabel_to_uri_mapping): 466 467 for to_year_votes in to_year_then_country_voting_groups: 468 469 for to_country_year_votes in to_year_votes: 470 471 augment_voting_for_esc_country_in_year(to_country_year_votes,countrylabel_to_uri_mapping) 472 473 474 to_year_votes.sort(key=lambda v: v[0].get("VoteGrandTotal"), reverse=True) 475 to_year_num_votes = len(to_year_votes) 476 for i in range(to_year_num_votes): 477 finishing_pos = i+1 478 to_year_votes[i][0]["FinishingPos"] = finishing_pos 479 480 481 def gs_yc_directory_metadata(to_year_then_country_voting_groups): 482 # Next step is to express the grouped to-country voting data 483 # in the Greenstone JSON metadata format: 484 485 # { "DirectoryMetadata": 486 # [ 487 # { "FileSet": 488 # [ 489 # { "FileName": "France1991\.nul" }, 490 # { "Description": 491 # { 492 # "Metadata": 493 # [ 494 # { "name": "Germany-J", "content": "12" }, # J = Jury Vote 495 # ... 496 # ] 497 # } 498 # } 499 # ] 500 # } 501 # ... 502 # ] 503 # } 504 505 directory_metadata = [] 506 507 for to_year_votes in to_year_then_country_voting_groups: 508 509 for to_country_year_votes in to_year_votes: 510 511 ## augment_voting_for_esc_country_in_year(to_country_year_votes,countrylabel_to_uri_mapping) 512 fileset = fileset_voting_for_esc_country_in_year(to_country_year_votes) 513 directory_metadata.append(fileset) 514 515 filename_id = fileset.get('FileSet')[0].get('FileName') 516 num_countries_voting_data = len(fileset.get('FileSet')[1].get('Description').get('Metadata')) 517 518 print(" " + filename_id.ljust(28) + ": " + str(num_countries_voting_data) + " votes") 203 519 204 520 … … 223 539 print(" <gsf:metadata name=\""+from_country+"-T\" />") 224 540 541 print() 542 for from_country in sorted(comb_from_countries.keys()): 543 print(" <gsf:metadata name=\""+from_country+"-C\" />") 544 545 print() 546 for from_country in sorted(sing_from_countries.keys()): 547 print(" <gsf:metadata name=\""+from_country+"-S\" />") 548 225 549 print(" </gsf:headMetaTags>") 226 550 … … 271 595 272 596 273 to_country_year_voting_groups = create_to_country_voting_groups(data_hashmap_array_filtered) 597 # to_country_year_voting_groups = create_to_country_voting_groups(data_hashmap_array_filtered) 598 to_year_then_country_voting_groups = create_to_year_then_country_voting_groups(data_hashmap_array_filtered) 274 599 275 600 # Debug output 276 601 # 277 # print(to_ country_year_voting_groups)602 # print(to_year_then_country_voting_groups) 278 603 279 604 print() 280 605 print("Generating Greenstone JSON to-country voting metadata received by:") 281 greenstone_metadata_json = gs_directory_metadata(to_country_year_voting_groups,countrylabel_to_uri_mapping) 606 ##greenstone_metadata_json = gs_directory_metadata(to_country_year_voting_groups,countrylabel_to_uri_mapping) 607 augment_voting_in_year_then_country(to_year_then_country_voting_groups,countrylabel_to_uri_mapping) 608 greenstone_metadata_json = gs_yc_directory_metadata(to_year_then_country_voting_groups) 282 609 283 610 print("Saving output as: " + json_output_filename) -
main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/prepare/voting-excel/xlsxutil.py
r34910 r34960 53 53 54 54 55 56 # 1997: 57 # Televoting by 58 # Austria, Germany, Sweeden, Switzerland, United Kingdom 59 60 # 1998-2000: Televote, with Jury voting as backup plan 61 62 # 2001-2002: All televote, or 50-50 mix if country so chooses, Jury backup 63 # 2001: Jury: Bosnia & Herzegovina, Turkey, Russia 64 # 2001: Mix: Croatia, Greece, Malta 65 # 66 # 2002: Jury: Bosnia & Herzegovina, Turkey, Russia, FYR Macedonia, Romania 67 # 2002: Mix: Cyprus, Greece, Spain, Croatia, Finland, Malta, Slovenia, Lithuania 68 69 # 2003: back to all Televote, with Jury voting as backup 70 # 2004-2008: same as 2003 71 72 # 2009-2012: Combined, except San Marino which was 100% Jury (due to size), Jury as backup 73 74 # 2013-2015: As before, but how two types of votes combined different 75 76 # 2016- Jury and Tele given separately, added in 77 78 def voting_mode(year): 79 80 vote_mode = None 81 82 if (year>=2013): 83 # Separate voting: Jury and Tele 84 vote_mode = "Separated" 85 elif ((year>=2001) and (year<=2012)): 86 vote_mode = "Combined" 87 else: 88 vote_mode = "Single" 89 90 return vote_mode 91 92 93 def nuanced_voting_type(country,year): 94 95 vote_type = None 96 97 if (year>=2013): 98 # Separate voting: Jury and Tele 99 vote_type = "JT" 100 101 elif ((year>=2009) and (year<=2012)): 102 if (country=="San Marino"): 103 vote_type = "J" 104 else: 105 # Combined Jury and Tele 106 vote_type = "C" 107 elif ((year>=2003) and (year<=2008)): 108 vote_type = "T" 109 elif (year==2002): 110 jury_list = [ "Bosnia and Herzegovina", "Turkey", "Russia", "FYR Macedonia", "Romania"] 111 comb_list = [ "Cyprus", "Greece", "Spain", "Croatia", "Finland", "Malta", "Slovenia", "Lithuania" ] 112 if (country in jury_list): 113 vote_type = "J" 114 elif (country in comb_list): 115 vote_type = "C" 116 else: 117 vote_type = "T" 118 elif (year==2001): 119 jury_list = [ "Bosnia and Herzegovina", "Turkey", "Russia" ] 120 comb_list = [ "Croatia", "Greece", "Malta" ] 121 if (country in jury_list): 122 vote_type = "J" 123 elif (country in comb_list): 124 vote_type = "C" 125 else: 126 vote_type = "T" 127 elif ((year>=1998) and (year<=2000)): 128 vote_type = "T" 129 elif (year==1997): 130 tele_list = [ "Austria", "Germany", "Sweeden", "Switzerland", "United Kingdom" ] 131 if (country in tele_list): 132 vote_type = "T" 133 else: 134 vote_type = "J" 135 else: 136 vote_type = "J" 137 138 return vote_type 139 140 141 55 142 def load_xslx_sheet(excel_input_filename,sheetname): 56 143 print "Loading: " + excel_input_filename -
main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/transform/pages/document.xsl
r34918 r34960 191 191 192 192 <div id="to-country-votes"> 193 <gsf:switch> 194 <gsf:metadata name='FinishingPos'/> 195 <gsf:when test='exists'> 196 <h2> 197 Overall Final Postion: <gsf:metadata name='FinishingPos'/> 198 </h2> 199 </gsf:when> 200 </gsf:switch> 201 193 202 <gsf:script> 194 203 append_to_country_votes("Jury Votes","JuryVotesJSON","JuryVotesTotal"); 195 204 append_to_country_votes("Televotes","TeleVotesJSON","TeleVotesTotal"); 205 206 append_to_country_votes("Combined Jury & Tele Votes","CombVotesJSON","CombVotesTotal"); 207 append_to_country_votes("Voting Exclusively by Jury","SingVotesJSON","SingVotesTotal"); 196 208 </gsf:script> 197 209 -
main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/transform/pages/sparql.xsl
r34956 r34960 103 103 </textarea> 104 104 105 <div style="display :none;">105 <div style="displayXXXX:none;"> 106 106 <div> 107 107 Output: … … 229 229 ?esc_entrant_uri dc:Relation.isPartOf <http://127.0.0.1:8383/greenstone3/library/collection/eurovision>. 230 230 231 ?esc_entrant_uri gsextracted: JuryVotesTotal ?total.231 ?esc_entrant_uri gsextracted:SingVotesTotal ?total. 232 232 BIND(xsd:integer(?total) AS ?total_int). 233 233 … … 268 268 </xsl:text> 269 269 </div> 270 271 272 <div id="ssq-winning-totals" style="display: none;"> 273 <!-- --> 274 <xsl:text> 275 PREFIX gsextracted: <http://greenstone.org/gsextracted#> 276 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 277 PREFIX dc: <http://purl.org/dc/elements/1.1/> 278 279 280 SELECT ?year ?country ?total_max WHERE { 281 GRAPH <http://localhost:3030/greenstone/data/eurovision> { 282 283 { 284 SELECT ?year (STR(MAX(?total_int_inner)) as ?total_max) WHERE { 285 286 ?esc_entrant_uri gsextracted:VoteGrandTotal ?total. 287 BIND(xsd:integer(?total) AS ?total_int_inner). 288 289 ?esc_entrant_uri gsextracted:Year ?year. 290 } 291 GROUP BY ?year 292 } 293 294 ?esc_entrant_uri gsextracted:VoteGrandTotal ?total_max. 295 ?esc_entrant_uri gsextracted:Year ?year. 296 ?esc_entrant_uri gsextracted:Country ?country. 297 298 BIND(xsd:integer(?total_max) as ?total_int). 299 } 300 } 301 ORDER BY DESC(?total_int) 302 </xsl:text> 303 </div> 304 305 306 <div id="ssq-winning-freq-count" style="display: none;"> 307 <!-- --> 308 <xsl:text> 309 310 PREFIX gsextracted: <http://greenstone.org/gsextracted#> 311 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 312 PREFIX dc: <http://purl.org/dc/elements/1.1/> 313 314 315 SELECT ?country (STR(COUNT(?country)) as ?number_of_vote_wins) WHERE { 316 GRAPH <http://localhost:3030/greenstone/data/eurovision> { 317 318 319 { 320 SELECT ?year (STR(MAX(?total_int)) as ?total_max) WHERE { 321 322 323 ?esc_entrant_uri gsextracted:VoteGrandTotal ?total. 324 BIND(xsd:integer(?total) AS ?total_int). 325 326 ?esc_entrant_uri gsextracted:Year ?year. 327 } 328 GROUP BY ?year 329 } 330 331 ?esc_entrant_uri gsextracted:VoteGrandTotal ?total_max. 332 ?esc_entrant_uri gsextracted:Year ?year. 333 ?esc_entrant_uri gsextracted:Country ?country. 334 } 335 } 336 GROUP BY ?country 337 ORDER BY DESC(?number_of_vote_wins) 338 </xsl:text> 339 </div> 340 341 270 342 271 343 … … 350 422 351 423 <li> 352 JuryVoting Totals in 1975:<br/>424 Voting Totals in 1975:<br/> 353 425 <button type="button" class="load-ssq" id="load-ssq-jury-votes-totals-1975" onclick="ssq_load('ssq-jury-votes-totals-1975')">Load query above</button> 354 426 <button type="button" class="exec-ssq" id="exec-ssq-jury-votes-totals-1975" onclick="ssq_execute()">Get Results</button><br/> 355 427 356 The jury vote totals countries received in 1975, ranked to score. 428 In 1975 all voting was done exclusively by jury. This query retrieves the 429 totals of this Single voting format, and orders them by that score. 357 430 </li> 358 431 … … 365 438 </li> 366 439 440 441 <li> 442 Most points won:<br/> 443 <button type="button" class="load-ssq" id="load-ssq-winning-totals" onclick="ssq_load('ssq-winning-totals')">Load query above</button> 444 <button type="button" class="exec-ssq" id="exec-ssq-winning-totals" onclick="ssq_execute()">Get Results</button><br/> 445 446 List the coutries which won and their voting totals, sorted by total score. 447 </li> 448 449 <li> 450 Number of Times Countries Have Won:<br/> 451 <button type="button" class="load-ssq" id="load-ssq-winning-freq-count" onclick="ssq_load('ssq-winning-freq-count')">Load query above</button> 452 <button type="button" class="exec-ssq" id="exec-ssq-winning-freq-count" onclick="ssq_execute()">Get Results</button><br/> 453 454 The number of times a country has won Eurovision across the years. The includes 455 the years when only Juries voted (1956-2000) through to the introduction 456 of Televotes, where a variety of forms have been used such as only 457 Televotes, a pre-combined score based on Televotes and Jury votes, to 458 (from 2016 onwards) where the Jury and Tele votes are explicitly 459 given individually per country, then combined. 460 </li> 461 462 367 463 <li> 368 464 Facts and Figures About Competing Countries:<br/> … … 374 470 375 471 </ul> 472 473 <p> 474 Looking for something a bit more visual? Why not head over to our 475 <a href="{$library_name}/collection/{$collName}/page/sgvizler"><i>SGVizler page</i></a> and try the SPARQL-based visualization samples there. 476 </p> 376 477 377 478 </div>
Note:
See TracChangeset
for help on using the changeset viewer.