Similarity Results
Not calculatedToken Overview
Common tokens
Unique to Text A
Unique to Text B
Vector Contribution Chart
Detailed Vector Table
| Token | Text A frequency | Text B frequency | Text A weight | Text B weight | Dot contribution |
|---|
Token Frequency Comparison
Shared and Unique Tokens
Multiple-Document Results
Pairwise similarity matrix
Calculation Details
Calculation History
Formula Used
Cosine Similarity = (A · B) / (||A|| × ||B||)
Each text becomes a numeric vector. Matching vocabulary creates comparable dimensions. The score measures vector direction rather than text length.
How to Use
- Enter or upload two texts.
- Choose preprocessing and tokenization settings.
- Select a vector weighting method.
- Add optional batch documents.
- Calculate, review, and export results.
Worked Example
| Input | Example |
|---|---|
| Text A | Machine learning models analyse text data. |
| Text B | Text analysis uses machine learning models. |
| Method | Word tokens with raw term frequency. |
| Expected result | A high score because several important tokens overlap. |
Bag-of-Words and TF-IDF
Bag-of-words counts tokens without modelling order. TF-IDF reduces weights for widely shared terms. Both methods provide useful and transparent baselines.
Advantages and Limitations
Cosine similarity is fast, interpretable, and scale independent. It does not automatically understand synonyms or context. Results depend strongly on preprocessing and vectorization choices.
Common Applications
Use it for document ranking, duplicate detection, clustering, search, and matching. It also supports plagiarism screening and recommendation baselines. Semantic embeddings are preferable when deeper meaning matters.
Frequently Asked Questions
What does a cosine similarity score mean?
A larger score indicates more similar vector directions. For non-negative text vectors, results usually range from zero to one.
Is cosine similarity affected by document length?
Vector normalisation reduces direct length effects. Repeated vocabulary can still influence term weights.
When should I use TF-IDF?
Use TF-IDF when common words should contribute less. It is especially useful across multiple documents.
What happens when no tokens match?
The dot product becomes zero. The cosine similarity is therefore zero.
What is a zero-magnitude vector?
It occurs when preprocessing removes every usable token. The calculator reports a warning instead of dividing by zero.
Does this detect semantic similarity?
It measures lexical vector similarity. Synonyms may appear unrelated unless they share tokens.
What are word n-grams?
They combine consecutive tokens into phrases. Bigrams can capture limited word order information.
Why remove stop words?
Stop-word removal can emphasise content terms. It may also discard useful context in short texts.
How should I choose a threshold?
Test thresholds on labelled examples from your application. There is no universal similarity cutoff.
Can I compare many documents?
Yes. Add one document per line to create rankings and a pairwise matrix.
Are uploaded files sent to a server?
No calculator processing is submitted by this page. The browser reads supported files locally.