From 155414cb62712fcb08bc9b4ee55f34f514db8544 Mon Sep 17 00:00:00 2001 From: Snigdha Rao Date: Mon, 19 Mar 2018 12:04:08 +0530 Subject: [PATCH 1/5] fixed typos --- vacuum_world.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vacuum_world.ipynb b/vacuum_world.ipynb index 2c18e4185..366739823 100644 --- a/vacuum_world.ipynb +++ b/vacuum_world.ipynb @@ -445,7 +445,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We need a another function UPDATE-STATE which will be responsible for creating a new state description." + "We need another function UPDATE-STATE which will be responsible for creating a new state description." ] }, { From c3b11a883986233b911a41f8bbcc732d8dea28f0 Mon Sep 17 00:00:00 2001 From: Snigdha Rao Date: Mon, 19 Mar 2018 13:09:31 +0530 Subject: [PATCH 2/5] fixed several typos --- text.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/text.ipynb b/text.ipynb index f8c3aea13..327bd1160 100644 --- a/text.ipynb +++ b/text.ipynb @@ -535,7 +535,7 @@ "\n", "`[$][0-9]+([.][0-9][0-9])?`\n", "\n", - "Where `+` means 1 or more occurrences and `?` means at most 1 occurrence. Usually a template consists of a prefix, a target and a postfix regex. In this template, the prefix regex can be \"price:\", the target regex can be the above regex and the postfix regex can be empty.\n", + "Where `+` means 1 or more occurrences and `?` means atmost 1 occurrence. Usually a template consists of a prefix, a target and a postfix regex. In this template, the prefix regex can be \"price:\", the target regex can be the above regex and the postfix regex can be empty.\n", "\n", "A template can match with multiple strings. If this is the case, we need a way to resolve the multiple matches. Instead of having just one template, we can use multiple templates (ordered by priority) and pick the match from the highest-priority template. We can also use other ways to pick. For the dollar example, we can pick the match closer to the numerical half of the highest match. For the text \"Price $90, special offer $70, shipping $5\" we would pick \"$70\" since it is closer to the half of the highest match (\"$90\")." ] @@ -706,7 +706,7 @@ "metadata": {}, "source": [ "### Permutation Decoder\n", - "Now let us try to decode messages encrypted by a general monoalphabetic substitution cipher. The letters in the alphabet can be replaced by any permutation of letters. For example if the alpahbet consisted of `{A B C}` then it can be replaced by `{A C B}`, `{B A C}`, `{B C A}`, `{C A B}`, `{C B A}` or even `{A B C}` itself. Suppose we choose the permutation `{C B A}`, then the plain text `\"CAB BA AAC\"` would become `\"ACB BC CCA\"`. We can see that Caesar cipher is also a form of permutation cipher where the permutation is a cyclic permutation. Unlike the Caesar cipher, it is infeasible to try all possible permutations. The number of possible permutations in Latin alphabet is `26!` which is of the order $10^{26}$. We use graph search algorithms to search for a 'good' permutation." + "Now let us try to decode messages encrypted by a general mono-alphabetic substitution cipher. The letters in the alphabet can be replaced by any permutation of letters. For example, if the alphabet consisted of `{A B C}` then it can be replaced by `{A C B}`, `{B A C}`, `{B C A}`, `{C A B}`, `{C B A}` or even `{A B C}` itself. Suppose we choose the permutation `{C B A}`, then the plain text `\"CAB BA AAC\"` would become `\"ACB BC CCA\"`. We can see that Caesar cipher is also a form of permutation cipher where the permutation is a cyclic permutation. Unlike the Caesar cipher, it is infeasible to try all possible permutations. The number of possible permutations in Latin alphabet is `26!` which is of the order $10^{26}$. We use graph search algorithms to search for a 'good' permutation." ] }, { @@ -722,7 +722,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Each state/node in the graph is represented as a letter-to-letter map. If there no mapping for a letter it means the letter is unchanged in the permutation. These maps are stored as dictionaries. Each dictionary is a 'potential' permutation. We use the word 'potential' because every dictionary doesn't necessarily represent a valid permutation since a permutation cannot have repeating elements. For example the dictionary `{'A': 'B', 'C': 'X'}` is invalid because `'A'` is replaced by `'B'`, but so is `'B'` because the dictionary doesn't have a mapping for `'B'`. Two dictionaries can also represent the same permutation e.g. `{'A': 'C', 'C': 'A'}` and `{'A': 'C', 'B': 'B', 'C': 'A'}` represent the same permutation where `'A'` and `'C'` are interchanged and all other letters remain unaltered. To ensure we get a valid permutation a goal state must map all letters in the alphabet. We also prevent repetions in the permutation by allowing only those actions which go to new state/node in which the newly added letter to the dictionary maps to previously unmapped letter. These two rules togeter ensure that the dictionary of a goal state will represent a valid permutation.\n", + "Each state/node in the graph is represented as a letter-to-letter map. If there is no mapping for a letter, it means the letter is unchanged in the permutation. These maps are stored as dictionaries. Each dictionary is a 'potential' permutation. We use the word 'potential' because every dictionary doesn't necessarily represent a valid permutation since a permutation cannot have repeating elements. For example the dictionary `{'A': 'B', 'C': 'X'}` is invalid because `'A'` is replaced by `'B'`, but so is `'B'` because the dictionary doesn't have a mapping for `'B'`. Two dictionaries can also represent the same permutation e.g. `{'A': 'C', 'C': 'A'}` and `{'A': 'C', 'B': 'B', 'C': 'A'}` represent the same permutation where `'A'` and `'C'` are interchanged and all other letters remain unaltered. To ensure that we get a valid permutation, a goal state must map all letters in the alphabet. We also prevent repetitions in the permutation by allowing only those actions which go to a new state/node in which the newly added letter to the dictionary maps to previously unmapped letter. These two rules together ensure that the dictionary of a goal state will represent a valid permutation.\n", "The score of a state is determined using word scores, unigram scores, and bigram scores. Experiment with different weightages for word, unigram and bigram scores and see how they affect the decoding." ] }, @@ -752,7 +752,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "As evident from the above example, permutation decoding using best first search is sensitive to initial text. This is because not only the final dictionary, with substitutions for all letters, must have good score but so must the intermediate dictionaries. You could think of it as performing a local search by finding substitutons for each letter one by one. We could get very different results by changing even a single letter because that letter could be a deciding factor for selecting substitution in early stages which snowballs and affects the later stages. To make the search better we can use different definition of score in different stages and optimize on which letter to substitute first." + "As evident from the above example, permutation decoding using best first search is sensitive to initial text. This is because not only the final dictionary, with substitutions for all letters, must have good score but so must the intermediate dictionaries. You could think of it as performing a local search by finding substitutions for each letter one by one. We could get very different results by changing even a single letter because that letter could be a deciding factor for selecting substitution in early stages which snowballs and affects the later stages. To make the search better we can use different definitions of score in different stages and optimize on which letter to substitute first." ] } ], From 6c6f1e896510ec73afe1944d60d2754bfb53b805 Mon Sep 17 00:00:00 2001 From: Snigdha Rao Date: Mon, 19 Mar 2018 16:53:11 +0530 Subject: [PATCH 3/5] Corrected test_compare_agents() function TrivialVacuumEnvironment was missing a pair of parenthesis while creating the "environment" object of the TrivialVacuumEnvironment class ModelBasedVacuumAgent and ReflexVacuumAgent were also missing parenthesis while creating the "agents" object. --- tests/test_agents.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_agents.py b/tests/test_agents.py index ded9b7d95..125a69ca4 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -192,8 +192,8 @@ def test_TableDrivenVacuumAgent() : def test_compare_agents() : - environment = TrivialVacuumEnvironment - agents = [ModelBasedVacuumAgent, ReflexVacuumAgent] + environment = TrivialVacuumEnvironment() + agents = [ModelBasedVacuumAgent(), ReflexVacuumAgent()] result = compare_agents(environment, agents) performance_ModelBasedVacummAgent = result[0][1] From 1c4410dc7d06f2f54423f226f901941cd7eacc92 Mon Sep 17 00:00:00 2001 From: Snigdha Rao Date: Mon, 19 Mar 2018 17:01:11 +0530 Subject: [PATCH 4/5] Reverted changes made to test_compare_agents() --- tests/test_agents.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_agents.py b/tests/test_agents.py index 125a69ca4..ded9b7d95 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -192,8 +192,8 @@ def test_TableDrivenVacuumAgent() : def test_compare_agents() : - environment = TrivialVacuumEnvironment() - agents = [ModelBasedVacuumAgent(), ReflexVacuumAgent()] + environment = TrivialVacuumEnvironment + agents = [ModelBasedVacuumAgent, ReflexVacuumAgent] result = compare_agents(environment, agents) performance_ModelBasedVacummAgent = result[0][1] From 5a02da54dc7a4f2bee59cb044c4acb607bc7d9bc Mon Sep 17 00:00:00 2001 From: Snigdha Rao Date: Mon, 19 Mar 2018 18:28:10 +0530 Subject: [PATCH 5/5] fixed typo --- search-4e.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/search-4e.ipynb b/search-4e.ipynb index 1912a7fa8..72981d49b 100644 --- a/search-4e.ipynb +++ b/search-4e.ipynb @@ -30,7 +30,7 @@ "\n", "\n", "\n", - "A state-space search problem can be represented by a *graph*, where the vertexes of the graph are the states of the problem (in this case, cities) and the edges of the graph are the actions (in this case, driving along a road).\n", + "A state-space search problem can be represented by a *graph*, where the vertices of the graph are the states of the problem (in this case, cities) and the edges of the graph are the actions (in this case, driving along a road).\n", "\n", "We'll represent a city by its single initial letter. \n", "We'll represent the graph of connections as a `dict` that maps each city to a list of the neighboring cities (connected by a road). For now we don't explicitly represent the actions, nor the distances\n",