minor fixes
This commit is contained in:
		| @ -11,9 +11,31 @@ | |||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": null, |    "execution_count": 1, | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [ | ||||||
|  |     { | ||||||
|  |      "name": "stderr", | ||||||
|  |      "output_type": "stream", | ||||||
|  |      "text": [ | ||||||
|  |       "Using TensorFlow backend.\n" | ||||||
|  |      ] | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |      "name": "stdout", | ||||||
|  |      "output_type": "stream", | ||||||
|  |      "text": [ | ||||||
|  |       "[nltk_data] Downloading package punkt to /home/jonas/nltk_data...\n", | ||||||
|  |       "[nltk_data]   Package punkt is already up-to-date!\n", | ||||||
|  |       "[nltk_data] Downloading package averaged_perceptron_tagger to\n", | ||||||
|  |       "[nltk_data]     /home/jonas/nltk_data...\n", | ||||||
|  |       "[nltk_data]   Package averaged_perceptron_tagger is already up-to-\n", | ||||||
|  |       "[nltk_data]       date!\n", | ||||||
|  |       "[nltk_data] Downloading package wordnet to /home/jonas/nltk_data...\n", | ||||||
|  |       "[nltk_data]   Package wordnet is already up-to-date!\n" | ||||||
|  |      ] | ||||||
|  |     } | ||||||
|  |    ], | ||||||
|    "source": [ |    "source": [ | ||||||
|     "import simple_twitter_learning as stl\n", |     "import simple_twitter_learning as stl\n", | ||||||
|     "import glob\n", |     "import glob\n", | ||||||
| @ -37,7 +59,7 @@ | |||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": null, |    "execution_count": 2, | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [], | ||||||
|    "source": [ |    "source": [ | ||||||
| @ -92,9 +114,48 @@ | |||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": null, |    "execution_count": 3, | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [ | ||||||
|  |     { | ||||||
|  |      "data": { | ||||||
|  |       "text/markdown": [ | ||||||
|  |        "----" | ||||||
|  |       ], | ||||||
|  |       "text/plain": [ | ||||||
|  |        "<IPython.core.display.Markdown object>" | ||||||
|  |       ] | ||||||
|  |      }, | ||||||
|  |      "metadata": {}, | ||||||
|  |      "output_type": "display_data" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |      "data": { | ||||||
|  |       "text/markdown": [ | ||||||
|  |        "## User Interface" | ||||||
|  |       ], | ||||||
|  |       "text/plain": [ | ||||||
|  |        "<IPython.core.display.Markdown object>" | ||||||
|  |       ] | ||||||
|  |      }, | ||||||
|  |      "metadata": {}, | ||||||
|  |      "output_type": "display_data" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |      "data": { | ||||||
|  |       "application/vnd.jupyter.widget-view+json": { | ||||||
|  |        "model_id": "4fd5552e6a024dcaa0f35a594c77ae99", | ||||||
|  |        "version_major": 2, | ||||||
|  |        "version_minor": 0 | ||||||
|  |       }, | ||||||
|  |       "text/plain": [ | ||||||
|  |        "Tab(children=(VBox(children=(HBox(children=(Text(value='./data_en/', description='root_path'), Button(descript…" | ||||||
|  |       ] | ||||||
|  |      }, | ||||||
|  |      "metadata": {}, | ||||||
|  |      "output_type": "display_data" | ||||||
|  |     } | ||||||
|  |    ], | ||||||
|    "source": [ |    "source": [ | ||||||
|     "mp(\"----\")\n", |     "mp(\"----\")\n", | ||||||
|     "mp(\"## User Interface\")\n", |     "mp(\"## User Interface\")\n", | ||||||
| @ -174,6 +235,18 @@ | |||||||
|     "                ]\n", |     "                ]\n", | ||||||
|     "            ], \n", |     "            ], \n", | ||||||
|     "            \"train\" )\n", |     "            \"train\" )\n", | ||||||
|  |     "create_area(\"playground 😎\",\n", | ||||||
|  |     "           [\n", | ||||||
|  |     "               [\n", | ||||||
|  |     "                   (widgets.Text(),\"test_input\"),\n", | ||||||
|  |     "                   (widgets.HTML(),\"prediction\")\n", | ||||||
|  |     "               ],\n", | ||||||
|  |     "               [\n", | ||||||
|  |     "                   (widgets.Checkbox(),\"show_sorted_list\")\n", | ||||||
|  |     "               ]\n", | ||||||
|  |     "           ],\n", | ||||||
|  |     "           \"playground\")\n", | ||||||
|  |     "\n", | ||||||
|     "tab_manager" |     "tab_manager" | ||||||
|    ] |    ] | ||||||
|   }, |   }, | ||||||
| @ -187,7 +260,7 @@ | |||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": null, |    "execution_count": 4, | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [], | ||||||
|    "source": [ |    "source": [ | ||||||
| @ -205,7 +278,7 @@ | |||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": null, |    "execution_count": 5, | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [], | ||||||
|    "source": [ |    "source": [ | ||||||
| @ -293,7 +366,7 @@ | |||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": null, |    "execution_count": 6, | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [], | ||||||
|    "source": [ |    "source": [ | ||||||
| @ -317,7 +390,7 @@ | |||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": null, |    "execution_count": 7, | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [], | ||||||
|    "source": [ |    "source": [ | ||||||
| @ -381,7 +454,7 @@ | |||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": null, |    "execution_count": 8, | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [], | ||||||
|    "source": [ |    "source": [ | ||||||
| @ -425,7 +498,7 @@ | |||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": null, |    "execution_count": 9, | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [], | ||||||
|    "source": [ |    "source": [ | ||||||
| @ -541,6 +614,46 @@ | |||||||
|     "\n", |     "\n", | ||||||
|     "\n" |     "\n" | ||||||
|    ] |    ] | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |    "cell_type": "markdown", | ||||||
|  |    "metadata": {}, | ||||||
|  |    "source": [ | ||||||
|  |     "## testing area" | ||||||
|  |    ] | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |    "cell_type": "code", | ||||||
|  |    "execution_count": 10, | ||||||
|  |    "metadata": {}, | ||||||
|  |    "outputs": [], | ||||||
|  |    "source": [ | ||||||
|  |     "def test_input(b):\n", | ||||||
|  |     "    global sdm\n", | ||||||
|  |     "    global pm\n", | ||||||
|  |     "    global tr\n", | ||||||
|  |     "    with out_areas[\"playground\"]:\n", | ||||||
|  |     "        clear_output()\n", | ||||||
|  |     "        mp(\"----\")\n", | ||||||
|  |     "        if pm is None:\n", | ||||||
|  |     "            sys.stderr.write(\"ERROR: load or create classifier first\")\n", | ||||||
|  |     "            return\n", | ||||||
|  |     "        X = shown_widgets[\"test_input\"].value\n", | ||||||
|  |     "        pred = pm.predict([X])\n", | ||||||
|  |     "        shown_widgets[\"prediction\"].value = \"<h1> \" + str(stl.sent2emoji(pred)[0]) + \"</h1>\"\n", | ||||||
|  |     "        if shown_widgets[\"show_sorted_list\"].value:\n", | ||||||
|  |     "            mp(\"## \" + \"\".join(stl.edist.sentiment_vector_to_emoji(pred, only_emoticons=True, n_results=100)))\n", | ||||||
|  |     "\n", | ||||||
|  |     "#link\n", | ||||||
|  |     "shown_widgets[\"test_input\"].observe(test_input)" | ||||||
|  |    ] | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |    "cell_type": "code", | ||||||
|  |    "execution_count": null, | ||||||
|  |    "metadata": {}, | ||||||
|  |    "outputs": [], | ||||||
|  |    "source": [] | ||||||
|   } |   } | ||||||
|  ], |  ], | ||||||
|  "metadata": { |  "metadata": { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user