Learning about NLTK

In the past couple of week I’ve been helping to update the curriculum for a fantastic project called DH Bridge. This curriculum includes a one-day programming bootcamp for people with no computer science experience (and particularly those who are also involved in the humanities) to learn some basic Python skills. I’ve had so much fun doing the tutorial along the way because it focuses on text analysis using the Natural Language Toolkit (NLTK), which I wasn’t previously familiar with, but includes some really cool tools for natural language processing. You can download NLTK for free and use the many Python libraries it has available to do text analysis day and night! Here are a few of the things I learned:

  • NLTK has a built in method for getting word frequencies, and it’ll spit out the n most common words in a text (you decide what n is) along with the number of times that each word appears, in order from most to least frequent. Nothing too complicated – but it’s a great (and very useful) starting place.
  • Want to see the context in which a certain word appears throughout a text? This method takes a single word as a parameter and prints out each instance of that word within its surrounding text. For example, here’s every instance of the word “trial” in Harper Lee’s To Kill a Mockingbird.

This is a great way to get a sense of how a word is being used throughout a text without having to Control+F your way through the whole thing.

  • This one is my favorite because I think it’s so cool. You give it a word and it returns the twenty words that are “most similar” to that word in the text. I haven’t looked too far into how it works, but the method somehow determines which words are most often used in a similar context to the given word. For example, here are the results for the word “trial” in To Kill a Mockingbird.

Some words, like “court” and “newspaper” are pretty self explanatory, but we may question why a word like “family” is so closely associated with the word “trial” in this novel.

Even with these very simple searches, it’s already easy to see the kind of information you can get out of a text that the human eye wouldn’t necessarily be able to see. Yay digital text analysis!

Testing the Guide to Set Up WordPress Locally with WAMP

A local server environment will make testing themes and plugins of WordPress much easier. One of the ways to achieve this to install WAMP on your PC. I found this great blog post titled How to Set Up WordPress Locally for PC/Windows with WampServer by Raelene Morey. I installed WAMP on my PC and set up WordPress following this guide. Here is a summary of what I did and found, including a few details which are emitted from the guide.

Install WAMP on your PC

  • Go to http://www.wampserver.com/en/
  • Choose the version that matches up with your system
    • You may be unsure about downloading the 64 bits or the 32 bits version. You can check your system type by typing “System” in the search box. Look for the “System Type” field which tell you if your system is x64 or x32.
  • Click “download directly”
  • Follow the installation instructions

Set-up Wordpress on WAMP (things emitted from the guide)

  1. Before downloading WordPress, you need to set up a database first. This requires you to login to phpMyAdmin. You don’t actually need to enter the username nor password in order to login. If clicking “Go” button doesn’t lead you to a new page, try entering “root” as the username and leave the password field blank. 
  2. When you’ve downloaded WordPress following the guide, you’ll need to tweak the wp-config-sample.php file. To edit the .php file, you’ll need a text editor. The one I used was notepad++. You can also try TextWrangler, Brackets and other text editors. (Here is a list of options.) After downloading notepad++ from here, you can right click the .php file and choose “Edit with notepad++”. Here’s how the .php file looked in notepad++ before and after edited.  (before)  (after)


Test WordPress Plugin (Juxtapose) on WAMP

  1. Go to http://localhost/wordpress/ in your WAMP server. Login to your WordPress account.
  2. Search for plugins that you’d like to test.  I chose Juxtapose for this experiment.
  3. Upload images to be juxtaposed to “Media” first. Then in your blog post or wherever you’d like to use this feature, paste in this shortcode –  [juxtapose]<image1><image2>[/juxtapose]. Replace “<image1><image2>” by inserting the images you’d like to be juxtaposed.
  4. Results: now you can compare the two images by sliding the vertical bar. Images of different dimensions may not work as expected. This plugin also works for pairs of images of any size, except thumbnails.