I am facing an issue in the following piece of code. Basically what I am trying to do here is I am trying to check for particular phrases that are present in my data which is OCR'd from an image. I cannot share the image because of reasons. I get error "Backend TkAgg is interactive backend. Turning interactive mode on" while I try to debug the code. But I get normal exception error when run.
imgH = imageShape[0]
imgW = imageShape[1]
imgWx = int(float(imgW*.5))
wordRatio = []
SUBJECTEXISTS = False
dictMatch = defaultdict(str)
try:
for pattern in patterns:
for word in pattern:
if (len(word.text))>3:
wordStripped = re.sub(r'[^\w\s]', '', word.text.lower())
# if int(float(word.x0))<=imgWx:
for subject in subjectList:
if wordStripped in subject.lower():
if Levenshtein.ratio(wordStripped,subject.lower())>.5 and wordStripped not in transcript_exclusion:
SUBJECTEXISTS = True
break
except:
for word in patterns:
if SUBJECTEXISTS:
break
if (len(word.text)) > 3:
wordStripped = re.sub(r'[^\w\s]', '', word.text.lower())
# if int(float(word.x0))<=imgWx:
for subject in subjectList:
if wordStripped in subject.lower():
if Levenshtein.ratio(wordStripped,
subject.lower()) > .5 and wordStripped not in transcript_exclusion:
# print("The word: ",wordStripped)
lineValue = imageInfo[int(word.lineId)-1]
wordsList = lineValue.text.lower().split()
wordIdx = wordsList.index(wordStripped)
if 'accounting' in wordStripped:
pass
try:
if wordStripped in lineValue.text.lower() and 'in' in wordsList[wordIdx-1]:
pass
else:
SUBJECTEXISTS = True
break
except:
SUBJECTEXISTS = True
break
I think the error lies within the usage of break statements below SUBJECTEXISTS. Should I be concerned with this or is it just like a warning? Also I am using Pycharm IDE Does anyone have any idea what the error is?