Esempio n. 1
0
def _compute_user_stats():
    """
    Computes user statistics for the WMT13 evaluation campaign.
    """
    user_stats = []
    wmt13 = Group.objects.get(name='WMT13')
    users = wmt13.user_set.all()
    
    for user in users:
        _user_stats = HIT.compute_status_for_user(user)
        _name = user.username
        _avg_time = seconds_to_timedelta(_user_stats[1])
        _total_time = seconds_to_timedelta(_user_stats[2])
        _data = (_name, _user_stats[0], _avg_time, _total_time)
        
        if _data[0] > 0:
            user_stats.append(_data)
    
    # Sort by total number of completed HITs.
    user_stats.sort(key=lambda x: x[1])
    user_stats.reverse()
    
    # Only show top 25 contributors.
    user_stats = user_stats[:25]
    
    return user_stats
Esempio n. 2
0
def _compute_language_pair_stats():
    """
    Computes HIT statistics per language pair.
    """
    language_pair_stats = []
    
    for choice in LANGUAGE_PAIR_CHOICES:
        _code = choice[0]
        _name = choice[1]
        _remaining_hits = HIT.compute_remaining_hits(language_pair=_code)
        _total_hits = 0
        _completed_hits = 0
        
        for hit in HIT.objects.filter(active=True, mturk_only=False,
          language_pair=_code):
            _total_hits = _total_hits + 1
            # Again: we now consider a HIT to be completed once it has been
            # annotated by one or more annotators.
            #
            # Before we required `hit.users.count() >= 3` for gr
            if hit.users.all().count() >= 1:
                _completed_hits = _completed_hits + 1
        
        # _data = (_remaining_hits, _completed_hits, _total_hits)
        
        _data = (
          _name,
          (_remaining_hits, 100 * _remaining_hits/float(_total_hits or 1)),
          (_completed_hits, 100 * _completed_hits/float(_total_hits or 1))
        )
        
        language_pair_stats.append(_data)
    
    return language_pair_stats
Esempio n. 3
0
def status(request):
    """
    Renders the status overview.
    """
    LOGGER.info('Rendering WMT13 HIT status for user "{0}".'.format(request.user.username or "Anonymous"))

    # Compute some global stats.
    global_stats = []
    wmt13 = Group.objects.get(name="WMT13")
    users = wmt13.user_set.all()

    # Check how many HITs have been completed.
    hits_completed = 0
    for hit in HIT.objects.all():
        if hit.users.count() >= 3:
            hits_completed = hits_completed + 1

    # Compute remaining HITs for all language pairs.
    hits_remaining = HIT.compute_remaining_hits()

    # Compute number of results contributed so far.
    ranking_results = RankingResult.objects.all().count()

    # 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)

    # Compute average/total duration over all results.
    durations = RankingResult.objects.all().values_list("duration", flat=True)
    total_time = sum([datetime_to_seconds(x) for x in durations])
    avg_time = total_time / float(hits_completed or 1)

    global_stats.append(("Users", users.count()))
    global_stats.append(("Groups", len(groups)))
    global_stats.append(("HITs completed", hits_completed))
    global_stats.append(("HITs remaining", hits_remaining))
    global_stats.append(("Ranking results", ranking_results))
    global_stats.append(("System comparisons", 10 * ranking_results))
    global_stats.append(("Average duration", seconds_to_timedelta(avg_time)))
    global_stats.append(("Total duration", seconds_to_timedelta(total_time)))

    dictionary = {
        "active_page": "STATUS",
        "global_stats": global_stats,
        "commit_tag": COMMIT_TAG,
        "title": "WMT13 Status",
    }

    return render(request, "wmt13/status.html", dictionary)
Esempio n. 4
0
def _compute_global_stats():
    """
    Computes some global statistics for the WMT13 evaluation campaign.
    """
    global_stats = []
    wmt13 = Group.objects.get(name='WMT13')
    users = wmt13.user_set.all()
    
    # Check how many HITs have been completed.  We now consider a HIT to be
    # completed once it has been annotated by one or more annotators.
    #
    # Before we required `hit.users.count() >= 3` for greater overlap.
    hits_completed = 0
    for hit in HIT.objects.filter(active=True, mturk_only=False):
        if hit.users.count() >= 1:
            hits_completed = hits_completed + 1
    
    # Compute remaining HITs for all language pairs.
    hits_remaining = HIT.compute_remaining_hits()
    
    # Compute number of results contributed so far.
    ranking_results = RankingResult.objects.filter(
      item__hit__active=True, item__hit__mturk_only=False).count()
    
    # 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)
    
    # Compute average/total duration over all results.
    durations = RankingResult.objects.all().values_list('duration', flat=True)
    total_time = sum([datetime_to_seconds(x) for x in durations])
    avg_time = total_time / float(hits_completed or 1)
    avg_user_time = total_time / float(3 * hits_completed or 1)
    
    global_stats.append(('Users', users.count()))
    global_stats.append(('Groups', len(groups)))
    global_stats.append(('HITs completed', hits_completed))
    global_stats.append(('HITs remaining', hits_remaining))
    global_stats.append(('Ranking results', ranking_results))
    global_stats.append(('System comparisons', 10 * ranking_results))
    global_stats.append(('Average duration', seconds_to_timedelta(avg_time)))
    global_stats.append(('Average duration (single user)',
      seconds_to_timedelta(avg_user_time)))
    global_stats.append(('Total duration', seconds_to_timedelta(total_time)))
    
    return global_stats
