Skip to content

soheil-mp/Hidden-Markov-Model-POS

Repository files navigation

Hidden Markov Model Part of Speech tagger

Introduction

Part of speech tagging is the process of determining the syntactic category of a word from the words in its surrounding context. It is often used to help disambiguate natural language phrases because it can be done quickly with high accuracy. Tagging can be used for many NLP tasks like determining correct pronunciation during speech synthesis (for example, dis-count as a noun vs dis-count as a verb), for information retrieval, and for word sense disambiguation.

In this notebook, we'll use the Pomegranate library to build a hidden Markov model for part of speech tagging using a "universal" tagset. Hidden Markov models have been able to achieve >96% tag accuracy with larger tagsets on realistic text corpora. Hidden Markov models have also been used for speech recognition and speech generation, machine translation, gene recognition for bioinformatics, and human gesture recognition for computer vision, and more.

Getting Started

  1. (Optional) The provided code includes a function for drawing the network graph that depends on GraphViz. You must manually install the GraphViz executable for your OS before the steps below or the drawing function will not work.

  2. Open a terminal and clone the project repository:

$ git clone https://github.com/soheillll/hidden_markov_model_tagger
  1. Switch to the project folder and create a conda environment (note: you must already have Anaconda installed):
$ cd hmm-tagger
hmm-tagger/ $ conda env create -f hmm-tagger.yaml
  1. Activate the conda environment, then run the jupyter notebook server. (Note: windows users should run activate hmm-tagger)
hmm-tagger/ $ source activate hmm-tagger
(hmm-tagger) hmm-tagger/ $ jupyter notebook

Depending on your system settings, Jupyter will either open a browser window, or the terminal will print a URL with a security token. If the terminal prints a URL, simply copy the URL and paste it into a browser window to load the Jupyter browser. Once you load the Jupyter browser, select the project notebook (HMM tagger.ipynb) and follow the instructions inside to complete the project.