You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1189 lines
36 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {},
  7. "outputs": [],
  8. "source": [
  9. "#from oi import *\n",
  10. "\n",
  11. "#oi = oi()\n",
  12. "\n",
  13. "#import ipyvuetify as v\n",
  14. "\n",
  15. "#state = False\n",
  16. "#oi.toggle_code(state)\n",
  17. "\n",
  18. "#button = widgets.ToggleButton(state, description = button_descriptions[state])\n",
  19. "\n",
  20. "\n",
  21. "#button.observe(oi.button_action, \"value\")\n",
  22. "\n",
  23. "#button.layout.height = '50px'\n",
  24. "#button.layout.width = '100%'\n",
  25. "#button.add_class(\"thobutton\")\n",
  26. "\n",
  27. "#display(button)\n",
  28. "#button.button_style = 'danger'\n"
  29. ]
  30. },
  31. {
  32. "cell_type": "code",
  33. "execution_count": 2,
  34. "metadata": {},
  35. "outputs": [
  36. {
  37. "data": {
  38. "text/html": [
  39. "<style>\n",
  40. "\n",
  41. ".center {\n",
  42. " display: block;\n",
  43. " margin-left: auto;\n",
  44. " margin-right: auto;\n",
  45. " width: 20%;\n",
  46. "}\n",
  47. "\n",
  48. "body {\n",
  49. " align: center;\n",
  50. " }\n",
  51. "\n",
  52. "</style>\n",
  53. "<body>\n",
  54. "<a href=\"https://basabuuka.zapto.org/alpcentaur/Basabuuka_Prototyp\">\n",
  55. "<img src=\"brainBasaBuuka5.png\" width=\"300\" height=\"200\" class=\"center\"/>\n",
  56. "</a>\n",
  57. "<p style=\"font-family: courier\"><center><b>Du kommst zu dem Code - wenn du auf das Logo klickst!</b></center></p> \n",
  58. "</body>\n"
  59. ],
  60. "text/plain": [
  61. "<IPython.core.display.HTML object>"
  62. ]
  63. },
  64. "metadata": {},
  65. "output_type": "display_data"
  66. }
  67. ],
  68. "source": [
  69. "%%html\n",
  70. "<style>\n",
  71. "\n",
  72. ".center {\n",
  73. " display: block;\n",
  74. " margin-left: auto;\n",
  75. " margin-right: auto;\n",
  76. " width: 20%;\n",
  77. "}\n",
  78. "\n",
  79. "body {\n",
  80. " align: center;\n",
  81. " }\n",
  82. "\n",
  83. "</style>\n",
  84. "<body>\n",
  85. "<a href=\"https://basabuuka.zapto.org/alpcentaur/Basabuuka_Prototyp\">\n",
  86. "<img src=\"brainBasaBuuka5.png\" width=\"300\" height=\"200\" class=\"center\"/>\n",
  87. "</a>\n",
  88. "<p style=\"font-family: courier\"><center><b>Du kommst zu dem Code - wenn du auf das Logo klickst!</b></center></p> \n",
  89. "</body>"
  90. ]
  91. },
  92. {
  93. "cell_type": "code",
  94. "execution_count": null,
  95. "metadata": {},
  96. "outputs": [],
  97. "source": [
  98. "\n"
  99. ]
  100. },
  101. {
  102. "cell_type": "code",
  103. "execution_count": 3,
  104. "metadata": {},
  105. "outputs": [
  106. {
  107. "data": {
  108. "text/html": [
  109. "<style type=\"text/css\">\n",
  110. ".modal-open { position: fixed; }\n",
  111. "\n",
  112. "* {\n",
  113. " font-family: courier;\n",
  114. " }\n",
  115. "\n",
  116. "</style>\n",
  117. "\n"
  118. ],
  119. "text/plain": [
  120. "<IPython.core.display.HTML object>"
  121. ]
  122. },
  123. "metadata": {},
  124. "output_type": "display_data"
  125. }
  126. ],
  127. "source": [
  128. "%%html\n",
  129. "<style type=\"text/css\">\n",
  130. ".modal-open { position: fixed; }\n",
  131. "\n",
  132. "* {\n",
  133. " font-family: courier;\n",
  134. " }\n",
  135. "\n",
  136. "</style>\n",
  137. "\n"
  138. ]
  139. },
  140. {
  141. "cell_type": "code",
  142. "execution_count": 4,
  143. "metadata": {},
  144. "outputs": [],
  145. "source": [
  146. "#%%html\n",
  147. "#<style>\n",
  148. "#.jupyter-button.mod-danger {\n",
  149. "# font-style: italic;\n",
  150. "# color: black;\n",
  151. "# background-color: pink;\n",
  152. "#}\n",
  153. "#.jupyter-button.mod-danger.mod-active {\n",
  154. "# \n",
  155. "# color: black;\n",
  156. "# background-color: lightgreen;\n",
  157. "#}\n",
  158. "#</style>"
  159. ]
  160. },
  161. {
  162. "cell_type": "code",
  163. "execution_count": 5,
  164. "metadata": {},
  165. "outputs": [],
  166. "source": [
  167. "\n",
  168. "#from ipywidgets import widgets\n",
  169. "#button = widgets.Button(description='Click me')\n",
  170. "#display(button)\n",
  171. "\n",
  172. "#def on_button_clicked(b):\n",
  173. "# print('button clicked')\n",
  174. "\n",
  175. "#button.on_click(on_button_clicked)"
  176. ]
  177. },
  178. {
  179. "cell_type": "code",
  180. "execution_count": 6,
  181. "metadata": {
  182. "scrolled": true
  183. },
  184. "outputs": [],
  185. "source": [
  186. "\n",
  187. "# importing the libraries\n",
  188. "#print('importing libraries')\n",
  189. "#from SolveShorts import *\n",
  190. "#import SentSeg\n",
  191. "#from SayYes import *\n",
  192. "#from Passiv2Aktiv import *\n",
  193. "#from GenitivSolve import *\n",
  194. "#from ConjunctSolve import *\n",
  195. "#from FremdWB import *\n",
  196. "#from Medio import *\n",
  197. "#from oi import *\n",
  198. "#print('done')\n",
  199. "\n",
  200. "\n",
  201. "# Initializing the libraries\n",
  202. "#print('initializing the libraries')\n",
  203. "#print('1')\n",
  204. "#solSh = SolveShorts('hkldbShorts.hkl', 'hkldbShorts_All.hkl')\n",
  205. "#print('2')\n",
  206. "#sent_seg = SentSeg.SentSeg('de')\n",
  207. "#print('3')\n",
  208. "#sy = SayYes(None, None)\n",
  209. "#print('4')\n",
  210. "#p2a = Passiv2Aktiv(None, None, None)\n",
  211. "#print('5')\n",
  212. "#gs = GenitivSolve()\n",
  213. "#print('6')\n",
  214. "#cs = ConjunctSolve(None,None)\n",
  215. "#print('7')\n",
  216. "#oi = oi()\n",
  217. "#print('8')\n",
  218. "#fwb = FremdWB(None,None)\n",
  219. "#print('9')\n",
  220. "#medi = Medio(None,None)\n",
  221. "#print('done')\n",
  222. "\n",
  223. "\n",
  224. "# loading the databases and models\n",
  225. "#print('loading SolveShorts Databases')\n",
  226. "#solSh.load_DB_into_FASTsearch()\n",
  227. "#print('loading SentSeg Databases')\n",
  228. "#sent_seg.LoadSentGlueSGDandGSUtils()\n",
  229. "#print('loading SayYes Databases')\n",
  230. "#sy.load_DB_into_FASTsearch()\n",
  231. "#print('loading passiv2active Databases')\n",
  232. "#p2a.load_DB_into_FASTsearch()\n",
  233. "#print('loading conjunctivesolve Databases')\n",
  234. "#cs.load_DB_into_FASTsearch()\n",
  235. "#print('loading the fremdwb Databases')\n",
  236. "#fwb.load_DB_into_FASTsearch()\n",
  237. "#print('loading the mediodot Databases')\n",
  238. "#medi.load_DB_into_FASTsearch()\n",
  239. "\n",
  240. "#print('done')\n",
  241. "\n"
  242. ]
  243. },
  244. {
  245. "cell_type": "code",
  246. "execution_count": 7,
  247. "metadata": {
  248. "scrolled": true
  249. },
  250. "outputs": [
  251. {
  252. "data": {
  253. "application/vnd.jupyter.widget-view+json": {
  254. "model_id": "3daf3708d77e4098b826524460104e31",
  255. "version_major": 2,
  256. "version_minor": 0
  257. },
  258. "text/plain": [
  259. "Textarea(value='', layout=Layout(height='180px', width='99%'), placeholder='Hier den Text eingeben, darunter k…"
  260. ]
  261. },
  262. "metadata": {},
  263. "output_type": "display_data"
  264. }
  265. ],
  266. "source": [
  267. "\n",
  268. "#print('done')\n",
  269. "\n",
  270. "#print('loading passiv2active Databases')\n",
  271. "#from Passiv2Aktiv import *\n",
  272. "#p2a = Passiv2Aktiv(None, None, None)\n",
  273. "#p2a.load_DB_into_FASTsearch()\n",
  274. "#print('done')\n",
  275. "#print('loading genitiv solve')\n",
  276. "#from GenitivSolve import *\n",
  277. "#gs = GenitivSolve()\n",
  278. "\n",
  279. "#from FremdWB import *\n",
  280. "#fwb = FremdWB(None,None)\n",
  281. "#fwb.load_DB_into_FASTsearch()\n",
  282. "\n",
  283. "#from SolveShorts import *\n",
  284. "#print('loading SolveShorts Databases')\n",
  285. "#solSh.load_DB_into_FASTsearch()\n",
  286. "\n",
  287. "#from SayYes import *\n",
  288. "#sy = SayYes(None, None)\n",
  289. "#print('loading SayYes Databases')\n",
  290. "#sy.load_DB_into_FASTsearch()\n",
  291. "\n",
  292. "#import SentSeg\n",
  293. "#sent_seg = SentSeg.SentSeg('de')\n",
  294. "#print('loading SentSeg Databases')\n",
  295. "#sent_seg.LoadSentGlueSGDandGSUtils()\n",
  296. "#print('loading conjunctsolve')\n",
  297. "#from ConjunctSolve import *\n",
  298. "#cs = ConjunctSolve(None,None)\n",
  299. "#print('done')\n",
  300. "#print('loading conjunctivesolve Databases')\n",
  301. "#cs.load_DB_into_FASTsearch()\n",
  302. "#print('done')\n",
  303. "#from oi import *\n",
  304. "#oi = oi()\n",
  305. "\n",
  306. "#print('loading session..')\n",
  307. "\n",
  308. "#print('done')\n",
  309. "import dill\n",
  310. "dill.load_session('voilastate.db')\n",
  311. "\n",
  312. "#from SolveShorts import *\n",
  313. "#print('loading SolveShorts Databases')\n",
  314. "#solSh.load_DB_into_FASTsearch()\n",
  315. "\n",
  316. "#import SentSeg\n",
  317. "#sent_seg = SentSeg.SentSeg('de')\n",
  318. "#print('loading SentSeg Databases')\n",
  319. "#sent_seg.LoadSentGlueSGDandGSUtils()\n",
  320. "\n",
  321. "#from FremdWB import *\n",
  322. "#fwb = FremdWB(None,None)\n",
  323. "#fwb.load_DB_into_FASTsearch()\n",
  324. "\n",
  325. "#from Medio import *\n",
  326. "#medi = Medio(None,None)\n",
  327. "#medi.load_DB_into_FASTsearch()\n",
  328. "\n",
  329. "\n",
  330. "#import dill\n",
  331. "#print('dumping the session')\n",
  332. "#dill.dump_session('voilastate.db')\n",
  333. "#print('done')\n",
  334. "\n",
  335. "#from oi import *\n",
  336. "#oi = oi()\n",
  337. "\n",
  338. "import ipywidgets as widgets\n",
  339. "\n",
  340. "TextFeld = widgets.Textarea(placeholder='Hier den Text eingeben, darunter können die Module aktiviert(grün) oder deaktiviert(pink) werden', disabled=False)\n",
  341. "#print(TextFeld.layout.height)\n",
  342. "TextFeld.layout.height = '180px'\n",
  343. "TextFeld.layout.width = '99%'\n",
  344. "\n",
  345. "TextFelddouble = widgets.Textarea(placeholder='Hier den Text eingeben, darunter können die Module aktiviert(grün) oder deaktiviert(pink) werden', disabled=False)\n",
  346. "#print(TextFeld.layout.height)\n",
  347. "TextFelddouble.layout.height = '180px'\n",
  348. "TextFelddouble.layout.width = '99%'\n",
  349. "TextFelddouble.disabled=True\n",
  350. "\n",
  351. "display(TextFeld)"
  352. ]
  353. },
  354. {
  355. "cell_type": "code",
  356. "execution_count": 8,
  357. "metadata": {},
  358. "outputs": [],
  359. "source": [
  360. "\n",
  361. "\n",
  362. "dawidth = '100%'\n",
  363. "KonjunktiveErsetzen = widgets.ToggleButton(\n",
  364. " value=False,\n",
  365. " description='Konjunktive ersetzen',\n",
  366. " disabled=False,\n",
  367. ")\n",
  368. "KonjunktiveErsetzen.layout.width = dawidth\n",
  369. "GenitiveErsetzen = widgets.ToggleButton(\n",
  370. " value=True,\n",
  371. " description='Genitiv ersetzen',\n",
  372. " disabled=False\n",
  373. ")\n",
  374. "GenitiveErsetzen.layout.width = dawidth\n",
  375. "PassivErsetzen = widgets.ToggleButton(\n",
  376. " value=True,\n",
  377. " description='Passiv ersetzen',\n",
  378. " disabled=False\n",
  379. ")\n",
  380. "PassivErsetzen.layout.width = dawidth\n",
  381. "SayYes = widgets.ToggleButton(\n",
  382. " value=True,\n",
  383. " description='Verneinungen ersetzen',\n",
  384. " disabled=False\n",
  385. ")\n",
  386. "SayYes.layout.width = dawidth\n",
  387. "SentSeg = widgets.ToggleButton(\n",
  388. " value=True,\n",
  389. " description='Eine Aussage pro Satz',\n",
  390. " disabled=False\n",
  391. ")\n",
  392. "SentSeg.layout.width = dawidth\n",
  393. "SolveShorts = widgets.ToggleButton(\n",
  394. " value=False,\n",
  395. " description='Abkürzungen erklären',\n",
  396. " disabled=False\n",
  397. ")\n",
  398. "SolveShorts.layout.width = dawidth\n",
  399. "FremdWB = widgets.ToggleButton(\n",
  400. " value=True,\n",
  401. " description='FremdWoerterbuch',\n",
  402. " disabled=False\n",
  403. ")\n",
  404. "FremdWB.layout.width = dawidth\n",
  405. "\n",
  406. "Appendixes = widgets.ToggleButton(\n",
  407. " value=True,\n",
  408. " description='Charakterisierung pro Satz',\n",
  409. " disabled=False\n",
  410. ")\n",
  411. "Appendixes.layout.width = dawidth\n",
  412. "\n",
  413. "Medio = widgets.ToggleButton(\n",
  414. " value=True,\n",
  415. " description='Mediopunkte',\n",
  416. " disabled=False\n",
  417. ")\n",
  418. "Medio.layout.width = dawidth\n",
  419. "\n",
  420. "#items1 = [SentSeg, SolveShorts]\n",
  421. "#items2 = [SayYes, PassivErsetzen]\n",
  422. "#items3 = [GenitiveErsetzen, KonjunktiveErsetzen]\n",
  423. "#items = [Textfeld, SentSeg, SolveShorts, SayYes, PassivErsetzen, GenitiveErsetzen, KonjunktiveErsetzen]\n",
  424. "#display(SentSeg, SolveShorts, SayYes, PassivErsetzen, GenitiveErsetzen, KonjunktiveErsetzen)\n",
  425. "#widgets.GridBox(items, layout=widgets.Layout(grid_template_columns=\"repeat(3, 100px)\"))\n",
  426. "\n",
  427. "\n",
  428. "\n",
  429. "#widgets.HBox(items1)\n",
  430. "#widgets.HBox(items2)\n",
  431. "#widgets.HBox(items3)\n"
  432. ]
  433. },
  434. {
  435. "cell_type": "code",
  436. "execution_count": 9,
  437. "metadata": {},
  438. "outputs": [],
  439. "source": [
  440. "import ipywidgets\n",
  441. "out = 'Hier kommt der übersetzte Text heraus.'\n",
  442. "\n",
  443. "TextFeld.add_class(\"thotext\")\n",
  444. "TextFelddouble.add_class(\"thotext\")\n",
  445. "#display(OutTextFeld)\n",
  446. "items = [SentSeg, SolveShorts, SayYes, PassivErsetzen, GenitiveErsetzen, KonjunktiveErsetzen, FremdWB, Appendixes, Medio] \n",
  447. "#display(SentSeg, SolveShorts, SayYes, PassivErsetzen, GenitiveErsetzen, KonjunktiveErsetzen)\n",
  448. "Grid = widgets.GridBox(items, layout=widgets.Layout(justify_items=\"center\", grid_template_columns=\"repeat(3, 30%)\", grid_gap=\"1.5%\", height=\"200px\"))\n"
  449. ]
  450. },
  451. {
  452. "cell_type": "code",
  453. "execution_count": 10,
  454. "metadata": {},
  455. "outputs": [
  456. {
  457. "data": {
  458. "text/html": [
  459. "<br>"
  460. ],
  461. "text/plain": [
  462. "<IPython.core.display.HTML object>"
  463. ]
  464. },
  465. "metadata": {},
  466. "output_type": "display_data"
  467. },
  468. {
  469. "data": {
  470. "application/vnd.jupyter.widget-view+json": {
  471. "model_id": "a45cde93f5394cf6b262cc31f14c0d2e",
  472. "version_major": 2,
  473. "version_minor": 0
  474. },
  475. "text/plain": [
  476. "GridBox(children=(ToggleButton(value=True, description='Eine Aussage pro Satz', layout=Layout(width='100%')), …"
  477. ]
  478. },
  479. "metadata": {},
  480. "output_type": "display_data"
  481. }
  482. ],
  483. "source": [
  484. "\n",
  485. "display(HTML('<br>'))\n",
  486. "display(Grid)\n",
  487. "\n",
  488. "\n",
  489. "\n",
  490. "\n",
  491. "def function():\n",
  492. " out = 'Wählen Sie ein Kästchen aus!'\n",
  493. " try:\n",
  494. " insentences, punctuations = oi.CellInputText2SplitsentencesWithspacy(TextFeld.value)\n",
  495. " except:\n",
  496. " OutTextFeld.placeholder = 'Bitte auf die Zeichensetzung achten! '\n",
  497. " return\n",
  498. " \n",
  499. " check = 0\n",
  500. " #print('insentences',insentences)\n",
  501. " #print(punctuations)\n",
  502. " if SayYes.value == True:\n",
  503. " \n",
  504. " print('ersetze Gegenteile..')\n",
  505. " outsentences = sy.replaceOpposites(insentences)\n",
  506. " check = 1\n",
  507. " \n",
  508. " \n",
  509. " \n",
  510. " \n",
  511. " if Appendixes.value == True:\n",
  512. " if check == 1:\n",
  513. " insentences = outsentences\n",
  514. " print('generiere ist-Aussagen..')\n",
  515. " outsentences, punctuations = sent_seg.putAppendixesIntoOwnSentences(insentences, punctuations)\n",
  516. " \n",
  517. " if SentSeg.value == True:\n",
  518. " if check == 1:\n",
  519. " insentences = outsentences\n",
  520. " print('forme zu einem Satz pro Aussage um..')\n",
  521. " sentsegformattedsentences = []\n",
  522. " for sentence in insentences:\n",
  523. " \n",
  524. " sentsegformattedsentences.append([sentence])\n",
  525. " \n",
  526. " #print(sentsegformattedsentences)\n",
  527. " sentences = sent_seg.CommaSentenceOrNot(sentsegformattedsentences)\n",
  528. " #print(sentences)\n",
  529. " sentences = sent_seg.GetUtteranceNumber(sentences)\n",
  530. " #print(sentences)\n",
  531. " sentences = sent_seg.GetQuestionOrNot(sentences)\n",
  532. " #print(sentences)\n",
  533. " sentences, punctuations = sent_seg.AndOrSolver(sentences, punctuations)\n",
  534. " #print(len(punctuations))\n",
  535. " #print('sentences after AndOrSolver', sentences, punctuations)\n",
  536. " sentences = sent_seg.CommaSentenceOrNot(sentences)\n",
  537. " #print(sentences)\n",
  538. " sentences = sent_seg.GetUtteranceNumber(sentences)\n",
  539. " #print(sentences)\n",
  540. " sentences = sent_seg.GetQuestionOrNot(sentences)\n",
  541. " #print(sentences)\n",
  542. " sentences, punctuations = sent_seg.SplitSentencesIntoHauptNebenTuple(sentences, punctuations)\n",
  543. " #print(len(punctuations))\n",
  544. " #print('sentences after split haupt neben', sentences)\n",
  545. " sentences = sent_seg.CommaSentenceOrNot(sentences)\n",
  546. " #print(sentences)\n",
  547. " sentences = sent_seg.GetUtteranceNumber(sentences)\n",
  548. " #print(sentences)\n",
  549. " sentences = sent_seg.GetQuestionOrNot(sentences)\n",
  550. " #print(sentences)\n",
  551. " outsentences, punctuations = sent_seg.SplitCommatas(sentences, punctuations)\n",
  552. " #print(len(punctuations))\n",
  553. " #print('out',outsentences)\n",
  554. " #print('out', punctuations)\n",
  555. " check = 1\n",
  556. " \n",
  557. " \n",
  558. " if SolveShorts.value == True:\n",
  559. " if check == 1:\n",
  560. " insentences = outsentences\n",
  561. " print('erklaere Abkuerzungen..')\n",
  562. " outsentences = solSh.ExplainShortsInSentencesWithBrackets(insentences)\n",
  563. " check = 1\n",
  564. " #print(len(punctuations)) \n",
  565. " #print('sentences after solveshorts', outsentences)\n",
  566. " \n",
  567. " if PassivErsetzen.value == True:\n",
  568. " if check == 1:\n",
  569. " insentences = outsentences\n",
  570. " print('ersetze Passiv Formen..')\n",
  571. " outsentences = p2a.replacePassivForms(insentences)\n",
  572. " check = 1\n",
  573. " #print(len(punctuations))\n",
  574. " #print('sentences after p2a', outsentences)\n",
  575. " \n",
  576. " if GenitiveErsetzen.value == True:\n",
  577. " if check == 1:\n",
  578. " insentences = outsentences\n",
  579. " #print('replacing genitiv forms with dativ..')\n",
  580. " outsentences = gs.ReplaceGenitivWithDativ(insentences)\n",
  581. " check = 1\n",
  582. " #print(len(punctuations))\n",
  583. " #print('sentences after gs', outsentences)\n",
  584. " \n",
  585. " if check == 1:\n",
  586. " newinsentences = []\n",
  587. " for sentence in outsentences: \n",
  588. " newinsentences.append([word.replace('ö','oe').replace('ü','ue').replace('ä','ae').replace('ß','ss') for word in sentence])\n",
  589. " \n",
  590. " outsentences =newinsentences\n",
  591. " if check != 1:\n",
  592. " newinsentences = []\n",
  593. " for sentence in insentences: \n",
  594. " newinsentences.append([word.replace('ö','oe').replace('ü','ue').replace('ä','ae').replace('ß','ss') for word in sentence])\n",
  595. " \n",
  596. " insentences =newinsentences\n",
  597. " #print()\n",
  598. " if KonjunktiveErsetzen.value == True:\n",
  599. " if check == 1:\n",
  600. " insentences = outsentences\n",
  601. " print('ersetze Konjunktive..')\n",
  602. " \n",
  603. " outsentences = cs.replaceConjunctives(insentences)\n",
  604. " #print('outsentences')\n",
  605. " check = 1\n",
  606. " \n",
  607. " #print('sentences after cs', outsentences)\n",
  608. " print(len(punctuations))\n",
  609. " \n",
  610. " if FremdWB.value == True:\n",
  611. " if check == 1:\n",
  612. " insentences = outsentences\n",
  613. " print('Suche Woerterbucheintraege..')\n",
  614. " \n",
  615. " outsentences, punctuations = fwb.fremdEintragAppend(insentences, punctuations)\n",
  616. " #print('outsentences')\n",
  617. " check = 1\n",
  618. " \n",
  619. " if Medio.value == True:\n",
  620. " if check == 1:\n",
  621. " insentences = outsentences\n",
  622. " print('Ersetze lange Woerter mit Mediopunkten..')\n",
  623. " \n",
  624. " outsentences, punctuations = medi.Medioreplace(insentences, punctuations)\n",
  625. " #print('outsentences')\n",
  626. " check = 1\n",
  627. " #print('sentences after medios', outsentences)\n",
  628. " \n",
  629. " \n",
  630. " #print('sentences after fwb', outsentences)\n",
  631. " \n",
  632. " print(len(punctuations))\n",
  633. " \n",
  634. " if check == 1:\n",
  635. " out = ''\n",
  636. " #print('just before looking if the lenght is the same')\n",
  637. " #print(len(outsentences), len(punctuations))\n",
  638. " if len(outsentences) == len(punctuations):\n",
  639. " #print('the length is the same')\n",
  640. " for n in range(len(outsentences)):\n",
  641. " outsentence = outsentences[n]\n",
  642. " outsentence[0] = outsentence[0].title()\n",
  643. " out += ' '.join(outsentence) + punctuations[n] + '\\n'\n",
  644. " \n",
  645. " \n",
  646. " OutTextFeld.value = out\n",
  647. " TextFelddouble.value = TextFeld.value\n",
  648. " display(TextFelddouble)\n",
  649. " \n",
  650. " return \n",
  651. "\n"
  652. ]
  653. },
  654. {
  655. "cell_type": "code",
  656. "execution_count": null,
  657. "metadata": {
  658. "scrolled": false
  659. },
  660. "outputs": [],
  661. "source": []
  662. },
  663. {
  664. "cell_type": "code",
  665. "execution_count": 11,
  666. "metadata": {},
  667. "outputs": [
  668. {
  669. "data": {
  670. "application/vnd.jupyter.widget-view+json": {
  671. "model_id": "5b0d573af12e4e1f9276834123b062a7",
  672. "version_major": 2,
  673. "version_minor": 0
  674. },
  675. "text/plain": [
  676. "interactive(children=(Button(description='Übersetzen in Leichte Sprache', style=ButtonStyle()), Output()), _do…"
  677. ]
  678. },
  679. "metadata": {},
  680. "output_type": "display_data"
  681. }
  682. ],
  683. "source": [
  684. "#from IPython.display import Image\n",
  685. "#i = Image(filename='Babelfish.png')\n",
  686. "\n",
  687. "#i.width = '60%'\n",
  688. "#display(i)\n",
  689. "\n",
  690. "#print(widgets.interact_manual.opts)\n",
  691. "\n",
  692. "widgets.interact_manual.opts['manual_name']= 'Übersetzen in Leichte Sprache'\n",
  693. "ola = widgets.interact_manual(function)\n",
  694. "ola.widget.children[0].style.button_color = 'lightgreen'\n",
  695. "ola.widget.children[0].layout.height = '50px'\n",
  696. "ola.widget.children[0].layout.width = '99%'\n",
  697. "\n",
  698. "#widgets.GridBox([ola], layout=widgets.Layout(grid_template_columns=\"repeat(2, 300px)\"))"
  699. ]
  700. },
  701. {
  702. "cell_type": "code",
  703. "execution_count": 12,
  704. "metadata": {
  705. "scrolled": true
  706. },
  707. "outputs": [
  708. {
  709. "data": {
  710. "application/vnd.jupyter.widget-view+json": {
  711. "model_id": "be9b40c345ca4105a3810de0872fa144",
  712. "version_major": 2,
  713. "version_minor": 0
  714. },
  715. "text/plain": [
  716. "Textarea(value='', layout=Layout(height='180px', width='99%'), placeholder='Hier kommt der übersetzte Text her…"
  717. ]
  718. },
  719. "metadata": {},
  720. "output_type": "display_data"
  721. }
  722. ],
  723. "source": [
  724. "OutTextFeld = ipywidgets.Textarea(placeholder=out, disabled=False)\n",
  725. "OutTextFeld.layout.height = '180px'\n",
  726. "OutTextFeld.layout.width = '99%'\n",
  727. "OutTextFeld.add_class(\"thetext\")\n",
  728. "display(OutTextFeld)\n"
  729. ]
  730. },
  731. {
  732. "cell_type": "code",
  733. "execution_count": 13,
  734. "metadata": {},
  735. "outputs": [],
  736. "source": [
  737. "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",
  738. "VerbeTextFeld = ipywidgets.Textarea(placeholder=beschreibung, disabled=False)\n",
  739. "VerbeTextFeld.layout.height = '180px'\n",
  740. "VerbeTextFeld.layout.width = '99%'\n",
  741. "\n"
  742. ]
  743. },
  744. {
  745. "cell_type": "code",
  746. "execution_count": 14,
  747. "metadata": {},
  748. "outputs": [],
  749. "source": [
  750. "\n",
  751. "\n",
  752. "def Absendefunction():\n",
  753. " \n",
  754. " \n",
  755. "\n",
  756. " \n",
  757. " #print(VerbeTextFeld.value)\n",
  758. " #print(TextFeld.value)\n",
  759. " #print(OutTextFeld.value)\n",
  760. " \n",
  761. " try:\n",
  762. "\n",
  763. " insentences, punctuations = oi.CellInputText2SplitsentencesWithspacy(VerbeTextFeld.value)\n",
  764. " insentences1, punctuations1 = oi.CellInputText2SplitsentencesWithspacy(TextFeld.value)\n",
  765. " insentences2, punctuations2 = oi.CellInputText2SplitsentencesWithspacy(OutTextFeld.value)\n",
  766. "\n",
  767. " #print(insentences2)\n",
  768. "\n",
  769. " #print(insentences, punctuations)\n",
  770. " indexDerVerbesserungen = 0\n",
  771. " number = 0\n",
  772. " with open('Verbesserungen/indexDerVerbesserungen.txt', 'r') as dok:\n",
  773. " for number in dok:\n",
  774. " number = int(number)\n",
  775. " if number >= 0:\n",
  776. " indexDerVerbesserungen = number\n",
  777. " number += 1\n",
  778. "\n",
  779. " with open('Verbesserungen/indexDerVerbesserungen.txt', 'w') as dokk:\n",
  780. " dokk.write(str(number))\n",
  781. "\n",
  782. "\n",
  783. " with open('Verbesserungen/Verbesserungen' + str(number) + '.txt','w+') as doc:\n",
  784. " for n in range(len(insentences)):\n",
  785. " npunct = punctuations[n]\n",
  786. " writeline = insentences[n]+ [npunct]\n",
  787. "\n",
  788. " writestring = ' '.join(writeline)\n",
  789. "\n",
  790. " doc.write(writestring + '\\n')\n",
  791. "\n",
  792. " with open('Verbesserungen/Input' + str(number) + '.txt','w+') as docc:\n",
  793. " for n in range(len(insentences1)):\n",
  794. " npunct = punctuations1[n]\n",
  795. " writeline = insentences1[n]+ [npunct]\n",
  796. "\n",
  797. " writestring = ' '.join(writeline)\n",
  798. "\n",
  799. " docc.write(writestring + '\\n')\n",
  800. " with open('Verbesserungen/Output' + str(number) + '.txt','w+') as dock:\n",
  801. " #print(insentences2)\n",
  802. " for n in range(len(insentences2)):\n",
  803. " #print(len(insentences2))\n",
  804. "\n",
  805. " #print(punctuations2)\n",
  806. " npunct = punctuations2[n]\n",
  807. " writeline = insentences2[n]+ [npunct]\n",
  808. "\n",
  809. " writestring = ' '.join(writeline)\n",
  810. "\n",
  811. " dock.write(writestring + '\\n')\n",
  812. "\n",
  813. " VerbeTextFeld.value = ''\n",
  814. " OutTextFeld.value = ''\n",
  815. " VerbeTextFeld.placeholder = beschreibung\n",
  816. " OutTextFeld.placeholder = 'Hier kommt der übersetzte Text raus.'\n",
  817. " except:\n",
  818. " VerbeTextFeld.placeholder = 'Es gab einen Fehler. Eventuell ist die Zeichensetzung nicht ok. \\n \\n' + beschreibung\n",
  819. " \n",
  820. " \n",
  821. " return \n",
  822. "\n"
  823. ]
  824. },
  825. {
  826. "cell_type": "code",
  827. "execution_count": 15,
  828. "metadata": {},
  829. "outputs": [
  830. {
  831. "data": {
  832. "application/vnd.jupyter.widget-view+json": {
  833. "model_id": "01404ad96cc34dd5af96915447731bea",
  834. "version_major": 2,
  835. "version_minor": 0
  836. },
  837. "text/plain": [
  838. "Textarea(value='', layout=Layout(height='180px', width='99%'), placeholder=\"Textfeld für die verbesserte Übers…"
  839. ]
  840. },
  841. "metadata": {},
  842. "output_type": "display_data"
  843. },
  844. {
  845. "data": {
  846. "text/html": [
  847. "<br>"
  848. ],
  849. "text/plain": [
  850. "<IPython.core.display.HTML object>"
  851. ]
  852. },
  853. "metadata": {},
  854. "output_type": "display_data"
  855. },
  856. {
  857. "data": {
  858. "application/vnd.jupyter.widget-view+json": {
  859. "model_id": "39c27a696cbd470fa8f5c58d10460336",
  860. "version_major": 2,
  861. "version_minor": 0
  862. },
  863. "text/plain": [
  864. "interactive(children=(Button(description='Absenden', style=ButtonStyle()), Output()), _dom_classes=('widget-in…"
  865. ]
  866. },
  867. "metadata": {},
  868. "output_type": "display_data"
  869. }
  870. ],
  871. "source": [
  872. "VerbeTextFeld.add_class(\"thetext3\")\n",
  873. "display(VerbeTextFeld)\n",
  874. "display(HTML('<br>'))\n",
  875. "widgets.interact_manual.opts['manual_name']= 'Absenden'\n",
  876. "AbsendenUndSchreiben = widgets.interact_manual(Absendefunction)\n",
  877. "AbsendenUndSchreiben.widget.children[0].style.button_color = 'lightblue'\n",
  878. "AbsendenUndSchreiben.widget.children[0].layout.height = '50px'\n",
  879. "AbsendenUndSchreiben.widget.children[0].layout.width = '99%'\n",
  880. "\n"
  881. ]
  882. },
  883. {
  884. "cell_type": "code",
  885. "execution_count": 16,
  886. "metadata": {},
  887. "outputs": [
  888. {
  889. "data": {
  890. "text/html": [
  891. "<style>\n",
  892. ".output_png {\n",
  893. " display: table-cell;\n",
  894. " text-align: center;\n",
  895. " vertical-align: middle;\n",
  896. " }\n",
  897. ".jupyter-button {\n",
  898. " text-shadow: -1px -1px rgba(255, 255, 255, 0.35), 1px 1px rgba(0, 0, 0, 0.40);\n",
  899. " font-family: 'Lato', sans-serif;\n",
  900. " text-decoration: none;\n",
  901. " letter-spacing: .06rem;\n",
  902. " font-size: 90%;\n",
  903. " font-weight: bold;\n",
  904. " color: rgba(0, 0, 0, 0.3);\n",
  905. " background-color: pink;\n",
  906. " border-radius: 20px;\n",
  907. " transition: all 0.2s cubic-bezier(0, 0.22, .3, 1);\n",
  908. " #box-shadow: inset 0 2px 0 rgba(255,255,255,0.5), 0 2px 2px rgba(0, 0, 0, 0.19);\n",
  909. " box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.29);\n",
  910. " }\n",
  911. "\n",
  912. ".jupyter-button.mod-active {\n",
  913. " \n",
  914. " color: rgba(0, 0, 0, 0.4);\n",
  915. " background-color: lightgreen;\n",
  916. "}\n",
  917. ".jupyter-button:hover {\n",
  918. " background-color: .jupyter-button.background-color;\n",
  919. " opacity: 0.6;\n",
  920. " color: rgba(0, 0, 0, 0.3);\n",
  921. "}\n",
  922. "</style>\n"
  923. ],
  924. "text/plain": [
  925. "<IPython.core.display.HTML object>"
  926. ]
  927. },
  928. "metadata": {},
  929. "output_type": "display_data"
  930. }
  931. ],
  932. "source": [
  933. "%%html\n",
  934. "<style>\n",
  935. ".output_png {\n",
  936. " display: table-cell;\n",
  937. " text-align: center;\n",
  938. " vertical-align: middle;\n",
  939. " }\n",
  940. ".jupyter-button {\n",
  941. " text-shadow: -1px -1px rgba(255, 255, 255, 0.35), 1px 1px rgba(0, 0, 0, 0.40);\n",
  942. " font-family: 'Lato', sans-serif;\n",
  943. " text-decoration: none;\n",
  944. " letter-spacing: .06rem;\n",
  945. " font-size: 90%;\n",
  946. " font-weight: bold;\n",
  947. " color: rgba(0, 0, 0, 0.3);\n",
  948. " background-color: pink;\n",
  949. " border-radius: 20px;\n",
  950. " transition: all 0.2s cubic-bezier(0, 0.22, .3, 1);\n",
  951. " #box-shadow: inset 0 2px 0 rgba(255,255,255,0.5), 0 2px 2px rgba(0, 0, 0, 0.19);\n",
  952. " box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.29);\n",
  953. " }\n",
  954. "\n",
  955. ".jupyter-button.mod-active {\n",
  956. " \n",
  957. " color: rgba(0, 0, 0, 0.4);\n",
  958. " background-color: lightgreen;\n",
  959. "}\n",
  960. ".jupyter-button:hover {\n",
  961. " background-color: .jupyter-button.background-color;\n",
  962. " opacity: 0.6;\n",
  963. " color: rgba(0, 0, 0, 0.3);\n",
  964. "}\n",
  965. "</style>"
  966. ]
  967. },
  968. {
  969. "cell_type": "code",
  970. "execution_count": 17,
  971. "metadata": {},
  972. "outputs": [
  973. {
  974. "data": {
  975. "text/html": [
  976. "<style>\n",
  977. ".thetext > .widget-label {\n",
  978. " font-style: italic;\n",
  979. " color: blue;\n",
  980. " font-size: 30px;\n",
  981. "}\n",
  982. ".thetext > textarea {\n",
  983. " padding: 10px 0 0 10px;\n",
  984. " resize: none;\n",
  985. " font-size: 15px;\n",
  986. " color: black;\n",
  987. " background-color: lightgreen;\n",
  988. " border-radius: 20px;\n",
  989. " border-width : 0px\n",
  990. " transition: all 0.3s cubic-bezier(0, 0.22, .3, 1);\n",
  991. " #box-shadow: inset 0 2px 0 rgba(255,255,255,0.5), 0 2px 2px rgba(0, 0, 0, 0.19);\n",
  992. " box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.29);\n",
  993. "}\n",
  994. ".thetext > ::placeholder {\n",
  995. " opacity: 0.5;\n",
  996. " \n",
  997. "}\n",
  998. ".thetext3 > .widget-label {\n",
  999. " \n",
  1000. " font-style: ;\n",
  1001. " color: blue;\n",
  1002. " font-size: 20px;\n",
  1003. "}\n",
  1004. ".thetext3 > textarea {\n",
  1005. " padding: 10px 0 0 10px;\n",
  1006. " resize: none;\n",
  1007. " font-size: 15px;\n",
  1008. " color: black;\n",
  1009. " background-color: lightblue;\n",
  1010. " border-radius: 20px;\n",
  1011. " border-width : 0px\n",
  1012. " transition: all 0.3s cubic-bezier(0, 0.22, .3, 1);\n",
  1013. " #box-shadow: inset 0 2px 0 rgba(255,255,255,0.5), 0 2px 2px rgba(0, 0, 0, 0.19);\n",
  1014. " box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.29);\n",
  1015. "}\n",
  1016. ".thetext3 > ::placeholder {\n",
  1017. " opacity: 0.5;\n",
  1018. " \n",
  1019. "}\n",
  1020. "</style>\n"
  1021. ],
  1022. "text/plain": [
  1023. "<IPython.core.display.HTML object>"
  1024. ]
  1025. },
  1026. "metadata": {},
  1027. "output_type": "display_data"
  1028. }
  1029. ],
  1030. "source": [
  1031. "%%html\n",
  1032. "<style>\n",
  1033. ".thetext > .widget-label {\n",
  1034. " font-style: italic;\n",
  1035. " color: blue;\n",
  1036. " font-size: 30px;\n",
  1037. "}\n",
  1038. ".thetext > textarea {\n",
  1039. " padding: 10px 0 0 10px;\n",
  1040. " resize: none;\n",
  1041. " font-size: 15px;\n",
  1042. " color: black;\n",
  1043. " background-color: lightgreen;\n",
  1044. " border-radius: 20px;\n",
  1045. " border-width : 0px\n",
  1046. " transition: all 0.3s cubic-bezier(0, 0.22, .3, 1);\n",
  1047. " #box-shadow: inset 0 2px 0 rgba(255,255,255,0.5), 0 2px 2px rgba(0, 0, 0, 0.19);\n",
  1048. " box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.29);\n",
  1049. "}\n",
  1050. ".thetext > ::placeholder {\n",
  1051. " opacity: 0.5;\n",
  1052. " \n",
  1053. "}\n",
  1054. ".thetext3 > .widget-label {\n",
  1055. " \n",
  1056. " font-style: ;\n",
  1057. " color: blue;\n",
  1058. " font-size: 20px;\n",
  1059. "}\n",
  1060. ".thetext3 > textarea {\n",
  1061. " padding: 10px 0 0 10px;\n",
  1062. " resize: none;\n",
  1063. " font-size: 15px;\n",
  1064. " color: black;\n",
  1065. " background-color: lightblue;\n",
  1066. " border-radius: 20px;\n",
  1067. " border-width : 0px\n",
  1068. " transition: all 0.3s cubic-bezier(0, 0.22, .3, 1);\n",
  1069. " #box-shadow: inset 0 2px 0 rgba(255,255,255,0.5), 0 2px 2px rgba(0, 0, 0, 0.19);\n",
  1070. " box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.29);\n",
  1071. "}\n",
  1072. ".thetext3 > ::placeholder {\n",
  1073. " opacity: 0.5;\n",
  1074. " \n",
  1075. "}\n",
  1076. "</style>"
  1077. ]
  1078. },
  1079. {
  1080. "cell_type": "code",
  1081. "execution_count": 18,
  1082. "metadata": {
  1083. "scrolled": false
  1084. },
  1085. "outputs": [
  1086. {
  1087. "data": {
  1088. "text/html": [
  1089. "<style>\n",
  1090. ".thotext > .widget-label {\n",
  1091. " font-style: ;\n",
  1092. " color: blue;\n",
  1093. " font-size: 30px;\n",
  1094. " \n",
  1095. "}\n",
  1096. ".thotext > textarea {\n",
  1097. " padding: 10px 0 0 10px;\n",
  1098. " resize: none;\n",
  1099. " font-size: 15px;\n",
  1100. " color: black;\n",
  1101. " background-color: lightgreen;\n",
  1102. " border-radius: 20px;\n",
  1103. " border-width : 0px\n",
  1104. " transition: all 0.3s cubic-bezier(0, 0.22, .3, 1);\n",
  1105. " #box-shadow: inset 0 2px 0 rgba(255,255,255,0.5), 0 2px 2px rgba(0, 0, 0, 0.19);\n",
  1106. " box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.29);\n",
  1107. "}\n",
  1108. ".thotext > ::placeholder {\n",
  1109. " opacity: 0.5;\n",
  1110. " \n",
  1111. "}\n",
  1112. "\n",
  1113. "</style>\n"
  1114. ],
  1115. "text/plain": [
  1116. "<IPython.core.display.HTML object>"
  1117. ]
  1118. },
  1119. "metadata": {},
  1120. "output_type": "display_data"
  1121. }
  1122. ],
  1123. "source": [
  1124. "%%html\n",
  1125. "<style>\n",
  1126. ".thotext > .widget-label {\n",
  1127. " font-style: ;\n",
  1128. " color: blue;\n",
  1129. " font-size: 30px;\n",
  1130. " \n",
  1131. "}\n",
  1132. ".thotext > textarea {\n",
  1133. " padding: 10px 0 0 10px;\n",
  1134. " resize: none;\n",
  1135. " font-size: 15px;\n",
  1136. " color: black;\n",
  1137. " background-color: lightgreen;\n",
  1138. " border-radius: 20px;\n",
  1139. " border-width : 0px\n",
  1140. " transition: all 0.3s cubic-bezier(0, 0.22, .3, 1);\n",
  1141. " #box-shadow: inset 0 2px 0 rgba(255,255,255,0.5), 0 2px 2px rgba(0, 0, 0, 0.19);\n",
  1142. " box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.29);\n",
  1143. "}\n",
  1144. ".thotext > ::placeholder {\n",
  1145. " opacity: 0.5;\n",
  1146. " \n",
  1147. "}\n",
  1148. "\n",
  1149. "</style>"
  1150. ]
  1151. },
  1152. {
  1153. "cell_type": "code",
  1154. "execution_count": null,
  1155. "metadata": {},
  1156. "outputs": [],
  1157. "source": []
  1158. },
  1159. {
  1160. "cell_type": "code",
  1161. "execution_count": null,
  1162. "metadata": {},
  1163. "outputs": [],
  1164. "source": []
  1165. }
  1166. ],
  1167. "metadata": {
  1168. "celltoolbar": "Raw Cell Format",
  1169. "kernelspec": {
  1170. "display_name": "Python 3",
  1171. "language": "python",
  1172. "name": "python3"
  1173. },
  1174. "language_info": {
  1175. "codemirror_mode": {
  1176. "name": "ipython",
  1177. "version": 3
  1178. },
  1179. "file_extension": ".py",
  1180. "mimetype": "text/x-python",
  1181. "name": "python",
  1182. "nbconvert_exporter": "python",
  1183. "pygments_lexer": "ipython3",
  1184. "version": "3.5.3"
  1185. }
  1186. },
  1187. "nbformat": 4,
  1188. "nbformat_minor": 2
  1189. }