{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "#from oi import *\n", "\n", "#oi = oi()\n", "\n", "#import ipyvuetify as v\n", "\n", "#state = False\n", "#oi.toggle_code(state)\n", "\n", "#button = widgets.ToggleButton(state, description = button_descriptions[state])\n", "\n", "\n", "#button.observe(oi.button_action, \"value\")\n", "\n", "#button.layout.height = '50px'\n", "#button.layout.width = '100%'\n", "#button.add_class(\"thobutton\")\n", "\n", "#display(button)\n", "#button.button_style = 'danger'\n" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "

Ein Klick auf das Logo - und es geht zum Code

\n", "\n", "\n", " \n", "\n", " \n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%html\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "

Ein Klick auf das Logo - und es geht zum Code

\n", "\n", "\n", " \n", "\n", " \n", "\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "#%%html\n", "#\n", "#\n", "#\n", "#\n", "#\n", "#

Ein Klick auf das Logo - und es geht zum Code

\n", "#" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "#%%html\n", "#" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "\n", "#from ipywidgets import widgets\n", "#button = widgets.Button(description='Click me')\n", "#display(button)\n", "\n", "#def on_button_clicked(b):\n", "# print('button clicked')\n", "\n", "#button.on_click(on_button_clicked)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "scrolled": true }, "outputs": [], "source": [ "\n", "# importing the libraries\n", "#print('importing libraries')\n", "#from SolveShorts import *\n", "#import SentSeg\n", "#from SayYes import *\n", "#from Passiv2Aktiv import *\n", "#from GenitivSolve import *\n", "#from ConjunctSolve import *\n", "#from FremdWB import *\n", "#from Medio import *\n", "#from oi import *\n", "#print('done')\n", "\n", "\n", "# Initializing the libraries\n", "#print('initializing the libraries')\n", "#print('1')\n", "#solSh = SolveShorts('hkldbShorts.hkl', 'hkldbShorts_All.hkl')\n", "#print('2')\n", "#sent_seg = SentSeg.SentSeg('de')\n", "#print('3')\n", "#sy = SayYes(None, None)\n", "#print('4')\n", "#p2a = Passiv2Aktiv(None, None, None)\n", "#print('5')\n", "#gs = GenitivSolve()\n", "#print('6')\n", "#cs = ConjunctSolve(None,None)\n", "#print('7')\n", "#oi = oi()\n", "#print('8')\n", "#fwb = FremdWB(None,None)\n", "#print('9')\n", "#medi = Medio(None,None)\n", "#print('done')\n", "\n", "\n", "# loading the databases and models\n", "#print('loading SolveShorts Databases')\n", "#solSh.load_DB_into_FASTsearch()\n", "#print('loading SentSeg Databases')\n", "#sent_seg.LoadSentGlueSGDandGSUtils()\n", "#print('loading SayYes Databases')\n", "#sy.load_DB_into_FASTsearch()\n", "#print('loading passiv2active Databases')\n", "#p2a.load_DB_into_FASTsearch()\n", "#print('loading conjunctivesolve Databases')\n", "#cs.load_DB_into_FASTsearch()\n", "#print('loading the fremdwb Databases')\n", "#fwb.load_DB_into_FASTsearch()\n", "#print('loading the mediodot Databases')\n", "#medi.load_DB_into_FASTsearch()\n", "\n", "#print('done')\n", "\n" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "scrolled": true }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "106e70dd208f4de29ae10874823d30a8", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Textarea(value='', layout=Layout(height='180px', width='99%'), placeholder='Hier den Text eingeben, darunter k…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "\n", "#print('done')\n", "\n", "#print('loading passiv2active Databases')\n", "#from Passiv2Aktiv import *\n", "#p2a = Passiv2Aktiv(None, None, None)\n", "#p2a.load_DB_into_FASTsearch()\n", "#print('done')\n", "#print('loading genitiv solve')\n", "#from GenitivSolve import *\n", "#gs = GenitivSolve()\n", "\n", "#from FremdWB import *\n", "#fwb = FremdWB(None,None)\n", "#fwb.load_DB_into_FASTsearch()\n", "\n", "#from SolveShorts import *\n", "#print('loading SolveShorts Databases')\n", "#solSh.load_DB_into_FASTsearch()\n", "\n", "#from SayYes import *\n", "#sy = SayYes(None, None)\n", "#print('loading SayYes Databases')\n", "#sy.load_DB_into_FASTsearch()\n", "\n", "#import SentSeg\n", "#sent_seg = SentSeg.SentSeg('de')\n", "#print('loading SentSeg Databases')\n", "#sent_seg.LoadSentGlueSGDandGSUtils()\n", "#print('loading conjunctsolve')\n", "#from ConjunctSolve import *\n", "#cs = ConjunctSolve(None,None)\n", "#print('done')\n", "#print('loading conjunctivesolve Databases')\n", "#cs.load_DB_into_FASTsearch()\n", "#print('done')\n", "#from oi import *\n", "#oi = oi()\n", "\n", "#print('loading session..')\n", "\n", "#print('done')\n", "import dill\n", "dill.load_session('voilastate.db')\n", "\n", "#from SolveShorts import *\n", "#print('loading SolveShorts Databases')\n", "#solSh.load_DB_into_FASTsearch()\n", "\n", "#import SentSeg\n", "#sent_seg = SentSeg.SentSeg('de')\n", "#print('loading SentSeg Databases')\n", "#sent_seg.LoadSentGlueSGDandGSUtils()\n", "\n", "#from FremdWB import *\n", "#fwb = FremdWB(None,None)\n", "#fwb.load_DB_into_FASTsearch()\n", "\n", "#from Medio import *\n", "#medi = Medio(None,None)\n", "#medi.load_DB_into_FASTsearch()\n", "\n", "\n", "#import dill\n", "#print('dumping the session')\n", "#dill.dump_session('voilastate.db')\n", "#print('done')\n", "\n", "#from oi import *\n", "#oi = oi()\n", "\n", "import ipywidgets as widgets\n", "\n", "TextFeld = widgets.Textarea(placeholder='Hier den Text eingeben, darunter können die Module aktiviert(grün) oder deaktiviert(pink) werden', disabled=False)\n", "#print(TextFeld.layout.height)\n", "TextFeld.layout.height = '180px'\n", "TextFeld.layout.width = '99%'\n", "\n", "TextFelddouble = widgets.Textarea(placeholder='Hier den Text eingeben, darunter können die Module aktiviert(grün) oder deaktiviert(pink) werden', disabled=False)\n", "#print(TextFeld.layout.height)\n", "TextFelddouble.layout.height = '180px'\n", "TextFelddouble.layout.width = '99%'\n", "TextFelddouble.disabled=True\n", "\n", "display(TextFeld)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "\n", "\n", "dawidth = '100%'\n", "daheight = '100%'\n", "KonjunktiveErsetzen = widgets.ToggleButton(\n", " value=False,\n", " description='Konjunktive ersetzen',\n", " disabled=False,\n", ")\n", "KonjunktiveErsetzen.layout.width = dawidth\n", "KonjunktiveErsetzen.layout.height = '80%'\n", "\n", "GenitiveErsetzen = widgets.ToggleButton(\n", " value=True,\n", " description='Genitiv ersetzen',\n", " disabled=False\n", ")\n", "GenitiveErsetzen.layout.width = '60%'\n", "GenitiveErsetzen.layout.height = daheight\n", "\n", "PassivErsetzen = widgets.ToggleButton(\n", " value=True,\n", " description='Passiv ersetzen',\n", " disabled=False\n", ")\n", "PassivErsetzen.layout.width = '70%'\n", "PassivErsetzen.layout.height = '90%'\n", "\n", "SayYes = widgets.ToggleButton(\n", " value=True,\n", " description='Verneinungen ersetzen',\n", " disabled=False\n", ")\n", "SayYes.layout.width = '80%'\n", "SayYes.layout.height = '80%'\n", "SentSeg = widgets.ToggleButton(\n", " value=True,\n", " description='Eine Aussage pro Satz',\n", " disabled=False\n", ")\n", "SentSeg.layout.width = '60%'\n", "SentSeg.layout.height = daheight\n", "SolveShorts = widgets.ToggleButton(\n", " value=False,\n", " description='Abkürzungen erklären',\n", " disabled=False\n", ")\n", "SolveShorts.layout.width = '80%'\n", "SolveShorts.layout.height = '90%'\n", "FremdWB = widgets.ToggleButton(\n", " value=True,\n", " description='FremdWoerterbuch',\n", " disabled=False\n", ")\n", "FremdWB.layout.width = '90%'\n", "FremdWB.layout.height = '90%'\n", "\n", "Appendixes = widgets.ToggleButton(\n", " value=True,\n", " description='Charakterisierung pro Satz',\n", " disabled=False\n", ")\n", "Appendixes.layout.width = '120%'\n", "Appendixes.layout.height = '80%'\n", "\n", "Medio = widgets.ToggleButton(\n", " value=True,\n", " description='Mediopunkte',\n", " disabled=False\n", ")\n", "Medio.layout.width = '50%'\n", "Medio.layout.height = '90%'\n", "\n", "#items1 = [SentSeg, SolveShorts]\n", "#items2 = [SayYes, PassivErsetzen]\n", "#items3 = [GenitiveErsetzen, KonjunktiveErsetzen]\n", "#items = [Textfeld, SentSeg, SolveShorts, SayYes, PassivErsetzen, GenitiveErsetzen, KonjunktiveErsetzen]\n", "#display(SentSeg, SolveShorts, SayYes, PassivErsetzen, GenitiveErsetzen, KonjunktiveErsetzen)\n", "#widgets.GridBox(items, layout=widgets.Layout(grid_template_columns=\"repeat(3, 100px)\"))\n", "\n", "\n", "\n", "#widgets.HBox(items1)\n", "#widgets.HBox(items2)\n", "#widgets.HBox(items3)\n" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "import ipywidgets\n", "out = 'Hier kommt der übersetzte Text heraus.'\n", "\n", "TextFeld.add_class(\"thotext\")\n", "TextFelddouble.add_class(\"thotext\")\n", "#display(OutTextFeld)\n", "items = [SentSeg, SolveShorts, SayYes, PassivErsetzen, GenitiveErsetzen, KonjunktiveErsetzen, FremdWB, Appendixes, Medio] \n", "#display(SentSeg, SolveShorts, SayYes, PassivErsetzen, GenitiveErsetzen, KonjunktiveErsetzen)\n", "Grid = widgets.GridBox(items, layout=widgets.Layout(justify_items=\"center\", grid_template_columns=\"repeat(3, 30%)\", grid_gap=\"4.5%\", height=\"320px\"))\n" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "c08292c98ddf447ca1c19117241980b8", "version_major": 2, "version_minor": 0 }, "text/plain": [ "GridBox(children=(ToggleButton(value=True, description='Eine Aussage pro Satz', layout=Layout(height='100%', w…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "\n", "display(HTML('
'))\n", "display(Grid)\n", "\n", "\n", "\n", "\n", "def function():\n", " out = 'Wählen Sie ein Kästchen aus!'\n", " try:\n", " insentences, punctuations = oi.CellInputText2SplitsentencesWithspacy(TextFeld.value)\n", " except:\n", " OutTextFeld.placeholder = 'Bitte auf die Zeichensetzung achten! '\n", " return\n", " \n", " check = 0\n", " #print('insentences',insentences)\n", " #print(punctuations)\n", " if SayYes.value == True:\n", " \n", " print('ersetze Gegenteile..')\n", " outsentences = sy.replaceOpposites(insentences)\n", " check = 1\n", " \n", " \n", " \n", " \n", " if Appendixes.value == True:\n", " if check == 1:\n", " insentences = outsentences\n", " print('generiere ist-Aussagen..')\n", " outsentences, punctuations = sent_seg.putAppendixesIntoOwnSentences(insentences, punctuations)\n", " \n", " if SentSeg.value == True:\n", " if check == 1:\n", " insentences = outsentences\n", " print('forme zu einem Satz pro Aussage um..')\n", " sentsegformattedsentences = []\n", " for sentence in insentences:\n", " \n", " sentsegformattedsentences.append([sentence])\n", " \n", " #print(sentsegformattedsentences)\n", " sentences = sent_seg.CommaSentenceOrNot(sentsegformattedsentences)\n", " #print(sentences)\n", " sentences = sent_seg.GetUtteranceNumber(sentences)\n", " #print(sentences)\n", " sentences = sent_seg.GetQuestionOrNot(sentences)\n", " #print(sentences)\n", " sentences, punctuations = sent_seg.AndOrSolver(sentences, punctuations)\n", " #print(len(punctuations))\n", " #print('sentences after AndOrSolver', sentences, punctuations)\n", " sentences = sent_seg.CommaSentenceOrNot(sentences)\n", " #print(sentences)\n", " sentences = sent_seg.GetUtteranceNumber(sentences)\n", " #print(sentences)\n", " sentences = sent_seg.GetQuestionOrNot(sentences)\n", " #print(sentences)\n", " sentences, punctuations = sent_seg.SplitSentencesIntoHauptNebenTuple(sentences, punctuations)\n", " #print(len(punctuations))\n", " #print('sentences after split haupt neben', sentences)\n", " sentences = sent_seg.CommaSentenceOrNot(sentences)\n", " #print(sentences)\n", " sentences = sent_seg.GetUtteranceNumber(sentences)\n", " #print(sentences)\n", " sentences = sent_seg.GetQuestionOrNot(sentences)\n", " #print(sentences)\n", " outsentences, punctuations = sent_seg.SplitCommatas(sentences, punctuations)\n", " #print(len(punctuations))\n", " #print('out',outsentences)\n", " #print('out', punctuations)\n", " check = 1\n", " \n", " \n", " if SolveShorts.value == True:\n", " if check == 1:\n", " insentences = outsentences\n", " print('erklaere Abkuerzungen..')\n", " outsentences = solSh.ExplainShortsInSentencesWithBrackets(insentences)\n", " check = 1\n", " #print(len(punctuations)) \n", " #print('sentences after solveshorts', outsentences)\n", " \n", " if PassivErsetzen.value == True:\n", " if check == 1:\n", " insentences = outsentences\n", " print('ersetze Passiv Formen..')\n", " outsentences = p2a.replacePassivForms(insentences)\n", " check = 1\n", " #print(len(punctuations))\n", " #print('sentences after p2a', outsentences)\n", " \n", " if GenitiveErsetzen.value == True:\n", " if check == 1:\n", " insentences = outsentences\n", " #print('replacing genitiv forms with dativ..')\n", " outsentences = gs.ReplaceGenitivWithDativ(insentences)\n", " check = 1\n", " #print(len(punctuations))\n", " #print('sentences after gs', outsentences)\n", " \n", " if check == 1:\n", " newinsentences = []\n", " for sentence in outsentences: \n", " newinsentences.append([word.replace('ö','oe').replace('ü','ue').replace('ä','ae').replace('ß','ss') for word in sentence])\n", " \n", " outsentences =newinsentences\n", " if check != 1:\n", " newinsentences = []\n", " for sentence in insentences: \n", " newinsentences.append([word.replace('ö','oe').replace('ü','ue').replace('ä','ae').replace('ß','ss') for word in sentence])\n", " \n", " insentences =newinsentences\n", " #print()\n", " if KonjunktiveErsetzen.value == True:\n", " if check == 1:\n", " insentences = outsentences\n", " print('ersetze Konjunktive..')\n", " \n", " outsentences = cs.replaceConjunctives(insentences)\n", " #print('outsentences')\n", " check = 1\n", " \n", " #print('sentences after cs', outsentences)\n", " print(len(punctuations))\n", " \n", " if FremdWB.value == True:\n", " if check == 1:\n", " insentences = outsentences\n", " print('Suche Woerterbucheintraege..')\n", " \n", " outsentences, punctuations = fwb.fremdEintragAppend(insentences, punctuations)\n", " #print('outsentences')\n", " check = 1\n", " \n", " if Medio.value == True:\n", " if check == 1:\n", " insentences = outsentences\n", " print('Ersetze lange Woerter mit Mediopunkten..')\n", " \n", " outsentences, punctuations = medi.Medioreplace(insentences, punctuations)\n", " #print('outsentences')\n", " check = 1\n", " #print('sentences after medios', outsentences)\n", " \n", " \n", " #print('sentences after fwb', outsentences)\n", " \n", " print(len(punctuations))\n", " \n", " if check == 1:\n", " out = ''\n", " #print('just before looking if the lenght is the same')\n", " #print(len(outsentences), len(punctuations))\n", " if len(outsentences) == len(punctuations):\n", " #print('the length is the same')\n", " for n in range(len(outsentences)):\n", " outsentence = outsentences[n]\n", " outsentence[0] = outsentence[0].title()\n", " out += ' '.join(outsentence) + punctuations[n] + '\\n'\n", " \n", " \n", " OutTextFeld.value = out\n", " TextFelddouble.value = TextFeld.value\n", " display(TextFelddouble)\n", " \n", " return \n", "\n" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "3ca86c6e7e39437eafa36439e3337b42", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(Button(description='Übersetzen in Leichte Sprache', style=ButtonStyle()), Output()), _do…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#from IPython.display import Image\n", "#i = Image(filename='Babelfish.png')\n", "\n", "#i.width = '60%'\n", "#display(i)\n", "\n", "#print(widgets.interact_manual.opts)\n", "\n", "widgets.interact_manual.opts['manual_name']= 'Übersetzen in Leichte Sprache'\n", "ola = widgets.interact_manual(function)\n", "ola.widget.children[0].style.button_color = 'lightgreen'\n", "ola.widget.children[0].layout.height = '60px'\n", "ola.widget.children[0].layout.width = '99%'\n", "\n", "#widgets.GridBox([ola], layout=widgets.Layout(grid_template_columns=\"repeat(2, 300px)\"))" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "scrolled": true }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "0d6f03c93f0147cd9f33d2a053672b0c", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Textarea(value='', layout=Layout(height='180px', width='99%'), placeholder='Hier kommt der übersetzte Text her…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "OutTextFeld = ipywidgets.Textarea(placeholder=out, disabled=False)\n", "OutTextFeld.layout.height = '180px'\n", "OutTextFeld.layout.width = '99%'\n", "OutTextFeld.add_class(\"thetext\")\n", "display(OutTextFeld)\n" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "beschreibung = 'Textfeld für die verbesserte Übersetzung. Satzzeichen bitte nicht vergessen! \\nFalls ein neuer Eintrag ins Fremdwörterbuch vorgenommen werden soll, schreibe einfach unter die Verbesserungen einen Eintrag der Form: [\\'Abfall\\', \\'Abfall sind Sachen die wir nicht mehr brauchen\\'] \\nFalls ein neuer Eintrag in die Mediopunkte-Datenbank vorgenommen werden soll, bitte schreibe unter die Verbesserungen einen Eintrag der Form: [\\'Mediopunkt\\', \\'Medio·punkt\\']' \n", "VerbeTextFeld = ipywidgets.Textarea(placeholder=beschreibung, disabled=False)\n", "VerbeTextFeld.layout.height = '180px'\n", "VerbeTextFeld.layout.width = '99%'\n", "\n" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "\n", "\n", "def Absendefunction():\n", " \n", " \n", "\n", " \n", " #print(VerbeTextFeld.value)\n", " #print(TextFeld.value)\n", " #print(OutTextFeld.value)\n", " \n", " try:\n", "\n", " insentences, punctuations = oi.CellInputText2SplitsentencesWithspacy(VerbeTextFeld.value)\n", " insentences1, punctuations1 = oi.CellInputText2SplitsentencesWithspacy(TextFeld.value)\n", " insentences2, punctuations2 = oi.CellInputText2SplitsentencesWithspacy(OutTextFeld.value)\n", "\n", " #print(insentences2)\n", "\n", " #print(insentences, punctuations)\n", " indexDerVerbesserungen = 0\n", " number = 0\n", " with open('Verbesserungen/indexDerVerbesserungen.txt', 'r') as dok:\n", " for number in dok:\n", " number = int(number)\n", " if number >= 0:\n", " indexDerVerbesserungen = number\n", " number += 1\n", "\n", " with open('Verbesserungen/indexDerVerbesserungen.txt', 'w') as dokk:\n", " dokk.write(str(number))\n", "\n", "\n", " with open('Verbesserungen/Verbesserungen' + str(number) + '.txt','w+') as doc:\n", " for n in range(len(insentences)):\n", " npunct = punctuations[n]\n", " writeline = insentences[n]+ [npunct]\n", "\n", " writestring = ' '.join(writeline)\n", "\n", " doc.write(writestring + '\\n')\n", "\n", " with open('Verbesserungen/Input' + str(number) + '.txt','w+') as docc:\n", " for n in range(len(insentences1)):\n", " npunct = punctuations1[n]\n", " writeline = insentences1[n]+ [npunct]\n", "\n", " writestring = ' '.join(writeline)\n", "\n", " docc.write(writestring + '\\n')\n", " with open('Verbesserungen/Output' + str(number) + '.txt','w+') as dock:\n", " #print(insentences2)\n", " for n in range(len(insentences2)):\n", " #print(len(insentences2))\n", "\n", " #print(punctuations2)\n", " npunct = punctuations2[n]\n", " writeline = insentences2[n]+ [npunct]\n", "\n", " writestring = ' '.join(writeline)\n", "\n", " dock.write(writestring + '\\n')\n", "\n", " VerbeTextFeld.value = ''\n", " OutTextFeld.value = ''\n", " VerbeTextFeld.placeholder = beschreibung\n", " OutTextFeld.placeholder = 'Hier kommt der übersetzte Text raus.'\n", " except:\n", " VerbeTextFeld.placeholder = 'Es gab einen Fehler. Eventuell ist die Zeichensetzung nicht ok. \\n \\n' + beschreibung\n", " \n", " \n", " return \n", "\n" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "1713cde35a884104b20056d5694d168a", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Textarea(value='', layout=Layout(height='180px', width='99%'), placeholder=\"Textfeld für die verbesserte Übers…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "d4100a2d84d34630acf974f78d316abc", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(Button(description='Absenden', style=ButtonStyle()), Output()), _dom_classes=('widget-in…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "VerbeTextFeld.add_class(\"thetext3\")\n", "display(VerbeTextFeld)\n", "display(HTML('
'))\n", "widgets.interact_manual.opts['manual_name']= 'Absenden'\n", "AbsendenUndSchreiben = widgets.interact_manual(Absendefunction)\n", "AbsendenUndSchreiben.widget.children[0].style.button_color = 'lightblue'\n", "AbsendenUndSchreiben.widget.children[0].layout.height = '60px'\n", "AbsendenUndSchreiben.widget.children[0].layout.width = '99%'\n", "\n" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%html\n", "" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%html\n", "" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%html\n", "" ] } ], "metadata": { "celltoolbar": "Raw Cell Format", "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.5.3" } }, "nbformat": 4, "nbformat_minor": 2 }