3.5 Useful Applications of Regular Expressions
Doing More with Word PiecesOnce we can use re.findall() to extract material from words, there are interestingthings to do with the pieces, such as glue them back together or plot…
Doing More with Word PiecesOnce we can use re.findall() to extract material from words, there are interestingthings to do with the pieces, such as glue them back together or plot…
Many linguistic processing tasks involve pattern matching. For example, we can findwords ending with ed using endswith('ed'). Regular expressions give us a more powerful and flexible method for describing the…
Unicode supports over a million characters. Each character is assigned a number, calleda code point. In Python, code points are written in the form \uXXXX, where XXXXis the number in…
It’s time to study a fundamental data type that we’ve been studiously avoiding so far.In earlier chapters we focused on a text as a list of words. We didn’t look…
Electronic Books A small sample of texts from Project Gutenberg appears in the NLTK corpus collection. However, you may be interested in analyzing other texts from Project Gutenberg. You can…
Senses and SynonymsConsider the sentence in (1a). If we replace the word motorcar in (1a) with automobile, to get (1b), the meaning of the sentence stays pretty much the same:(1)…
A lexicon, or lexical resource, is a collection of words and/or phrases along with associated information, such as part-of-speech and sense definitions. Lexical resources aresecondary to texts, and are usually…
Creating Programs with a Text EditorThe Python interactive interpreter performs your instructions as soon as you type them.Often, it is better to compose a multiline program using a text editor,…
We introduced frequency distributions in Section 1.3. We saw that given some listmylist of words or other items, FreqDist(mylist) would compute the number ofoccurrences of each item in the list.…
Gutenberg CorpusNLTK includes a small selection of texts from the Project Gutenberg electronic textarchive, which contains some 25,000 free electronic books, hosted at http://www.gutenberg.org/. We begin by getting the Python…