Bag of Words (BoW)

Why Trust Techopedia

What Does Bag of Words Mean?

Bag of Words (BoW) is a natural language processing (NLP) strategy for converting a text document into numbers that can be used by a computer program. BoW is often implemented as a Python dictionary. Each key in the dictionary is set to a word, and each value is set to the number of times the word appears.

Advertisements

The BoW model is one of the most useful ways to convert text data for use by machine learning algorithms. In this context, text words are referred to as tokens and the entire process of representing a sentence as a bag of words vector (a string of numbers) is known as tokenization.

Techopedia Explains Bag of Words

BoW models are concerned with whether a known word occurs in a document and how many times it occurs — not the order in which it appears, nor its context. BoW plays an important role in natural language processing, information retrieval from documents and document classification.

How Bag of Words Works

BoW is used to extract feature sets from text during the data pre-processing phase. The strategy involves breaking a document down into a list of disparate words and noting how many times each word is used in the document.

The name ‘Bag of Words’ is thought to have been inspired by the popular word game, Scrabble. The value of each tile in a Scrabble bag was determined by how frequently a specific letter appeared on the front page of the New York Times in 1938.

Advertisements

Related Terms

Margaret Rouse
Technology expert
Margaret Rouse
Technology expert

Margaret is an award-winning writer and educator known for her ability to explain complex technical topics to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles in the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret’s idea of ​​a fun day is to help IT and business professionals to learn to speak each other’s highly specialized languages.