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.

264 lines
6.1 KiB

4 years ago
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {},
  7. "outputs": [],
  8. "source": [
  9. "import SentSeg\n"
  10. ]
  11. },
  12. {
  13. "cell_type": "code",
  14. "execution_count": 3,
  15. "metadata": {},
  16. "outputs": [
  17. {
  18. "name": "stdout",
  19. "output_type": "stream",
  20. "text": [
  21. "[[['Hallo', 'was', 'gehe', 'denn', 'hier', 'so.']], [['Ich', 'habe', 'echt', 'keine', 'Ahnung', 'verdammt.']], [['I.', 'd.', 'R.', 'gibt', 'es', 'keine', 'Abschiebungen.']], [['Ende', 'd.', 'J.', 'wird', 'alles', 'problematisch.']], [['Sie', 'gingen', 'nach', 'Hause,', 'weil', 'es', 'in', 'Strömen', 'regnete.']], [['Heute', 'war', 'die', 'Straße', 'blau', 'angemalt,', 'damit', 'der', 'Marathon', 'funktionierte.']], [['Er', 'habe', 'es', 'sehr', 'schwer.']], [['Es', 'war', 'die', 'Hose', 'des', 'Gauners.']], [['Bliblablub.']], [['Sie', 'ist', 'nicht', 'schön', 'heute.']], [['Oleoleole.']], [['Mannoman.']], [['Er', 'ginge', 'nicht', 'schnell.']], [['Die', 'Hühner', 'lieben', 'sich', 'nicht.']]]\n"
  22. ]
  23. }
  24. ],
  25. "source": [
  26. "sent_seg = SentSeg.SentSeg('de')\n",
  27. "\n",
  28. " \n",
  29. "sentences = sent_seg.ReadDoc2Sent('atest1')\n",
  30. "print(sentences)"
  31. ]
  32. },
  33. {
  34. "cell_type": "code",
  35. "execution_count": 4,
  36. "metadata": {},
  37. "outputs": [
  38. {
  39. "name": "stdout",
  40. "output_type": "stream",
  41. "text": [
  42. "initializing the gs utils..\n",
  43. "loading spacy..\n",
  44. "done\n",
  45. "done\n",
  46. "loading the Stochastic Gradient models..\n",
  47. "done\n",
  48. "initializing the SGM..\n",
  49. "loading vectorizer..\n",
  50. "done\n",
  51. "loading the SGD model..\n",
  52. "done\n",
  53. "loading spacy..\n",
  54. "done\n",
  55. "done\n",
  56. "importing spacy..\n",
  57. "done\n",
  58. "importing german model..\n",
  59. "done\n"
  60. ]
  61. },
  62. {
  63. "data": {
  64. "text/plain": [
  65. "'done'"
  66. ]
  67. },
  68. "execution_count": 4,
  69. "metadata": {},
  70. "output_type": "execute_result"
  71. }
  72. ],
  73. "source": [
  74. "sent_seg.LoadSentGlueSGDandGSUtils()"
  75. ]
  76. },
  77. {
  78. "cell_type": "code",
  79. "execution_count": 5,
  80. "metadata": {},
  81. "outputs": [
  82. {
  83. "name": "stdout",
  84. "output_type": "stream",
  85. "text": [
  86. "creating array of comma or not..\n",
  87. "done\n"
  88. ]
  89. }
  90. ],
  91. "source": [
  92. "sentences = sent_seg.CommaSentenceOrNot(sentences)\n",
  93. "print(sentences)"
  94. ]
  95. },
  96. {
  97. "cell_type": "code",
  98. "execution_count": 6,
  99. "metadata": {},
  100. "outputs": [],
  101. "source": [
  102. "sentences = sent_seg.GetUtteranceNumber(sentences)"
  103. ]
  104. },
  105. {
  106. "cell_type": "code",
  107. "execution_count": 7,
  108. "metadata": {},
  109. "outputs": [],
  110. "source": [
  111. "sentences = sent_seg.GetQuestionOrNot(sentences)"
  112. ]
  113. },
  114. {
  115. "cell_type": "code",
  116. "execution_count": 8,
  117. "metadata": {},
  118. "outputs": [
  119. {
  120. "name": "stdout",
  121. "output_type": "stream",
  122. "text": [
  123. "importing spacy..\n",
  124. "done\n"
  125. ]
  126. }
  127. ],
  128. "source": [
  129. "sentences1 = sent_seg.SplitSentencesIntoHauptNebenTuple(sentences)"
  130. ]
  131. },
  132. {
  133. "cell_type": "code",
  134. "execution_count": 9,
  135. "metadata": {},
  136. "outputs": [
  137. {
  138. "name": "stdout",
  139. "output_type": "stream",
  140. "text": [
  141. "['es', 'regnete', 'in Strömen']\n",
  142. "['deswegen', 'Sie', 'gingen', 'nach Hause']\n",
  143. "['Heute', 'war', 'blau', 'angemalt', 'die Straße']\n",
  144. "100\n",
  145. "['dann', 'funktionierte', 'der Marathon']\n"
  146. ]
  147. }
  148. ],
  149. "source": [
  150. "outsentences = sent_seg.SplitCommatas(sentences1)"
  151. ]
  152. },
  153. {
  154. "cell_type": "code",
  155. "execution_count": 18,
  156. "metadata": {},
  157. "outputs": [
  158. {
  159. "name": "stdout",
  160. "output_type": "stream",
  161. "text": [
  162. "[['Hallo', 'was', 'gehe', 'denn', 'hier', 'so'], ['Ich', 'habe', 'echt', 'keine', 'Ahnung', 'verdammt'], ['I.', 'd.', 'R.', 'gibt', 'es', 'keine', 'Abschiebungen'], ['Ende', 'd.', 'J.', 'wird', 'alles', 'problematisch'], ['in', 'Strömen', 'regnete', 'e'], ['deswegen', 'gingen', 'Sie', 'nach', 'Haus'], ['angemalt', 'war', 'die', 'Straße', 'blau', 'Heut'], ['dann', 'der', 'Marathon', 'funktioniert'], ['Er', 'habe', 'es', 'sehr', 'schwer'], ['Es', 'war', 'die', 'Hose', 'des', 'Gauners'], ['Bliblablub'], ['Oleoleole'], ['Mannoman'], ['Er', 'ginge', 'nicht', 'schnell'], ['Der', 'Satz', 'davor', 'funktioniert', 'nicht', 'im', 'Modul', 'Konjunktsolve'], ['Weil', 'er', 'zu', 'viele', 'verben', 'hat']]\n"
  163. ]
  164. }
  165. ],
  166. "source": [
  167. "print(outsentences)"
  168. ]
  169. },
  170. {
  171. "cell_type": "code",
  172. "execution_count": 19,
  173. "metadata": {},
  174. "outputs": [],
  175. "source": [
  176. "punctuations = []\n",
  177. "for n in range(len(outsentences)):\n",
  178. " punctuations.append('.')\n",
  179. " if outsentences[n][-1][-1] == '.':\n",
  180. " outsentences[n][-1] = outsentences[n][-1][:-1]"
  181. ]
  182. },
  183. {
  184. "cell_type": "code",
  185. "execution_count": 20,
  186. "metadata": {},
  187. "outputs": [],
  188. "source": [
  189. "from oi import *\n",
  190. "oi = oi()"
  191. ]
  192. },
  193. {
  194. "cell_type": "code",
  195. "execution_count": 21,
  196. "metadata": {},
  197. "outputs": [
  198. {
  199. "name": "stdout",
  200. "output_type": "stream",
  201. "text": [
  202. ".\n",
  203. ".\n",
  204. ".\n",
  205. ".\n",
  206. ".\n",
  207. ".\n",
  208. ".\n",
  209. ".\n",
  210. ".\n",
  211. ".\n",
  212. ".\n",
  213. ".\n",
  214. ".\n",
  215. ".\n",
  216. ".\n",
  217. ".\n"
  218. ]
  219. },
  220. {
  221. "data": {
  222. "text/plain": [
  223. "'OK'"
  224. ]
  225. },
  226. "execution_count": 21,
  227. "metadata": {},
  228. "output_type": "execute_result"
  229. }
  230. ],
  231. "source": [
  232. "oi.PrintSplitSentencesToTextFile(punctuations, outsentences, 'test1out')\n"
  233. ]
  234. },
  235. {
  236. "cell_type": "code",
  237. "execution_count": null,
  238. "metadata": {},
  239. "outputs": [],
  240. "source": []
  241. }
  242. ],
  243. "metadata": {
  244. "kernelspec": {
  245. "display_name": "Python 3",
  246. "language": "python",
  247. "name": "python3"
  248. },
  249. "language_info": {
  250. "codemirror_mode": {
  251. "name": "ipython",
  252. "version": 3
  253. },
  254. "file_extension": ".py",
  255. "mimetype": "text/x-python",
  256. "name": "python",
  257. "nbconvert_exporter": "python",
  258. "pygments_lexer": "ipython3",
  259. "version": "3.5.3"
  260. }
  261. },
  262. "nbformat": 4,
  263. "nbformat_minor": 2
  264. }