albertvillanova / WikidataBot

Wikidata bot
http://www.wikidata.org/wiki/User:AVMbot
0 stars 0 forks source link

[scripts] transfer_infotable crashes with KeyError #46

Closed albertvillanova closed 4 years ago

albertvillanova commented 4 years ago
2020-03-02 20:47:23,921 [    INFO] Parse position qualifier: final: ?
2020-03-02 20:47:23,922 [    INFO] Parse date
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in <module>
   1167         positions = extract_positions(infotable_params)
   1168         logger.info(f"Positions: {positions}")
-> 1169         position_statements = create_position_statements(positions)
   1170         if position_statements:
   1171             # Get item

~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in create_position_statements(positions)
    929     # Parse each position
    930     for position in positions:
--> 931         position_claim, qualifiers = parse_position(position)
    932         if not position_claim:
    933             # 1. Create the maximum number of statements

~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in parse_position(position)
    881         # rest
    882         elif position_key in INFOTABLE_PARAMS:
--> 883             qualifier_claim = parse_position_qualifier(position_key, position_value)
    884         else:
    885             logger.error(f"Unknown position qualifier key, value: {position_key}; {position_value}")

~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in parse_position_qualifier(key, value, position_value_id)
    753             return 'CONTINUE'
    754         # Date
--> 755         claim_value = parse_date(value)
    756     elif key == 'predecessor' or key == 'successor':
    757         if value == "-":

~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in parse_date(value)
    551         logger.error(f"Failed parsing date: {value}")
    552         return
--> 553     date_parts = [int(part) if part.isdigit() else TO_MONTH_NUMBER[part] for part in date_parts]
    554     claim_value = {k: v for k, v in zip(['year', 'month', 'day'], date_parts)}
    555     return claim_value

~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in <listcomp>(.0)
    551         logger.error(f"Failed parsing date: {value}")
    552         return
--> 553     date_parts = [int(part) if part.isdigit() else TO_MONTH_NUMBER[part] for part in date_parts]
    554     claim_value = {k: v for k, v in zip(['year', 'month', 'day'], date_parts)}
    555     return claim_value

KeyError: '?'
albertvillanova commented 4 years ago

wikipedia:ca:Aelfwald II de Northúmbria

2020-03-03 00:07:41,249 [    INFO] Parse position qualifier: final: ''c.'' 810
2020-03-03 00:07:41,249 [    INFO] Parse date
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in <module>
   1179         positions = extract_positions(infotable_params)
   1180         logger.info(f"Positions: {positions}")
-> 1181         position_statements = create_position_statements(positions)
   1182         if position_statements:
   1183             # Get item

~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in create_position_statements(positions)
    939     # Parse each position
    940     for position in positions:
--> 941         position_claim, qualifiers = parse_position(position)
    942         if not position_claim:
    943             # 1. Create the maximum number of statements

~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in parse_position(position)
    891         # rest
    892         elif position_key in INFOTABLE_PARAMS:
--> 893             qualifier_claim = parse_position_qualifier(position_key, position_value)
    894         else:
    895             logger.error(f"Unknown position qualifier key, value: {position_key}; {position_value}")

~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in parse_position_qualifier(key, value, position_value_id)
    763             return 'CONTINUE'
    764         # Date
--> 765         claim_value = parse_date(value)
    766     elif key == 'predecessor' or key == 'successor':
    767         if value == "-":

~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in parse_date(value)
    558         logger.error(f"Failed parsing date: {value}")
    559         return
--> 560     date_parts = [int(part) if part.isdigit() else TO_MONTH_NUMBER[part] for part in date_parts]
    561     claim_value = {k: v for k, v in zip(['year', 'month', 'day'], date_parts)}
    562     return claim_value

~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in <listcomp>(.0)
    558         logger.error(f"Failed parsing date: {value}")
    559         return
--> 560     date_parts = [int(part) if part.isdigit() else TO_MONTH_NUMBER[part] for part in date_parts]
    561     claim_value = {k: v for k, v in zip(['year', 'month', 'day'], date_parts)}
    562     return claim_value

KeyError: "''c.''"