Skip to content

Commit

Permalink
Merge pull request #84 from philip-schrodt/master
Browse files Browse the repository at this point in the history
Trapped and logged a tuple error in find_target(): tuple is occurring…
  • Loading branch information
Philip Schrodt committed May 28, 2015
2 parents fb7f7c5 + 48f939b commit 76ccdbf
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions petrarch/petrarch.py
Expand Up @@ -1312,7 +1312,10 @@ def find_target():
"""

global UpperSeq, LowerSeq, SourceLoc, TargetLoc
srccodelist = get_loccodes(SourceLoc)
try:
srccodelist = get_loccodes(SourceLoc)
except:
raise_ParseList_error('tuple error in get_loccodes(SourceLoc) called from find_target()')
if len(srccodelist) == 1:
srccode = '>' + srccodelist[0]
else:
Expand Down Expand Up @@ -2482,16 +2485,16 @@ def expand_compound_codes(codelist):

logger = logging.getLogger('petr_log')
# print('MES1: ',SourceLoc, TargetLoc)
# 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.
# p.a.s. 15.05.25: get_loccodes was generating the error "need string or buffer, tuple found" on some records that had been
# converted from the Levant Reuters series; which also occurred around line 1315 on a different record. For the time being,
# just trap and log it.
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))
logger.warning('tuple 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-
Expand Down

0 comments on commit 76ccdbf

Please sign in to comment.