Menu

Clustering App Ad Hooks in Go: TF-IDF, Cosine Similarity and a Hand-Labelled Sample, and the Walls You'll Hit (2026)
📰

Clustering App Ad Hooks in Go: TF-IDF, Cosine Similarity and a Hand-Labelled Sample, and the Walls You'll Hit (2026)

DEV Community: go·Fekri·2 days ago
#weabRmvG
#devtogo#devto#dev#hooks#terms
Reading 0:00
15s threshold

When I look at a competitor's ads, the first line matters most. The hook. "Stop living paycheck to paycheck." "No gym? No problem." After copying fifty of them into a note, you see a few angles coming back, but it's hard to say which ones and how often. So I wanted a script that groups hooks by the words they share.

This post builds that script in Go, using only the standard library. It tokenizes a CSV of hooks, builds TF-IDF vectors, compares them with cosine similarity, and merges them with average-linkage agglomerative clustering. For each cluster it prints the top terms, a representative hook and the members. Each hook has a hand label (the app category), so the script can check how often a cluster mixes categories.

I ran everything below with Go 1.27.3 on Linux on 16 November 2026. The output excerpts are copied from those runs.

The data is made up, on purpose

The hooks.csv in this post is a made-up sample dataset . I wrote all 50 lines myself, in the style of habit, fitness and budgeting app ads.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.