Changeset 35105 for main


Ignore:
Timestamp:
2021-04-23T11:06:01+12:00 (3 years ago)
Author:
davidb
Message:

Introduction of addition metadata field that represents 'reverse place'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/prepare/errata-categories/esc-wikipedia-download-and-process-votes.py

    r35032 r35105  
    1717import escwikipedia
    1818
     19   
     20def generate_reverse_finishing_pos_metadata(country_year_recs):
    1921
     22    country_year_recs_len = len(country_year_recs)
     23
     24    for country_year_key in country_year_recs.keys():
     25        country_year_rec = country_year_recs.get(country_year_key)
     26
     27        place = int(country_year_rec.get("Place"))
     28        rev_place = country_year_recs_len - place + 1
     29
     30        country_year_rec["ReversePlace"] = str(rev_place)
     31               
     32        country_year_rec["FinishingPos"] = str(place)
     33        country_year_rec["ReverseFinishingPos"] = str(rev_place)
     34
     35       
    2036def gs_fileset_country_in_year(country_year_name, country_year_rec, nul_output_dir_name):
    2137
     
    152168                                                              stop_at_first=True,
    153169                                                              extra_metadata={"Final": True})
    154 
     170        if (year > 1956):
     171            # skip inaugural year, as only known who was 1st
     172            # everyone else listed as 2nd, and given that there are
     173            # two entrants per countries the reversing step generates
     174            # (while technically correct) rather weird looking vals
     175            generate_reverse_finishing_pos_metadata(country_year_recs)
    155176
    156177        all_country_year_recs.append(country_year_recs)
Note: See TracChangeset for help on using the changeset viewer.