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.

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