Skip to content

Instantly share code, notes, and snippets.

@vickyg3
Created August 8, 2011 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vickyg3/1132361 to your computer and use it in GitHub Desktop.
Save vickyg3/1132361 to your computer and use it in GitHub Desktop.
Result Evaluation
percent = re.compile(r'([0-9]+)\%of([0-9]+)')
question = os.popen("./ocr.sh %s" % filename).read()
if '+' not in question and '-' not in question and '/' not in question and '*' not in question and '%' not in question and 'i' not in question:
result = int(question[0:-1]) * int(question[0:-1])
elif '%' in question:
result = int(percent.search(question).group(1)) * int(percent.search(question).group(2)) / 100;
else:
result = eval(question)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment