diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 9f0e67b..d6e851c 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -12,7 +12,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -35,7 +35,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -48,9 +48,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "13637" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "len(prophet)" ] @@ -66,11 +77,11 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "prophet = prophet[568:]" ] }, { @@ -82,11 +93,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['PROPHET\\n\\n|Almustafa,', 'the{7}', 'chosen', 'and', 'the\\nbeloved,', 'who', 'was', 'a', 'dawn', 'unto']\n" + ] + } + ], "source": [ - "# your code here" + "print(prophet[:10])" ] }, { @@ -100,7 +119,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -119,11 +138,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "def reference(x):\n", + " return x.split('{')[0]" ] }, { @@ -135,11 +155,11 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "prophet_reference = list(map(reference, prophet))" ] }, { @@ -151,7 +171,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -163,9 +183,7 @@ " Example:\n", " Input: 'the\\nbeloved'\n", " Output: ['the', 'beloved']\n", - " '''\n", - " \n", - " # your code here" + " '''\n" ] }, { @@ -177,13 +195,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": { "scrolled": true }, "outputs": [], "source": [ - "# your code here" + "prophet_line = list(map(line_break, prophet_reference))" ] }, { @@ -195,21 +213,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": {}, "outputs": [], "source": [ - "prophet_flat = [i for sub in prophet_line for i in sub]\n", - "prophet_flat" + "prophet_flat = [i for sub in prophet_line if sub is not None for i in sub]\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "filtered_prophet = list(filter(word_filter, prophet_flat))" ] }, { @@ -223,7 +240,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -256,13 +273,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": { "scrolled": true }, "outputs": [], "source": [ - "# your code here" + "prophet_filter = list(filter(word_filter, prophet_flat))" ] }, { @@ -276,15 +293,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "def word_filter_case(x):\n", " \n", " word_list = ['and', 'the', 'a', 'an']\n", - " \n", - " # your code here" + " return x.lower() not in word_list" ] }, { @@ -300,7 +316,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, "outputs": [], "source": [ @@ -319,13 +335,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": { "scrolled": true }, "outputs": [], "source": [ - "# your code here" + "def concat_space(a, b):\n", + " return a +''+ b" ] }, { @@ -337,17 +354,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "prophet_string = reduce(concat_space, prophet_filter, '')" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -361,7 +378,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.5" } }, "nbformat": 4,