Esempio n. 5
0
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
Esempio n. 6
0
 Author: Christian Federmann <*****@*****.**>

usage: export_wmt13_status.py

Exports HIT status for all language pairs.

"""
from datetime import datetime
import os
import sys

if __name__ == "__main__":
    # Properly set DJANGO_SETTINGS_MODULE environment variable.
    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
    PROJECT_HOME = os.path.normpath(os.getcwd() + "/..")
    sys.path.append(PROJECT_HOME)

    # We have just added appraise to the system path list, hence this works.
    from appraise.wmt13.models import HIT, LANGUAGE_PAIR_CHOICES

    remaining_hits = {}
    for language_pair in [x[0] for x in LANGUAGE_PAIR_CHOICES]:
        remaining_hits[language_pair] = HIT.compute_remaining_hits(
            language_pair=language_pair)

    print
    print '[{0}]'.format(datetime.now().strftime("%c"))
    for k, v in remaining_hits.items():
        print '{0}: {1:03d}'.format(k, v)
    print
Esempio n. 7
0
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)
Esempio n. 8
0
        
        # Hotfix potentially wrong ISO codes;  we are using ISO-639-3.
        iso_639_2_to_3_mapping = {'cze': 'ces', 'fre': 'fra', 'ger': 'deu'}
        for part2_code, part3_code in iso_639_2_to_3_mapping.items():
            language_pair = language_pair.replace(part2_code, part3_code)
        
        try:
            _total = _total + 1
            _hit_xml = tostring(_child, encoding="utf-8").decode('utf-8')
            
            if args.dry_run_enabled:
                _ = HIT(block_id=block_id, hit_xml=_hit_xml,
                  language_pair=language_pair, mturk_only=args.mturk_only)
            
            else:
                # Use get_or_create() to avoid exact duplicates.  We do allow
                # them for WMT13 to measure intra-annotator agreement...
                h = HIT(block_id=block_id, hit_xml=_hit_xml,
                  language_pair=language_pair, mturk_only=args.mturk_only)
                h.save()
        
        # pylint: disable-msg=W0703
        except Exception, msg:
            print msg
            _errors = _errors + 1
    
    print
    print 'Successfully imported {0} HITs, encountered errors for ' \
      '{1} HITs.'.format(_total, _errors)
    print
Esempio n. 9
0
usage: export_wmt13_status.py

Exports HIT status for all language pairs.

"""
from datetime import datetime
import os
import sys


if __name__ == "__main__":
    # Properly set DJANGO_SETTINGS_MODULE environment variable.
    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
    PROJECT_HOME = os.path.normpath(os.getcwd() + "/..")
    sys.path.append(PROJECT_HOME)
    
    # We have just added appraise to the system path list, hence this works.
    from appraise.wmt13.models import HIT, LANGUAGE_PAIR_CHOICES
    
    remaining_hits = {}
    for language_pair in [x[0] for x in LANGUAGE_PAIR_CHOICES]:
        remaining_hits[language_pair] = HIT.compute_remaining_hits(
          language_pair=language_pair)
    
    print
    print '[{0}]'.format(datetime.now().strftime("%c"))
    for k, v in remaining_hits.items():
        print '{0}: {1:03d}'.format(k, v)
    print
Esempio n. 10
0
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)
Esempio n. 11
0
            block_id = _child.attrib["block-id"]
            language_pair = '{0}2{1}'.format(_child.attrib["source-language"],
                                             _child.attrib["target-language"])

            # Hotfix potentially wrong ISO codes;  we are using ISO-639-3.
            iso_639_2_to_3_mapping = {'cze': 'ces', 'fre': 'fra', 'ger': 'deu'}
            for part2_code, part3_code in iso_639_2_to_3_mapping.items():
                language_pair = language_pair.replace(part2_code, part3_code)

            try:
                _total = _total + 1
                _hit_xml = tostring(_child, encoding="utf-8").decode('utf-8')

                if args.dry_run_enabled:
                    _ = HIT(block_id=block_id,
                            hit_xml=_hit_xml,
                            language_pair=language_pair,
                            mturk_only=args.mturk_only)

                else:
                    # Use get_or_create() to avoid exact duplicates.  We do allow
                    # them for WMT13 to measure intra-annotator agreement...
                    h = HIT(block_id=block_id,
                            hit_xml=_hit_xml,
                            language_pair=language_pair,
                            mturk_only=args.mturk_only)
                    h.save()

            # pylint: disable-msg=W0703
            except Exception, msg:
                print msg
                _errors = _errors + 1