152 lines
3.6 KiB
Plaintext
152 lines
3.6 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Manual Tagger Tool"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import ipywidgets as widgets"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "c7413a7a695a4770a65e4da2b6e11899",
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
},
|
|
"text/plain": [
|
|
"ToggleButtons(options=('Slow', 'Regular', 'Fast', 'Slow', 'Regular', 'Fast', 'Slow', 'Regular', 'Fast', 'Slow'…"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"\n",
|
|
"\n",
|
|
"widgets.ToggleButtons(\n",
|
|
" options=['Slow', 'Regular', 'Fast','Slow', 'Regular', 'Fast','Slow', 'Regular', 'Fast','Slow', 'Regular', 'Fast','Slow', 'Regular', 'Fast'],\n",
|
|
" disabled=False,\n",
|
|
" button_style='',#'success', #, 'info', 'warning', 'danger' or ''\n",
|
|
" tooltips=['Description of slow', 'Description of regular', 'Description of fast'],\n",
|
|
"# icons=['check'] * 3\n",
|
|
")\n",
|
|
"\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"food_labels = ['0','action','ingredient','tool','container']"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 44,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"def create_label_layout_for_sent(sentence, labels):\n",
|
|
" assert len(sentence) == len(labels)\n",
|
|
" n = len(labels)\n",
|
|
" \n",
|
|
" token_containers = []\n",
|
|
" label_containers = []\n",
|
|
" \n",
|
|
" style = widgets.ToggleButtonsStyle()\n",
|
|
" style.button_width = \"80px\"\n",
|
|
" \n",
|
|
" for i in range(n):\n",
|
|
" text = widgets.Label(sentence[i])\n",
|
|
" label = widgets.ToggleButtons(options=food_labels, style=style)\n",
|
|
" label.value = labels[i]\n",
|
|
" \n",
|
|
" label_containers.append(label)\n",
|
|
" \n",
|
|
" token_containers.append(widgets.VBox([text,label]))\n",
|
|
" \n",
|
|
" \n",
|
|
" main_container = widgets.HBox(token_containers)\n",
|
|
" \n",
|
|
" display(main_container)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### single sentence test"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 46,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "3806cdff0a0c4984a1aadfc94f8229df",
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
},
|
|
"text/plain": [
|
|
"HBox(children=(VBox(children=(Label(value='this'), ToggleButtons(options=('0', 'action', 'ingredient', 'tool',…"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"create_label_layout_for_sent([\"this\", \"is\", \"a\", \"very\", \"very\", \"very\", \"long\", \"sentence\"], [\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"ingredient\"])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.7.3"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|