Skip to content

Commit

Permalink
Merge pull request #83 from philip-schrodt/master
Browse files Browse the repository at this point in the history
Trapped and logged unicode error in make_event_strings()
  • Loading branch information
Philip Schrodt committed May 25, 2015
2 parents 45b9bcc + ce45956 commit fb7f7c5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions petrarch/petrarch.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2482,10 +2482,17 @@ def expand_compound_codes(codelist):

logger = logging.getLogger('petr_log')
# print('MES1: ',SourceLoc, TargetLoc)
srccodes = get_loccodes(SourceLoc)
expand_compound_codes(srccodes)
tarcodes = get_loccodes(TargetLoc)
expand_compound_codes(tarcodes)
# p.a.s. 15.05.25: For reasons that were far from obvious, this was generating some errors that supposedly involved UniCode problems
# on some records that had been converted from the Levant Reuters series. Maybe the actual issues are in the dictionaries?
# Anyway, just trap and log it for now.
try:
srccodes = get_loccodes(SourceLoc)
expand_compound_codes(srccodes)
tarcodes = get_loccodes(TargetLoc)
expand_compound_codes(tarcodes)
except:
logger.warning('Error when attempting to extract src and tar codes in make_event_strings(): {}'.format(SentenceID))
return

#TODO: This needs to be fixed: this is the placeholder code for having a general country-
# level location for the sentence or story
Expand Down

0 comments on commit fb7f7c5

Please sign in to comment.