Skip to content
Tutorials Center
My learning

Topics

Lesson 35 of 36 ยท Projects and Practice

Project: Content Brief with TF-IDF

Build a content brief tool in Python that compares your draft with competing pages using keyword density, TF-IDF, readability and heading coverage, with no external libraries.

A content brief tells a writer what a page must cover: the target query, the search intent, the questions to answer, the subtopics to include and the terms that expert pages naturally use. In this project you will write small tools that help produce one: a text cleaner, a keyword-density check, a TF-IDF term ranker, a readability score and a heading outline. Everything is plain Python and runs in your browser.

This is a helper for human judgment, not an oracle. Search engines do not rank by a magic keyword percentage, and copying the terms of top pages produces a copy, not a better page. Use the output to notice what you forgot, then write something original and more helpful.

Step 1: tokenizing and keyword density

Keyword density is how often a term appears relative to the total words. There is no ideal percentage; it is useful only to spot extremes (a keyword missing, or stuffed into every sentence).

Python Keyword density

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice how the phrase takes a large share of this tiny sample. Natural writing varies terms, uses synonyms and pronouns, and mentions related ideas.

Step 2: TF-IDF

TF-IDF (term frequency x inverse document frequency) gives a high score to words that are frequent in one document but rare across the others. It is a classic way to find the characteristic terms of a page. We compute it for a small set of competitor pages (short invented excerpts) and list the terms your draft may be missing.

  • TF = how often the term appears in the document, divided by the document's length.
  • IDF = log(number of documents / number of documents containing the term), plus a small smoothing term.
Python Characteristic terms across competitor pages

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The missing list is a prompt for questions: does the draft explain rock plates, cushioning, waterproofing and terrain? Add them only where they help the reader. With real work you would use many more pages, remove boilerplate and consider phrases, not only single words.

Step 3: readability

Readability formulas estimate how hard a text is to read from sentence and word length. The Flesch reading ease score is higher for easier text: roughly 60-70 is plain English, below 30 is very difficult. Very simple text can even score above 100 and dense text below 0. Syllable counting is approximate, and the formula is built for English only, so treat it as a rough indicator and match your audience.

Python Flesch reading ease

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 4: outline from questions

The best brief is built from the questions people ask. Collect them from search suggestions, forums, customer emails and your own expertise, group them, and turn them into headings. This prints a simple brief template from structured data.

Python Generate a brief

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

(The internal link in the data is just an example slug from this course.)

Putting it to work

  1. Pick the target query and study the results: intent, format and common subtopics (Content Strategy and Topical Authority).
  2. Run the tools on your draft and on a few competitors you have permission to analyse as part of ordinary research.
  3. Add missing subtopics, evidence, examples and your own point of view.
  4. Write the title and meta description last, with the on-page checks from the previous project (Project: Build a Meta Tag Auditor).
  5. Publish, track performance and refresh (Refreshing and Pruning Content).

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a high TF-IDF score for a term in a document indicate?

    TF-IDF rewards terms characteristic of one document rather than words common everywhere.
  2. 2. Is there an ideal keyword density to rank?

    Search engines do not use a target density; write naturally and cover the topic.
  3. 3. What does a higher Flesch reading ease score mean?

    The score rises with shorter sentences and shorter words.
  4. 4. What should you do with the list of missing competitor terms?

    The terms are prompts for coverage, not text to copy.

Summary

  • A content brief captures intent, audience, outline, terms, links and evidence.
  • Keyword density is a sanity check; TF-IDF suggests characteristic terms.
  • Readability scores are rough indicators for English text.
  • Use the tools to find gaps, then write original, genuinely helpful content.

Next: SEO Practice and Final Checklist