Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf2a627

Browse files
antmarakisnorvig
authored andcommitted
NLP: Applications/Language Recognition (aimacode#621)
* Update README.md * Create nlp_apps.ipynb * typo in readme * Update intro.ipynb
1 parent 09beeb4 commit bf2a627

File tree

3 files changed

+279
-44
lines changed

3 files changed

+279
-44
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ Python code for the book *[Artificial Intelligence: A Modern Approach](http://ai
1010
## Python 3.4
1111

1212
This code is in Python 3.4 (Python 3.5 and later also works, but Python 2.x does not). You can [install the latest Python version](https://www.python.org/downloads) or use a browser-based Python interpreter such as [repl.it](https://repl.it/languages/python3).
13-
You can run the code in an IDE, or from the command line with `python -i `*filename*`.py` where the `-i` option puts you in an interactive loop where you can run Python functions.
13+
You can run the code in an IDE, or from the command line with `python -i filename.py` where the `-i` option puts you in an interactive loop where you can run Python functions.
1414

15-
In addition to the *filename*`.py` files, there are also *filename*`.ipynb` files, which are Jupyter (formerly Ipython) notebooks. You can read these notebooks, and you can also run the code embedded with them. See [jupyter.org](http://jupyter.org/) for instructions on setting up a Jupyter notebook environment.
15+
In addition to the `filename.py` files, there are also `filename.ipynb` files, which are Jupyter (formerly Ipython) notebooks. You can read these notebooks, and you can also run the code embedded with them. See [jupyter.org](http://jupyter.org/) for instructions on setting up a Jupyter notebook environment. Some modules also have `filename_apps.ipynb` files, which are notebooks for applications of the module.
1616

1717
## Structure of the Project
1818

1919
When complete, this project will have Python code for all the pseudocode algorithms in the book. For each major topic, such as `logic`, we will have the following three files in the main branch:
2020

21-
- `logic.py`: Implementations of all the pseudocode algorithms, and necessary support functions/classes/data.
22-
- `logic.ipynb`: A Jupyter (IPython) notebook that explains and gives examples of how to use the code.
23-
- `tests/test_logic.py`: A lightweight test suite, using `assert` statements, designed for use with [`py.test`](http://pytest.org/latest/), but also usable on their own.
21+
- `nlp.py`: Implementations of all the pseudocode algorithms, and necessary support functions/classes/data.
22+
- `nlp.ipynb`: A Jupyter (IPython) notebook that explains and gives examples of how to use the code.
23+
- `nlp_apps.ipynb`: A Jupyter notebook that gives example applications of the code.
24+
- `tests/test_nlp.py`: A lightweight test suite, using `assert` statements, designed for use with [`py.test`](http://pytest.org/latest/), but also usable on their own.
2425

2526
# Index of Algorithms
2627

intro.ipynb

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"metadata": {
6-
"deletable": true,
7-
"editable": true
8-
},
5+
"metadata": {},
96
"source": [
107
"# An Introduction To `aima-python` \n",
118
" \n",
129
"The [aima-python](https://github.com/aimacode/aima-python) repository implements, in Python code, the algorithms in the textbook *[Artificial Intelligence: A Modern Approach](http://aima.cs.berkeley.edu)*. A typical module in the repository has the code for a single chapter in the book, but some modules combine several chapters. See [the index](https://github.com/aimacode/aima-python#index-of-code) if you can't find the algorithm you want. The code in this repository attempts to mirror the pseudocode in the textbook as closely as possible and to stress readability foremost; if you are looking for high-performance code with advanced features, there are other repositories for you. For each module, there are three files, for example:\n",
1310
"\n",
14-
"- [**`logic.py`**](https://github.com/aimacode/aima-python/blob/master/logic.py): Source code with data types and algorithms for dealing with logic; functions have docstrings explaining their use.\n",
15-
"- [**`logic.ipynb`**](https://github.com/aimacode/aima-python/blob/master/logic.ipynb): A notebook like this one; gives more detailed examples and explanations of use.\n",
16-
"- [**`tests/test_logic.py`**](https://github.com/aimacode/aima-python/blob/master/tests/test_logic.py): Test cases, used to verify the code is correct, and also useful to see examples of use.\n",
11+
"- [**`nlp.py`**](https://github.com/aimacode/aima-python/blob/master/nlp.py): Source code with data types and algorithms for natural language processing; functions have docstrings explaining their use.\n",
12+
"- [**`nlp.ipynb`**](https://github.com/aimacode/aima-python/blob/master/nlp.ipynb): A notebook like this one; gives more detailed examples and explanations of use.\n",
13+
"- [**`nlp_apps.ipynb`**](https://github.com/aimacode/aima-python/blob/master/nlp_apps.ipynb): A Jupyter notebook that gives example applications of the code.\n",
14+
"- [**`tests/test_nlp.py`**](https://github.com/aimacode/aima-python/blob/master/tests/test_nlp.py): Test cases, used to verify the code is correct, and also useful to see examples of use.\n",
1715
"\n",
1816
"There is also an [aima-java](https://github.com/aimacode/aima-java) repository, if you prefer Java.\n",
1917
" \n",
@@ -30,7 +28,7 @@
3028
"\n",
3129
"1. View static HTML pages. (Just browse to the [repository](https://github.com/aimacode/aima-python) and click on a `.ipynb` file link.)\n",
3230
"2. Run, modify, and re-run code, live. (Download the repository (by [zip file](https://github.com/aimacode/aima-python/archive/master.zip) or by `git` commands), start a Jupyter notebook server with the shell command \"`jupyter notebook`\" (issued from the directory where the files are), and click on the notebook you want to interact with.)\n",
33-
"3. Binder - Click on the binder badge on the [repository](https://github.com/aimacode/aima-python) main page to open the notebooks in an executable environment, online. This method does not require any extra installation. The code can be executed and modified from the browser itself.\n",
31+
"3. Binder - Click on the binder badge on the [repository](https://github.com/aimacode/aima-python) main page to open the notebooks in an executable environment, online. This method does not require any extra installation. The code can be executed and modified from the browser itself. Note that this is an unstable option; there is a chance the notebooks will never load.\n",
3432
"\n",
3533
" \n",
3634
"You can [read about notebooks](https://jupyter-notebook-beginner-guide.readthedocs.org/en/latest/) and then [get started](https://nbviewer.jupyter.org/github/jupyter/notebook/blob/master/docs/source/examples/Notebook/Running%20Code.ipynb)."
@@ -39,9 +37,7 @@
3937
{
4038
"cell_type": "markdown",
4139
"metadata": {
42-
"collapsed": true,
43-
"deletable": true,
44-
"editable": true
40+
"collapsed": true
4541
},
4642
"source": [
4743
"# Helpful Tips\n",
@@ -51,11 +47,9 @@
5147
},
5248
{
5349
"cell_type": "code",
54-
"execution_count": 2,
50+
"execution_count": 1,
5551
"metadata": {
56-
"collapsed": true,
57-
"deletable": true,
58-
"editable": true
52+
"collapsed": true
5953
},
6054
"outputs": [],
6155
"source": [
@@ -64,46 +58,48 @@
6458
},
6559
{
6660
"cell_type": "markdown",
67-
"metadata": {
68-
"deletable": true,
69-
"editable": true
70-
},
61+
"metadata": {},
7162
"source": [
7263
"From there, the notebook alternates explanations with examples of use. You can run the examples as they are, and you can modify the code cells (or add new cells) and run your own examples. If you have some really good examples to add, you can make a github pull request.\n",
7364
"\n",
74-
"If you want to see the source code of a function, you can open a browser or editor and see it in another window, or from within the notebook you can use the IPython magic function `%psource` (for \"print source\"):"
65+
"If you want to see the source code of a function, you can open a browser or editor and see it in another window, or from within the notebook you can use the IPython magic function `%psource` (for \"print source\") or the function `psource` from `notebook.py`. Also, if the algorithm has pseudocode, you can read it by calling the `pseudocode` function with input the name of the algorithm."
7566
]
7667
},
7768
{
7869
"cell_type": "code",
79-
"execution_count": 3,
70+
"execution_count": 2,
8071
"metadata": {
81-
"collapsed": true,
82-
"deletable": true,
83-
"editable": true
72+
"collapsed": true
8473
},
8574
"outputs": [],
8675
"source": [
8776
"%psource WalkSAT"
8877
]
8978
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": null,
82+
"metadata": {},
83+
"outputs": [],
84+
"source": [
85+
"from notebook import psource, pseudocode\n",
86+
"\n",
87+
"psource(WalkSAT)\n",
88+
"pseudocode(\"WalkSAT\")"
89+
]
90+
},
9091
{
9192
"cell_type": "markdown",
92-
"metadata": {
93-
"deletable": true,
94-
"editable": true
95-
},
93+
"metadata": {},
9694
"source": [
9795
"Or see an abbreviated description of an object with a trailing question mark:"
9896
]
9997
},
10098
{
10199
"cell_type": "code",
102-
"execution_count": 6,
100+
"execution_count": 3,
103101
"metadata": {
104-
"collapsed": true,
105-
"deletable": true,
106-
"editable": true
102+
"collapsed": true
107103
},
108104
"outputs": [],
109105
"source": [
@@ -112,14 +108,11 @@
112108
},
113109
{
114110
"cell_type": "markdown",
115-
"metadata": {
116-
"deletable": true,
117-
"editable": true
118-
},
111+
"metadata": {},
119112
"source": [
120113
"# Authors\n",
121114
"\n",
122-
"This notebook by [Chirag Vertak](https://github.com/chiragvartak) and [Peter Norvig](https://github.com/norvig)."
115+
"This notebook is written by [Chirag Vertak](https://github.com/chiragvartak) and [Peter Norvig](https://github.com/norvig)."
123116
]
124117
}
125118
],
@@ -139,9 +132,9 @@
139132
"name": "python",
140133
"nbconvert_exporter": "python",
141134
"pygments_lexer": "ipython3",
142-
"version": "3.5.2"
135+
"version": "3.5.3"
143136
}
144137
},
145138
"nbformat": 4,
146-
"nbformat_minor": 0
139+
"nbformat_minor": 1
147140
}

0 commit comments

Comments
 (0)