What is a affix tagger in nltk

This recipe explains what is a affix tagger in nltk

Recipe Objective

This recipe explains what is a affix tagger.

Step 1: Importing library

Let us first import the necessary libraries. We'll import treebank and AffixTagger from nltk.corpus and nltk.tag respectively.

from nltk.corpus import treebank
from nltk.tag import AffixTagger

Step 2: Affix Tagger

Affix tagger's working principle is that it looks up for a particular fixed-length substring of the word in the table to return the corresponding tag. It is a tagger that chooses a tag based on the trailing and leading substring of its word string. The context is either the suffix or the prefix of a word in the case of AffixTagger class. Affix Tagger is a subclass of ContextTagger. Affix tagger class learns based on a fixed-length substring of the prefix or suffix.

train = treebank.tagged_sents()[:1000]
test = treebank.tagged_sents()[1000:]
aff = AffixTagger(train)
print ("Accuracy : ", aff.evaluate(test))
prefix = AffixTagger(train, affix_length = 2)
accuracy = prefix.evaluate(test)
print ("Accuracy : ", accuracy)
sufix = AffixTagger(train, affix_length = -3)
accuracy = sufix.evaluate(test)
print ("Accuracy : ", accuracy)

What Users are saying..

profile image

Ray han

Tech Leader | Stanford / Yale University
linkedin profile url

I think that they are fantastic. I attended Yale and Stanford and have worked at Honeywell,Oracle, and Arthur Andersen(Accenture) in the US. I have taken Big Data and Hadoop,NoSQL, Spark, Hadoop... Read More

Relevant Projects

Recommender System Machine Learning Project for Beginners-2
Recommender System Machine Learning Project for Beginners Part 2- Learn how to build a recommender system for market basket analysis using association rule mining.

Personalized Medicine: Redefining Cancer Treatment
In this Personalized Medicine Machine Learning Project you will learn to classify genetic mutations on the basis of medical literature into 9 classes.

Classification Projects on Machine Learning for Beginners - 2
Learn to implement various ensemble techniques to predict license status for a given business.

Llama2 Project for MetaData Generation using FAISS and RAGs
In this LLM Llama2 Project, you will automate metadata generation using Llama2, RAGs, and AWS to reduce manual efforts.

NLP and Deep Learning For Fake News Classification in Python
In this project you will use Python to implement various machine learning methods( RNN, LSTM, GRU) for fake news classification.

Build a Multi ClassText Classification Model using Naive Bayes
Implement the Naive Bayes Algorithm to build a multi class text classification model in Python.

Build a CNN Model with PyTorch for Image Classification
In this deep learning project, you will learn how to build an Image Classification Model using PyTorch CNN

MLOps using Azure Devops to Deploy a Classification Model
In this MLOps Azure project, you will learn how to deploy a classification machine learning model to predict the customer's license status on Azure through scalable CI/CD ML pipelines.

Learn Hyperparameter Tuning for Neural Networks with PyTorch
In this Deep Learning Project, you will learn how to optimally tune the hyperparameters (learning rate, epochs, dropout, early stopping) of a neural network model in PyTorch to improve model performance.

Model Deployment on GCP using Streamlit for Resume Parsing
Perform model deployment on GCP for resume parsing model using Streamlit App.