Created
November 9, 2017 23:45
-
-
Save dyerrington/162fb77a645783f31269eed948419429 to your computer and use it in GitHub Desktop.
Copy and paste from a student project, find extracted scores in a convenient location.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ipywidgets as widgets | |
from IPython.display import clear_output, display | |
import re | |
raw_review = widgets.Textarea( | |
value='', | |
placeholder='Paste review text here', | |
layout=widgets.Layout(width='50%', height='80px'), | |
) | |
button = widgets.Button( | |
description='Get Scores!', | |
disabled=False, | |
button_style='', # 'success', 'info', 'warning', 'danger' or '' | |
tooltip='Click me', | |
icon='check', | |
layout=widgets.Layout(width='50%', height='80px') | |
) | |
def get_widget(): | |
display(widgets.VBox([raw_review, button])) | |
def parse_review(b): | |
exp = re.compile("[^(]+\(([^)]+)\)") | |
#print("Button clicked.", raw_review.value) | |
lines = raw_review.value.split("\n") | |
print([exp.match(line).group(1) for line in lines if "Our Rating for your response:" in line]) | |
out = widgets.Output() | |
button.on_click(parse_review) | |
display(widgets.VBox([raw_review, button])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment