Ravindra BagaleCourses & study guides English Track your progress

51. What Is Natural Language Processing (NLP)

Data Science

51.3 Tiny Text Cleaning Pipeline

51.3 Tiny text-cleaning pipeline

Raw text messy असतो: emoji, Marathi–English mix, “Pune!!!” vs “pune”.

हे का शिकायचं?

Why. Raw text messy: emoji, Marathi–English mix, extra spaces, “Pune!!!” vs “pune”. Features आधी calm pipeline हवा.

हे काय आहे?

What. Beginner pipeline: lowercase → punctuation/noise strip → tokens (words) → optional stop-word drop → मग vectorise (Chapter 52). आधी Python strings आणि lists.

कसं करायचं?

How.

एक fictional review clean करा

  1. String lowercase.
  2. Letters/numbers/spaces ठेवा; जास्त punctuation काढा.
  3. Spaces वर split → tokens.
  4. Drop empty tokens.
import re

raw = " Fresh PEDHA from Nashik!!! Delivery was OK :) "
text = raw.lower().strip()
text = re.sub(r"[^a-z0-9\s]", " ", text)
tokens = [t for t in text.split() if t]
print(tokens)
# ['fresh', 'pedha', 'from', 'nashik', 'delivery', 'was', 'ok']

Fictional data. Demo reviews teaching साठी — real customer dump नाही.

Reviews are invented for teaching — not scraped from a real storefront.