How to parse product titles unstructured into structured data?
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
Parsing product titles into structured data means turning messy text such as brand, model, color, size, and quantity into separate fields that software can reason about. The hard part is not splitting on spaces. It is handling ambiguity, inconsistent abbreviations, missing attributes, and category-specific vocabulary.
Start with a Clear Target Schema
Before writing any parsing code, define what structured output you actually want. For example:
- brand,
- product type,
- size,
- color,
- quantity,
- model or series,
- gender or audience where relevant.
Without a target schema, parsing quality is impossible to measure because you do not know what the parser is supposed to extract.
Normalize the Raw Title First
A good first step is basic normalization:
- lowercase or standardized casing,
- punctuation cleanup,
- unit normalization such as
oz,ml, andpack, - synonym normalization such as
blktoblack.
This does not solve the whole problem, but it reduces the number of token variants the parser must handle.
Rule-Based Extraction Often Comes First
For many catalogs, a rule-based parser plus dictionaries works surprisingly well. You can look for known colors, sizes, units, and brands.
This is usually the right starting point because it is transparent and easy to debug.
Use Category Context to Reduce Ambiguity
The same token can mean different things in different categories. M may mean medium in clothing, meters in hardware, or model code in electronics. That is why product-title parsing works better when category information is available.
A parser for apparel should not be identical to a parser for power tools. Category-aware rules reduce false positives significantly.
Move to Statistical or ML Models When Rules Plateau
Once rule-based extraction reaches its limit, a machine-learning or sequence-labeling model can help identify attributes in more varied text. But even then, rule-based normalization and dictionaries usually remain part of the pipeline.
In practice, the strongest systems are often hybrid:
- normalization and dictionary cleanup first,
- rule extraction for easy attributes,
- ML for ambiguous or context-dependent fields,
- confidence scoring for uncertain parses.
Evaluate on Real Titles, Not Invented Examples
Product title parsing quality depends heavily on the actual catalog language. Build a labeled sample of real titles and measure extraction accuracy per field. That quickly shows whether the parser fails mostly on brands, units, sizes, or ambiguous descriptors.
Common Pitfalls
- Starting with regex alone without defining a target schema.
- Treating all product categories as if they used the same vocabulary.
- Ignoring normalization and forcing every rule to handle messy token variants.
- Expecting one parser pass to perfectly infer missing or ambiguous attributes.
- Skipping labeled evaluation and relying only on anecdotal examples.
Summary
- Product-title parsing starts with a clear schema, not with regex.
- Normalization reduces the number of messy text variants the parser must handle.
- Rule-based extraction is usually the right first step.
- Category context matters because product vocabulary is not universal.
- The best production pipelines often combine rules, dictionaries, and ML rather than choosing only one approach.
Related reading
- How to proceed with NLP task for recognizing intent and slots
- How to read a file without newlines?
- How to recognize words in text with non-word tokens?
- How to recreate same DocumentTermMatrix with new test data
- How to remove new line characters from a string?
- How to remove newlines from beginning and end of a string?
- How to remove specific substrings from a set of strings in Python?
- How to remove stop words using nltk or python
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.