diff --git a/info4/kapitel-2/RegulaereAusdruecke.ipynb b/info4/kapitel-2/RegulaereAusdruecke.ipynb index 09323d44135a06c09f872a046d58f48db049c89e..3283846ec4ea0dcd6199ee7def0c80919bece684 100644 --- a/info4/kapitel-2/RegulaereAusdruecke.ipynb +++ b/info4/kapitel-2/RegulaereAusdruecke.ipynb @@ -38,7 +38,8 @@ "* $\\{\\lambda\\}$ falls $\\gamma = \\lambda$\n", "* $\\{a\\}$ falls $\\gamma = a$ für ein $a \\in \\Sigma$\n", "* $L(\\alpha) L(\\beta)$ falls $\\gamma = \\alpha \\beta$\n", - "* $L(\\alpha) \\cup L(\\beta)$ falls $\\gamma = (\\alpha + \\beta)$" + "* $L(\\alpha) \\cup L(\\beta)$ falls $\\gamma = (\\alpha + \\beta)$\n", + "* $L(\\alpha)^{*}$ falls $\\gamma = (\\alpha)^{*}$." ] }, { @@ -58,7 +59,14 @@ "Der reguläre Ausdruck \n", "* $\\alpha_1 = (\\lambda + a(a+b)^{*})$\n", "beschreibt die Sprache\n", - "* $L(\\alpha_1) = \\{\\lambda\\} \\cup \\{ax \\mid x \\in \\{a,b\\}^{*}\\}$\n", + "* $L(\\alpha_1)$ = \n", + "* $L(\\lambda + a(a+b)^{*})$ =\n", + "* $L(\\lambda) \\cup L(a(a+b)^{*})$ =\n", + "* $\\{\\lambda\\} \\cup L(a)L((a+b)^{*})$ =\n", + "* $\\{\\lambda\\} \\cup \\{a\\}(L(a+b))^{*}$ =\n", + "* $\\{\\lambda\\} \\cup \\{a\\}(L(a)\\cup L(b))^{*}$ =\n", + "* $\\{\\lambda\\} \\cup \\{a\\}(\\{a,b\\})^{*}$ =\n", + "* $\\{\\lambda\\} \\cup \\{ax \\mid x \\in \\{a,b\\}^{*}\\}$\n", "d.h. das leere Wort und alle Wörter über $\\Sigma$, die mit $a$\n", "beginnen.\n", "\n", @@ -77,7 +85,8 @@ "\n", "Um mit den praktischen Aspekten der regulären Ausdrücke zu experimentieren laden wir eine Bibliothek.\n", "In dieser Bibliothek wird der Plus Operator anders geschrieben: ```a|b```.\n", - "Es gibt nicht den regulären Ausdruck $\\emptyset$, aber dafür viele andere (abgeleitete) Operatoren (syntaktische Zucker), zum Beispiel:\n", + "\n", + "Es gibt auch nicht den regulären Ausdruck $\\emptyset$, aber dafür viele andere (abgeleitete) Operatoren (sogenannter syntaktischer Zucker), zum Beispiel:\n", "* $\\alpha^+$ als Kürzel für $\\alpha(\\alpha)^*$\n", "* [a-z] als Kürzel für $(a+b+c+d+...+z)$\n", "\n" @@ -85,7 +94,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -94,7 +103,7 @@ "Loaded machine: Regex" ] }, - "execution_count": 1, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -108,7 +117,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -117,7 +126,7 @@ "Machine initialised using operation 0: $initialise_machine()" ] }, - "execution_count": 2, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -135,7 +144,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -147,7 +156,7 @@ "TRUE" ] }, - "execution_count": 3, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -158,7 +167,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -170,18 +179,18 @@ "TRUE" ] }, - "execution_count": 4, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "REGEX_MATCH(\"b\",\"a|b\")" + "REGEX_MATCH(\"a\",\"a|b\")" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -193,18 +202,18 @@ "TRUE" ] }, - "execution_count": 5, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "REGEX_MATCH(\"aa\",\"a*\")" + "REGEX_MATCH(\"aaaaaaa\",\"a*\")" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -216,7 +225,7 @@ "TRUE" ] }, - "execution_count": 6, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -235,25 +244,25 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\mathit{rec}(\\mathit{length}\\in 3,\\mathit{position}\\in 1,\\mathit{string}\\in\\text{\"aab\"},\\mathit{submatches}\\in\\emptyset)$" + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\mathit{rec}(\\mathit{length}\\in 3,\\mathit{position}\\in 4,\\mathit{string}\\in\\text{\"aab\"},\\mathit{submatches}\\in\\emptyset)$" ], "text/plain": [ - "rec(length∈3,position∈1,string∈\"aab\",submatches∈∅)" + "rec(length∈3,position∈4,string∈\"aab\",submatches∈∅)" ] }, - "execution_count": 7, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "REGEX_SEARCH(\"aabc\",1,\"a*b\")" + "REGEX_SEARCH(\"xxxaabc\",1,\"a*b\")" ] }, { @@ -265,7 +274,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 21, "metadata": {}, "outputs": [ { @@ -277,7 +286,7 @@ "{(1↦\"aab\"),(2↦\"bb\"),(3↦\"a\")}" ] }, - "execution_count": 8, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -296,7 +305,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 22, "metadata": {}, "outputs": [ { @@ -308,7 +317,7 @@ "\"\\nFAUST:\\n Habe nun, ach! Philosophie,\\n Juristerei und Medizin,\\n Und leider auch Theologie\\n Durchaus studiert, mit heißem Bemühn.\\n Da steh ich nun, ich armer Tor!\\n Und bin so klug als wie zuvor;\\n Heiße Magister, heiße Doktor gar\\n Und ziehe schon an die zehen Jahr\\n Herauf, herab und quer und krumm\\n Meine Schüler an der Nase herum-\\n Und sehe, daß wir nichts wissen können!\\n Das will mir schier das Herz verbrennen.\\n Zwar bin ich gescheiter als all die Laffen,\\n Doktoren, Magister, Schreiber und Pfaffen;\\n Mich plagen keine Skrupel noch Zweifel,\\n Fürchte mich weder vor Hölle noch Teufel-\\n Dafür ist mir auch alle Freud entrissen,\\n Bilde mir nicht ein, was Rechts zu wissen,\\n Bilde mir nicht ein, ich könnte was lehren,\\n Die Menschen zu bessern und zu bekehren.\\n Auch hab ich weder Gut noch Geld,\\n Noch Ehr und Herrlichkeit der Welt;\\n Es möchte kein Hund so länger leben!\\n Drum hab ich mich der Magie ergeben,\\n Ob mir durch Geistes Kraft und Mund\\n Nicht manch Geheimnis würde kund;\\n Daß ich nicht mehr mit saurem Schweiß\\n Zu sagen brauche, was ich nicht weiß;\\n Daß ich erkenne, was die Welt\\n Im Innersten zusammenhält,\\n Schau alle Wirkenskraft und Samen,\\n Und tu nicht mehr in Worten kramen.\\n \"" ] }, - "execution_count": 9, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -353,7 +362,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -365,7 +374,7 @@ "{(1↦\"ich\"),(2↦\"ich\"),(3↦\"ich\"),(4↦\"ich\"),(5↦\"ich\"),(6↦\"ich\"),(7↦\"ich\"),(8↦\"ich\"),(9↦\"ich\"),(10↦\"ich\"),(11↦\"ich\"),(12↦\"ich\"),(13↦\"ich\"),(14↦\"ich\"),(15↦\"ich\"),(16↦\"ich\"),(17↦\"ich\"),(18↦\"ich\"),(19↦\"ich\"),(20↦\"ich\")}" ] }, - "execution_count": 10, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -376,7 +385,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -388,7 +397,7 @@ "rec(length∈3,position∈802,string∈\"Gut\",submatches∈∅)" ] }, - "execution_count": 11, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -399,7 +408,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -411,7 +420,7 @@ "{(1↦\"Gut\"),(2↦\"Geld\"),(3↦\"Geistes\"),(4↦\"Geheimnis\")}" ] }, - "execution_count": 12, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -422,10 +431,56 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto\\text{\"der Nase\"}),(2\\mapsto\\text{\"der Gut\"}),(3\\mapsto\\text{\"der Welt\"}),(4\\mapsto\\text{\"der Magie\"})\\}$" + ], + "text/plain": [ + "{(1↦\"der Nase\"),(2↦\"der Gut\"),(3↦\"der Welt\"),(4↦\"der Magie\")}" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH_ALL(txt,\"der ([A-Z][a-z]*)\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Kleine Anmerkung: mit Klammern kann man oft Gruppen bilden und herausfinden welches Teilwort von einer Gruppe generiert wurde." + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\mathit{rec}(\\mathit{length}\\in 8,\\mathit{position}\\in 326,\\mathit{string}\\in\\text{\"der Nase\"},\\mathit{submatches}\\in\\{(1\\mapsto\\text{\"Nase\"})\\})$" + ], + "text/plain": [ + "rec(length∈8,position∈326,string∈\"der Nase\",submatches∈{(1↦\"Nase\")})" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH(txt,1,\"der ([A-Z][a-z]*)\")" + ] }, { "cell_type": "markdown", @@ -440,7 +495,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -452,7 +507,7 @@ "{(1↦\"Geld\"),(2↦\"Geis\"),(3↦\"Gehe\")}" ] }, - "execution_count": 13, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -463,7 +518,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 29, "metadata": {}, "outputs": [ { @@ -475,7 +530,7 @@ "{(1↦\"Geld\"),(2↦\"Geistes\"),(3↦\"Geheimnis\")}" ] }, - "execution_count": 14, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -486,7 +541,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -498,7 +553,7 @@ "{(1↦\"Gut\"),(2↦\"Geld\"),(3↦\"Geis\"),(4↦\"Gehe\")}" ] }, - "execution_count": 15, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -517,7 +572,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 31, "metadata": {}, "outputs": [ { @@ -529,7 +584,7 @@ "rec(length∈1,position∈1,string∈\"a\",submatches∈∅)" ] }, - "execution_count": 16, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -540,7 +595,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -552,7 +607,7 @@ "rec(length∈3,position∈4,string∈\"a|b\",submatches∈∅)" ] }, - "execution_count": 17, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -563,7 +618,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -575,7 +630,7 @@ "rec(length∈1,position∈1,string∈\"a\",submatches∈∅)" ] }, - "execution_count": 18, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -586,7 +641,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 34, "metadata": {}, "outputs": [ { @@ -598,7 +653,7 @@ "rec(length∈2,position∈4,string∈\"a+\",submatches∈∅)" ] }, - "execution_count": 19, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -618,14 +673,14 @@ "* ```\\S``` für ein Zeichen, dass kein Leerzeichen ist\n", "* ```\\w``` für ein alpha-numerisches Zeichen oder den Underscore\n", "* ```\\W``` für ein Zeichen, dass kein alpha-numerisches Zeichen und kein Underscore ist\n", - "* ```.``` für all Zeichen ausser Zeilenumbrüche\n", + "* ```.``` für alle Zeichen ausser Zeilenumbrüchen\n", "* ```\\n``` für einen Zeilenumbruch\n", "* ```\\t``` für ein Tabulatorzeichen\n" ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 35, "metadata": {}, "outputs": [ { @@ -637,7 +692,7 @@ "{(1↦\"ab\"),(2↦\"cd\"),(3↦\"ef\")}" ] }, - "execution_count": 20, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -648,7 +703,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 36, "metadata": {}, "outputs": [ { @@ -660,7 +715,7 @@ "{(1↦\"FAUST\"),(2↦\"Habe\"),(3↦\"nun\"),(4↦\"ach\"),(5↦\"Philosophie\"),(6↦\"Juristerei\"),(7↦\"und\"),(8↦\"Medizin\"),(9↦\"Und\"),(10↦\"leider\"),(11↦\"auch\"),(12↦\"Theologie\"),(13↦\"Durchaus\"),(14↦\"studiert\"),(15↦\"mit\"),(16↦\"heißem\"),(17↦\"Bemühn\"),(18↦\"Da\"),(19↦\"steh\"),(20↦\"ich\"),(21↦\"nun\"),(22↦\"ich\"),(23↦\"armer\"),(24↦\"Tor\"),(25↦\"Und\"),(26↦\"bin\"),(27↦\"so\"),(28↦\"klug\"),(29↦\"als\"),(30↦\"wie\"),(31↦\"zuvor\"),(32↦\"Heiße\"),(33↦\"Magister\"),(34↦\"heiße\"),(35↦\"Doktor\"),(36↦\"gar\"),(37↦\"Und\"),(38↦\"ziehe\"),(39↦\"schon\"),(40↦\"an\"),(41↦\"die\"),(42↦\"zehen\"),(43↦\"Jahr\"),(44↦\"Herauf\"),(45↦\"herab\"),(46↦\"und\"),(47↦\"quer\"),(48↦\"und\"),(49↦\"krumm\"),(50↦\"Meine\"),(51↦\"Schüler\"),(52↦\"an\"),(53↦\"der\"),(54↦\"Nase\"),(55↦\"herum\"),(56↦\"Und\"),(57↦\"sehe\"),(58↦\"daß\"),(59↦\"wir\"),(60↦\"nichts\"),(61↦\"wissen\"),(62↦\"können\"),(63↦\"Das\"),(64↦\"will\"),(65↦\"mir\"),(66↦\"schier\"),(67↦\"das\"),(68↦\"Herz\"),(69↦\"verbrennen\"),(70↦\"Zwar\"),(71↦\"bin\"),(72↦\"ich\"),(73↦\"gescheiter\"),(74↦\"als\"),(75↦\"all\"),(76↦\"die\"),(77↦\"Laffen\"),(78↦\"Doktoren\"),(79↦\"Magister\"),(80↦\"Schreiber\"),(81↦\"und\"),(82↦\"Pfaffen\"),(83↦\"Mich\"),(84↦\"plagen\"),(85↦\"keine\"),(86↦\"Skrupel\"),(87↦\"noch\"),(88↦\"Zweifel\"),(89↦\"Fürchte\"),(90↦\"mich\"),(91↦\"weder\"),(92↦\"vor\"),(93↦\"Hölle\"),(94↦\"noch\"),(95↦\"Teufel\"),(96↦\"Dafür\"),(97↦\"ist\"),(98↦\"mir\"),(99↦\"auch\"),(100↦\"alle\"),(101↦\"Freud\"),(102↦\"entrissen\"),(103↦\"Bilde\"),(104↦\"mir\"),(105↦\"nicht\"),(106↦\"ein\"),(107↦\"was\"),(108↦\"Rechts\"),(109↦\"zu\"),(110↦\"wissen\"),(111↦\"Bilde\"),(112↦\"mir\"),(113↦\"nicht\"),(114↦\"ein\"),(115↦\"ich\"),(116↦\"könnte\"),(117↦\"was\"),(118↦\"lehren\"),(119↦\"Die\"),(120↦\"Menschen\"),(121↦\"zu\"),(122↦\"bessern\"),(123↦\"und\"),(124↦\"zu\"),(125↦\"bekehren\"),(126↦\"Auch\"),(127↦\"hab\"),(128↦\"ich\"),(129↦\"weder\"),(130↦\"Gut\"),(131↦\"noch\"),(132↦\"Geld\"),(133↦\"Noch\"),(134↦\"Ehr\"),(135↦\"und\"),(136↦\"Herrlichkeit\"),(137↦\"der\"),(138↦\"Welt\"),(139↦\"Es\"),(140↦\"möchte\"),(141↦\"kein\"),(142↦\"Hund\"),(143↦\"so\"),(144↦\"länger\"),(145↦\"leben\"),(146↦\"Drum\"),(147↦\"hab\"),(148↦\"ich\"),(149↦\"mich\"),(150↦\"der\"),(151↦\"Magie\"),(152↦\"ergeben\"),(153↦\"Ob\"),(154↦\"mir\"),(155↦\"durch\"),(156↦\"Geistes\"),(157↦\"Kraft\"),(158↦\"und\"),(159↦\"Mund\"),(160↦\"Nicht\"),(161↦\"manch\"),(162↦\"Geheimnis\"),(163↦\"würde\"),(164↦\"kund\"),(165↦\"Daß\"),(166↦\"ich\"),(167↦\"nicht\"),(168↦\"mehr\"),(169↦\"mit\"),(170↦\"saurem\"),(171↦\"Schweiß\"),(172↦\"Zu\"),(173↦\"sagen\"),(174↦\"brauche\"),(175↦\"was\"),(176↦\"ich\"),(177↦\"nicht\"),(178↦\"weiß\"),(179↦\"Daß\"),(180↦\"ich\"),(181↦\"erkenne\"),(182↦\"was\"),(183↦\"die\"),(184↦\"Welt\"),(185↦\"Im\"),(186↦\"Innersten\"),(187↦\"zusammenhält\"),(188↦\"Schau\"),(189↦\"alle\"),(190↦\"Wirkenskraft\"),(191↦\"und\"),(192↦\"Samen\"),(193↦\"Und\"),(194↦\"tu\"),(195↦\"nicht\"),(196↦\"mehr\"),(197↦\"in\"),(198↦\"Worten\"),(199↦\"kramen\")}" ] }, - "execution_count": 21, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -671,7 +726,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 37, "metadata": {}, "outputs": [ { @@ -683,7 +738,7 @@ "{\"Auch\",\"Bemühn\",\"Bilde\",\"Da\",\"Dafür\",\"Das\",\"Daß\",\"Die\",\"Doktor\",\"Doktoren\",\"Drum\",\"Durchaus\",\"Ehr\",\"Es\",\"FAUST\",\"Freud\",\"Fürchte\",\"Geheimnis\",\"Geistes\",\"Geld\",\"Gut\",\"Habe\",\"Heiße\",\"Herauf\",\"Herrlichkeit\",\"Herz\",\"Hund\",\"Hölle\",\"Im\",\"Innersten\",\"Jahr\",\"Juristerei\",\"Kraft\",\"Laffen\",\"Magie\",\"Magister\",\"Medizin\",\"Meine\",\"Menschen\",\"Mich\",\"Mund\",\"Nase\",\"Nicht\",\"Noch\",\"Ob\",\"Pfaffen\",\"Philosophie\",\"Rechts\",\"Samen\",\"Schau\",\"Schreiber\",\"Schweiß\",\"Schüler\",\"Skrupel\",\"Teufel\",\"Theologie\",\"Tor\",\"Und\",\"Welt\",\"Wirkenskraft\",\"Worten\",\"Zu\",\"Zwar\",\"Zweifel\",\"ach\",\"all\",\"alle\",\"als\",\"an\",\"armer\",\"auch\",\"bekehren\",\"bessern\",\"bin\",\"brauche\",\"das\",\"daß\",\"der\",\"die\",\"durch\",\"ein\",\"entrissen\",\"ergeben\",\"erkenne\",\"gar\",\"gescheiter\",\"hab\",\"heiße\",\"heißem\",\"herab\",\"herum\",\"ich\",\"in\",\"ist\",\"kein\",\"keine\",\"klug\",\"kramen\",\"krumm\",\"kund\",\"können\",\"könnte\",\"leben\",\"lehren\",\"leider\",\"länger\",\"manch\",\"mehr\",\"mich\",\"mir\",\"mit\",\"möchte\",\"nicht\",\"nichts\",\"noch\",\"nun\",\"plagen\",\"quer\",\"sagen\",\"saurem\",\"schier\",\"schon\",\"sehe\",\"so\",\"steh\",\"studiert\",\"tu\",\"und\",\"verbrennen\",\"vor\",\"was\",\"weder\",\"weiß\",\"wie\",\"will\",\"wir\",\"wissen\",\"würde\",\"zehen\",\"ziehe\",\"zu\",\"zusammenhält\",\"zuvor\"}" ] }, - "execution_count": 22, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -694,7 +749,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 38, "metadata": {}, "outputs": [ { @@ -706,7 +761,7 @@ "{(1↦\"\\nFAUST\")}" ] }, - "execution_count": 23, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } @@ -717,7 +772,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 39, "metadata": {}, "outputs": [ { @@ -729,7 +784,7 @@ "{(1↦\"\\nFAUST\"),(2↦\"\\n Habe\"),(3↦\"\\n Juristerei\"),(4↦\"\\n Und\"),(5↦\"\\n Durchaus\"),(6↦\"\\n Da\"),(7↦\"\\n Und\"),(8↦\"\\n Heiße\"),(9↦\"\\n Und\"),(10↦\"\\n Herauf\"),(11↦\"\\n Meine\"),(12↦\"\\n Und\"),(13↦\"\\n Das\"),(14↦\"\\n Zwar\"),(15↦\"\\n Doktoren\"),(16↦\"\\n Mich\"),(17↦\"\\n Fürchte\"),(18↦\"\\n Dafür\"),(19↦\"\\n Bilde\"),(20↦\"\\n Bilde\"),(21↦\"\\n Die\"),(22↦\"\\n Auch\"),(23↦\"\\n Noch\"),(24↦\"\\n Es\"),(25↦\"\\n Drum\"),(26↦\"\\n Ob\"),(27↦\"\\n Nicht\"),(28↦\"\\n Daß\"),(29↦\"\\n Zu\"),(30↦\"\\n Daß\"),(31↦\"\\n Im\"),(32↦\"\\n Schau\"),(33↦\"\\n Und\")}" ] }, - "execution_count": 24, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -740,19 +795,19 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "$\\text{\" \\npublic class HelloWorld {\\n public static void main(String[] args) {\\n System.out.println(\\\"Hello, World\\\");\\n int res1 = 2*3;\\n System.out.println(res);\\n }\\n}\\n\"}$" + "$\\text{\" \\npublic class HelloWorld {\\n public static void main(String[] args) {\\n System.out.println(\\\"Hello, World\\\");\\n int res1 = 22*33;\\n System.out.println(res);\\n }\\n}\\n\"}$" ], "text/plain": [ - "\" \\npublic class HelloWorld {\\n public static void main(String[] args) {\\n System.out.println(\\\"Hello, World\\\");\\n int res1 = 2*3;\\n System.out.println(res);\\n }\\n}\\n\"" + "\" \\npublic class HelloWorld {\\n public static void main(String[] args) {\\n System.out.println(\\\"Hello, World\\\");\\n int res1 = 22*33;\\n System.out.println(res);\\n }\\n}\\n\"" ] }, - "execution_count": 37, + "execution_count": 40, "metadata": {}, "output_type": "execute_result" } @@ -771,7 +826,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 41, "metadata": {}, "outputs": [ { @@ -783,18 +838,18 @@ "\"\\b[A-Za-z_][A-Za-z0-9_]*\"" ] }, - "execution_count": 26, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ - ":let ID \"\\b[A-Za-z_][A-Za-z0-9_]*\"" + ":let Bezeichner \"\\b[A-Za-z_][A-Za-z0-9_]*\"" ] }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 42, "metadata": {}, "outputs": [ { @@ -806,87 +861,87 @@ "\"\\b[0-9]+\"" ] }, - "execution_count": 31, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ - ":let Int \"\\b[0-9]+\"" + ":let Zahl \"\\b[0-9]+\"" ] }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "$\\text{\"\\b([A-Za-z_][A-Za-z0-9_]*)(\\.([A-Za-z_][A-Za-z0-9_]*))+\"}$" + "$\\{(1\\mapsto\\text{\"public\"}),(2\\mapsto\\text{\"class\"}),(3\\mapsto\\text{\"HelloWorld\"}),(4\\mapsto\\text{\"public\"}),(5\\mapsto\\text{\"static\"}),(6\\mapsto\\text{\"void\"}),(7\\mapsto\\text{\"main\"}),(8\\mapsto\\text{\"String\"}),(9\\mapsto\\text{\"args\"}),(10\\mapsto\\text{\"System\"}),(11\\mapsto\\text{\"out\"}),(12\\mapsto\\text{\"println\"}),(13\\mapsto\\text{\"Hello\"}),(14\\mapsto\\text{\"World\"}),(15\\mapsto\\text{\"int\"}),(16\\mapsto\\text{\"res1\"}),(17\\mapsto\\text{\"System\"}),(18\\mapsto\\text{\"out\"}),(19\\mapsto\\text{\"println\"}),(20\\mapsto\\text{\"res\"})\\}$" ], "text/plain": [ - "\"\\b([A-Za-z_][A-Za-z0-9_]*)(\\.([A-Za-z_][A-Za-z0-9_]*))+\"" + "{(1↦\"public\"),(2↦\"class\"),(3↦\"HelloWorld\"),(4↦\"public\"),(5↦\"static\"),(6↦\"void\"),(7↦\"main\"),(8↦\"String\"),(9↦\"args\"),(10↦\"System\"),(11↦\"out\"),(12↦\"println\"),(13↦\"Hello\"),(14↦\"World\"),(15↦\"int\"),(16↦\"res1\"),(17↦\"System\"),(18↦\"out\"),(19↦\"println\"),(20↦\"res\")}" ] }, - "execution_count": 45, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ - ":let ComposedID \"\\b([A-Za-z_][A-Za-z0-9_]*)(\\.([A-Za-z_][A-Za-z0-9_]*))+\"" + "REGEX_SEARCH_ALL(jt,Bezeichner)" ] }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 44, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "$\\{(1\\mapsto\\text{\"public\"}),(2\\mapsto\\text{\"class\"}),(3\\mapsto\\text{\"HelloWorld\"}),(4\\mapsto\\text{\"public\"}),(5\\mapsto\\text{\"static\"}),(6\\mapsto\\text{\"void\"}),(7\\mapsto\\text{\"main\"}),(8\\mapsto\\text{\"String\"}),(9\\mapsto\\text{\"args\"}),(10\\mapsto\\text{\"System\"}),(11\\mapsto\\text{\"out\"}),(12\\mapsto\\text{\"println\"}),(13\\mapsto\\text{\"Hello\"}),(14\\mapsto\\text{\"World\"}),(15\\mapsto\\text{\"int\"}),(16\\mapsto\\text{\"res1\"}),(17\\mapsto\\text{\"System\"}),(18\\mapsto\\text{\"out\"}),(19\\mapsto\\text{\"println\"}),(20\\mapsto\\text{\"res\"})\\}$" + "$\\{(1\\mapsto\\text{\"22\"}),(2\\mapsto\\text{\"33\"})\\}$" ], "text/plain": [ - "{(1↦\"public\"),(2↦\"class\"),(3↦\"HelloWorld\"),(4↦\"public\"),(5↦\"static\"),(6↦\"void\"),(7↦\"main\"),(8↦\"String\"),(9↦\"args\"),(10↦\"System\"),(11↦\"out\"),(12↦\"println\"),(13↦\"Hello\"),(14↦\"World\"),(15↦\"int\"),(16↦\"res1\"),(17↦\"System\"),(18↦\"out\"),(19↦\"println\"),(20↦\"res\")}" + "{(1↦\"22\"),(2↦\"33\")}" ] }, - "execution_count": 46, + "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "REGEX_SEARCH_ALL(jt,ID)" + "REGEX_SEARCH_ALL(jt,Zahl)" ] }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 45, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "$\\{(1\\mapsto\\text{\"2\"}),(2\\mapsto\\text{\"3\"})\\}$" + "$\\text{\"\\b([A-Za-z_][A-Za-z0-9_]*)(\\.([A-Za-z_][A-Za-z0-9_]*))+\"}$" ], "text/plain": [ - "{(1↦\"2\"),(2↦\"3\")}" + "\"\\b([A-Za-z_][A-Za-z0-9_]*)(\\.([A-Za-z_][A-Za-z0-9_]*))+\"" ] }, - "execution_count": 47, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "REGEX_SEARCH_ALL(jt,Int)" + ":let ComposedID \"\\b([A-Za-z_][A-Za-z0-9_]*)(\\.([A-Za-z_][A-Za-z0-9_]*))+\"" ] }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 46, "metadata": {}, "outputs": [ { @@ -898,7 +953,7 @@ "{(1↦\"System.out.println\"),(2↦\"System.out.println\")}" ] }, - "execution_count": 48, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" }