diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 9f0e67b..434d81b 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": [ @@ -50,7 +50,18 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "13637" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "len(prophet)" ] @@ -70,7 +81,8 @@ "metadata": {}, "outputs": [], "source": [ - "# your code here" + "# I use indexing to keep the elements\n", + "prophet = prophet[568:]" ] }, { @@ -82,11 +94,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 78, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "# To check the references we print the list\n", + "\n", + "#print(prophet[0:11])\n" ] }, { @@ -113,17 +127,10 @@ " Input: 'the{7}'\n", " Output: 'the'\n", " '''\n", - " \n", - " # your code here" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# your code here" + "\n", + " # Using split on the first element to remove references, due to we split on \"{\" symbol\n", + " return x.split(\"{\")[0]\n", + " " ] }, { @@ -135,11 +142,16 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 76, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "\n", + "# Using the map function we can get the list without references\n", + "prophet_reference = list (\n", + " map(reference,prophet)\n", + ")\n", + "\n" ] }, { @@ -163,9 +175,10 @@ " Example:\n", " Input: 'the\\nbeloved'\n", " Output: ['the', 'beloved']\n", - " '''\n", - " \n", - " # your code here" + " ''' \n", + " #Using split on the first element to remove references, due to we split on \"\\n\" string\n", + " return x.split(\"\\n\")\n", + " " ] }, { @@ -177,13 +190,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 75, "metadata": { "scrolled": true }, "outputs": [], "source": [ - "# your code here" + "\n", + "# We make the list prophet_line which has no \\n string on any element\n", + "prophet_line = list(\n", + " map(line_break,prophet_reference)\n", + ")\n", + "\n" ] }, { @@ -195,21 +213,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 74, "metadata": {}, "outputs": [], "source": [ - "prophet_flat = [i for sub in prophet_line for i in sub]\n", - "prophet_flat" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# your code here" + "\n", + "prophet_flat = [i for sub in prophet_line for i in sub]\n" ] }, { @@ -223,7 +232,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 72, "metadata": {}, "outputs": [], "source": [ @@ -242,9 +251,15 @@ " Output: True\n", " '''\n", " \n", - " word_list = ['and', 'the', 'a', 'an']\n", + " # We declare the list of word to filter\n", + " word_list = [\"and\", \"the\", \"a\", \"an\"]\n", " \n", - " # your code here" + " # If any of these words are on the string we return False,\n", + " # Other wise True\n", + " if x in word_list:\n", + " return False\n", + " else:\n", + " return True\n" ] }, { @@ -256,13 +271,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 71, "metadata": { "scrolled": true }, "outputs": [], "source": [ - "# your code here" + "\n", + "# We create prophet_filter with our function to keep only the words we want\n", + "prophet_filter = list(\n", + " filter(word_filter,prophet_flat)\n", + ")\n" ] }, { @@ -282,9 +301,17 @@ "source": [ "def word_filter_case(x):\n", " \n", - " word_list = ['and', 'the', 'a', 'an']\n", + " # We declare the list of word to filter\n", + " word_list = [\"and\",\"the\",\"a\",\"an\"]\n", " \n", - " # your code here" + " \n", + " # If any of these words are on the string we return False,\n", + " # Other wise True, this conditional avoids to not be case sensitive\n", + " if x.lower() in word_list:\n", + " return False\n", + " else:\n", + " return True\n", + " \n" ] }, { @@ -313,7 +340,8 @@ " Input: 'John', 'Smith'\n", " Output: 'John Smith'\n", " '''\n", - " \n", + " # We concatenate two string with a space between them\n", + " return a + \" \" +b\n", " # your code here" ] }, @@ -323,9 +351,20 @@ "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'First word'" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "concat_space(\"First\",\"word\")" ] }, { @@ -337,17 +376,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 79, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "\n", + "# We use the function to create propeht_string, into a single string\n", + "prophet_string = reduce(concat_space,prophet_filter)\n" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -361,7 +402,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.11.9" } }, "nbformat": 4,