Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Word frequency ignoring stop words

Python data engineering interview problem. Difficulty: intermediate. Pattern: Dictionaries. About 15 minutes. Part of the Pro drill bank.

A knowledge-base search wants word counts from an article but should ignore stop words like 'the' and 'and' so the histogram is actually useful.

Count word frequency in text after removing a provided stop-word list.

Requirements

  • Normalize case before comparing to stop words.
  • Return counts only for remaining tokens.

Constraints

  • Punctuation should not create extra keys.

Examples

Input: word_freq_filtered('The the cat sat', ['the']) Output: {'cat': 1, 'sat': 1} This input follows the stated rules and produces this output.

Topics: lakebench, python, frequency-counting.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Word frequency ignoring stop words

Interview-style drill: Count word frequency in a document, excluding a given set of stop words.

Count word frequency in text after removing a provided stop-word list.