Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 91 additions & 50 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -35,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -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)"
]
Expand All @@ -70,7 +81,8 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"# I use indexing to keep the elements\n",
"prophet = prophet[568:]"
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -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",
" "
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -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",
" "
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -223,7 +232,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 72,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -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"
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -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"
]
},
{
Expand Down Expand Up @@ -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"
]
},
Expand All @@ -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\")"
]
},
{
Expand All @@ -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"
},
Expand All @@ -361,7 +402,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down