Beispiel #1
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
Beispiel #2
0
            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 '[{0}]'.format(_hits_file)
        print 'Successfully imported {0} HITs, encountered errors for ' \
          '{1} HITs.'.format(_total, _errors)
        print