Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisions #77

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
144 changes: 42 additions & 102 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": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -35,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -66,11 +66,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"prophet = prophet[568:len(prophet)]"
]
},
{
Expand All @@ -80,15 +80,6 @@
"If you look through the words, you will find that many words have a reference attached to them. For example, let's look at words 1 through 10."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -100,30 +91,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"def reference(x):\n",
" '''\n",
" Input: A string\n",
" Output: The string with references removed\n",
" \n",
" Example:\n",
" Input: 'the{7}'\n",
" Output: 'the'\n",
" '''\n",
" \n",
" # your code here"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
" cleanedWord = x.split('{')[0]\n",
" return cleanedWord \n",
" "
]
},
{
Expand All @@ -135,11 +110,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"prophet_reference = list(map(reference, prophet))\n"
]
},
{
Expand All @@ -151,21 +126,12 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"def line_break(x):\n",
" '''\n",
" Input: A string\n",
" Output: A list of strings split on the line break (\\n) character\n",
" \n",
" Example:\n",
" Input: 'the\\nbeloved'\n",
" Output: ['the', 'beloved']\n",
" '''\n",
" \n",
" # your code here"
" return x.split('\\n')"
]
},
{
Expand All @@ -183,7 +149,9 @@
},
"outputs": [],
"source": [
"# your code here"
"\n",
"prophet_line = list(map(line_break, prophet_reference))\n",
"prophet_line"
]
},
{
Expand All @@ -203,15 +171,6 @@
"prophet_flat"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -223,28 +182,16 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"def word_filter(x):\n",
" '''\n",
" Input: A string\n",
" Output: True if the word is not in the specified list \n",
" and False if the word is in the list.\n",
" \n",
" Example:\n",
" word list = ['and', 'the']\n",
" Input: 'and'\n",
" Output: False\n",
" \n",
" Input: 'John'\n",
" Output: True\n",
" '''\n",
" \n",
" word_list = ['and', 'the', 'a', 'an']\n",
" \n",
" # your code here"
" if x not in word_list:\n",
" return True\n",
" else:\n",
" return False\n"
]
},
{
Expand All @@ -262,9 +209,16 @@
},
"outputs": [],
"source": [
"# your code here"
"\n",
"prophet_filter = list(filter(word_filter,prophet_flat))\n",
"prophet_filter"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -276,15 +230,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"def word_filter_case(x):\n",
" \n",
" x = x.lower()\n",
" word_list = ['and', 'the', 'a', 'an']\n",
" \n",
" # your code here"
" if x not in word_list:\n",
" return True\n",
" else:\n",
" return False"
]
},
{
Expand All @@ -300,32 +257,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"def concat_space(a, b):\n",
" '''\n",
" Input:Two strings\n",
" Output: A single string separated by a space\n",
" \n",
" Example:\n",
" Input: 'John', 'Smith'\n",
" Output: 'John Smith'\n",
" '''\n",
" \n",
" # your code here"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# your code here"
" string = a + ' ' + b\n",
" return string\n",
" "
]
},
{
Expand All @@ -341,13 +280,14 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"prophet_string = reduce(concat_space,prophet_filter)\n",
"prophet_string\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -361,7 +301,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.9.6"
}
},
"nbformat": 4,
Expand Down