Classifying the parts of speech of words

This recipe will demonstrate how to identify the parts of speech of each word in a sentence. We will be using a handy library called chatter, which contains very useful Natural Language Processing (NLP) tools. It can be obtained from Hackage at http://hackage.haskell.org/package/chatter.

NLP is the study of human language embedded in a machine. Our naturally spoken or written language may seem obvious to us in our day-to-day lives, but producing meaning out of words is still a difficult task for computers.

Getting ready

Install the NLP library using cabal:

cabal install chatter

How to do it…

In a new file, which we name Main.hs, enter the following source code:

  1. Import the parts of speech library and the pack ...

Get Haskell Data Analysis Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.