Entries from 2013-04-23 to 1 day

O'Reilly: Chapter 1 Exercise 17-22

Continuing Chapter 1 Exercise...17. >>> text9.index('sunset') 629 >>> text9[620:630] ['PARK', 'THE', 'suburb', 'of', 'Saffron', 'Park', 'lay', 'on', 'the', 'sunset'] >>> text9[620:635] ['PARK', 'THE', 'suburb', 'of', 'Saffron', 'Park', 'la…

Similaritiy of words

Let's start with a sample; to calculate similarity of two words, 'cookbook' and 'instruction_book'. >>> cb = wordnet.synset('cookbook.n.01') >>> ib = wordnet.synset('instruction_book.n.01') >>> cb.wup_similarity(ib) 0.9166666666666666 Alth…

Word collocations

According to the text book, Collocations are two or more words that tend to appear frequently together. This was also introduced in chapter 1 of the O'Reilly's text. >>> from nltk.corpus import webtext >>> from nltk.collocations import Big…