def _compute_group_stats(): """ Computes group statistics for the WMT13 evaluation campaign. """ group_stats = [] wmt13 = Group.objects.get(name='WMT13') users = wmt13.user_set.all() # Aggregate information about participating groups. groups = set() for user in users: for group in user.groups.all(): if group.name == 'WMT13' or group.name.startswith('eng2') \ or group.name.endswith('2eng'): continue groups.add(group) # The following dictionary defines the number of HITs each group should # have completed during the WMT13 evaluation campaign. group_hit_requirements = {'BALAGUR': 200, 'CMU': 300, 'CU': 1700, 'DCU': 300, 'DESRT': 100, 'FDA': 300, 'ITS-LATL': 200, 'JHU': 900, 'KIT': 400, 'LIA': 200, 'LIMSI': 600, 'MES': 1400, 'OMNIFLUENT': 400, 'Prompsit': 400, 'PROMT': 500, 'QUAERO': 100, 'RWTH': 400, 'SHEF': 700, 'STANFORD': 200, 'TALP': 100, 'TUBITAK': 200, 'UCAM': 100, 'UEDIN': 1700, 'UMD': 200, 'UU': 100, 'DFKI': 0, 'USAAR': 0} for group in groups: _name = group.name if not _name in group_hit_requirements.keys(): continue _group_stats = HIT.compute_status_for_group(group) _total = _group_stats[0] _required = group_hit_requirements[_name] _delta = _total - _required _data = (_total, _required, _delta) if _data[0] > 0: group_stats.append((_name, _data)) # Sort by number of remaining HITs. group_stats.sort(key=lambda x: x[1][2]) return group_stats
def overview(request): """ Renders the evaluation tasks overview. """ LOGGER.info('Rendering WMT13 HIT overview for user "{0}".'.format(request.user.username or "Anonymous")) # Re-initialise random number generator. seed(None) # Collect available language pairs for the current user. language_codes = set([x[0] for x in LANGUAGE_PAIR_CHOICES]) language_pairs = request.user.groups.filter(name__in=language_codes) hit_data = [] total = [0, 0, 0] for language_pair in language_pairs: hit = _compute_next_task_for_user(request.user, language_pair) status = HIT.compute_status_for_user(request.user, language_pair) for i in range(3): total[i] = total[i] + status[i] if hit: # Convert status seconds back into datetime.time instances. for i in range(2): status[i + 1] = seconds_to_timedelta(int(status[i + 1])) hit_data.append((hit.get_language_pair_display(), hit.get_absolute_url(), hit.block_id, status)) # Convert total seconds back into datetime.time instances. for i in range(2): total[i + 1] = seconds_to_timedelta(int(total[i + 1])) group = None for _group in request.user.groups.all(): if _group.name == "WMT13" or _group.name.startswith("eng2") or _group.name.endswith("2eng"): continue group = _group break if group is not None: group_name = group.name group_status = HIT.compute_status_for_group(group) for i in range(2): group_status[i + 1] = seconds_to_timedelta(int(group_status[i + 1])) else: group_status = None group_name = None LOGGER.debug( u'\n\nHIT data for user "{0}":\n\n{1}\n'.format( request.user.username or "Anonymous", u"\n".join([u"{0}\t{1}\t{2}\t{3}".format(*x) for x in hit_data]) ) ) dictionary = { "active_page": "OVERVIEW", "commit_tag": COMMIT_TAG, "hit_data": hit_data, "total": total, "group_name": group_name, "group_status": group_status, "title": "WMT13 Dashboard", } return render(request, "wmt13/overview.html", dictionary)
def overview(request): """ Renders the evaluation tasks overview. """ LOGGER.info('Rendering WMT13 HIT overview for user "{0}".'.format( request.user.username or "Anonymous")) # Re-initialise random number generator. seed(None) # Collect available language pairs for the current user. language_codes = set([x[0] for x in LANGUAGE_PAIR_CHOICES]) language_pairs = request.user.groups.filter(name__in=language_codes) hit_data = [] total = [0, 0, 0] for language_pair in language_pairs: hit = _compute_next_task_for_user(request.user, language_pair) user_status = HIT.compute_status_for_user(request.user, language_pair) for i in range(3): total[i] = total[i] + user_status[i] if hit: # Convert status seconds back into datetime.time instances. for i in range(2): user_status[i+1] = seconds_to_timedelta(int(user_status[i+1])) hit_data.append( (hit.get_language_pair_display(), hit.get_absolute_url(), hit.block_id, user_status) ) # Convert total seconds back into datetime.timedelta instances. total[1] = seconds_to_timedelta(int(total[2]) / float(int(total[0]) or 1)) # Remove microseconds to get a nicer timedelta rendering in templates. total[1] = total[1] - timedelta(microseconds=total[1].microseconds) total[2] = seconds_to_timedelta(int(total[2])) group = None for _group in request.user.groups.all(): if _group.name == 'WMT13' \ or _group.name.startswith('eng2') \ or _group.name.endswith('2eng'): continue group = _group break if group is not None: group_name = group.name group_status = HIT.compute_status_for_group(group) for i in range(2): group_status[i+1] = seconds_to_timedelta(int(group_status[i+1])) else: group_status = None group_name = None LOGGER.debug(u'\n\nHIT data for user "{0}":\n\n{1}\n'.format( request.user.username or "Anonymous", u'\n'.join([u'{0}\t{1}\t{2}\t{3}'.format(*x) for x in hit_data]))) dictionary = { 'active_page': "OVERVIEW", 'commit_tag': COMMIT_TAG, 'hit_data': hit_data, 'total': total, 'group_name': group_name, 'group_status': group_status, 'title': 'WMT13 Dashboard', } return render(request, 'wmt13/overview.html', dictionary)