09 Sep 2016
By the way, if you already know Python very well, this beginning stuff is probably really not super-interesting. Sorry about that. I want everyone to get to a point where they’re comfortable enough with Python to make it do simple things and know how to find out more as needed later. I’ll see if after this week I can try to come up with some alternative, more advanced things to do that might be more interesting/challenging if you already are quite well up to speed on list comprehensions and slices and functions and classes and so forth. At its core, this course is still more a “programming for linguists” course than a “linguistics for programmers” course, but I’ll try to get us to a point where everyone’s doing stuff that’s new to them before long (but absolutely without leaving those of you for whom Python/programming is new lost in the woods).
09 Sep 2016
The first homework is a “just getting comfortable” assignment, based on section 1 and partly on section 2 of the NLTK book, and using exercises already in the book.
Those exercises are: 2, 3, 4, 6, 12, 13, 21, 27, 28, 29.
You can send the answers to me in whatever form I can read. Electronic is preferable, just plain text in an email is fine, but so is Word, PDF.
08 Sep 2016
Just as note of reassurance, let me point out that the readings for tomorrow are sections 5 and 1 of chapter 1 of the NLTK book. While section 5 pretty much stands on its own, section 1 kind of assumes you’re following along at a Python prompt.
My intention for tomorrow is to talk about section 1, and actually walk through it and related material while you are at a Python prompt on the computers in the classroom. If you don’t have Python installed at home, that’s ok. I wanted you to read through section 1 so that it’s not all a surprise to you as we do it in class, but in those places where it doesn’t reveal what Python’s telling you in response, you’ll find out soon enough.
Generally, as the class proceeds, it will probably be very useful to have a Python prompt at hand while reading through the material. That’s how the book was written to be read, as a guide to exploring the tools. But if you haven’t succeeded in installing Python/NLTK on your own computer yet, it’s fine. I would suggest you attempt it, and we can work together to try to troubleshoot your endeavors to get it installed (since if you don’t have it at home, it’ll come to be necessary to come into the computer lab outside of class time to work through some of the homework and readings), but for the moment just reading enough to get the gist of what we’ll go through more systematically in class is perfectly good enough.
07 Sep 2016
If you are trying to install NLTK on your own Mac OS X computer, there are a couple of things that you might need to do differently from what the instructions given online tell you to do.
As background, here’s the thing: Mac OS X comes with Python pre-installed, but it is an older version of Python than we want (it is Python 2, we want Python 3). This adds complexity, because you need to install Python 3 yourself, but it also needs to co-exist with Python 2. This means that sometimes where the instructions say to type python
or pip
you need to type python3
or pip3
instead. There are also potentially “permissions” problems that can arise.
As far as I know at least, the following should work:
- Install Python 3.5 from the python.org downloads page (Download Python 3.5.2, then double-click on the resulting .pkg file and follow the prompts).
- Open Terminal (located in your Applications folder, in the Utilities folder within).
- Type
pip3 install -U nltk
(do not include sudo
, and do include the 3, which differs from the instructions on the Installing NLTK page).
- You probably also want to install
numpy
and matplotlib
, which you would do in the same way. Use pip3
and do not use sudo
.
Then, when you want to start Python from the Terminal, start it with python3
(not python
—python
without the 3 will start Python 2 rather than Python 3). If you use IDLE in the Python 3.5 folder in your Applications folder, then you’ll be using Python 3. But as I mentioned in class, I prefer Terminal to IDLE myself, mostly due to the ability to use the “up-arrow” to retrieve previously typed commands. As far as I know, you cannot do this in IDLE.
Mostly this also applies to the Macs in the lab as well. So, you’ll generally want to type python3 on those machines as well.
Generally, this is irrelevant for the Windows installations, because Python 2 is not automatically included with Windows, so you can use python to get to Python 3. I believe.