Calculate Frequency of N 2 Strings
This calculator helps you determine how often two specific strings appear together in a given text. It's useful for analyzing word patterns, co-occurrence statistics, and text analysis tasks.
How to Use This Calculator
To calculate the frequency of two strings in a text:
- Enter the first string you want to analyze in the "First String" field.
- Enter the second string you want to analyze in the "Second String" field.
- Paste or type the text you want to analyze in the "Text to Analyze" field.
- Click the "Calculate" button to get the results.
- Review the results showing how often the two strings appear together in the text.
The calculator will show you the exact count of times both strings appear consecutively in the text, as well as the percentage of the total words that match this pattern.
Formula Explained
The calculation follows these steps:
- Split the input text into individual words (tokens).
- Iterate through the words to find consecutive occurrences of the two strings.
- Count each time the first string is immediately followed by the second string.
- Calculate the percentage by dividing the count by the total number of words in the text.
This formula provides a simple measure of how often the two strings appear together in sequence.
Worked Examples
Example 1: Simple Sentence
Text: "The quick brown fox jumps over the lazy dog"
String1: "the"
String2: "quick"
Result: The strings "the" and "quick" appear together once in this sentence.
Example 2: Repeated Phrases
Text: "Data data analysis is important for data science. Data analysis helps in decision making."
String1: "data"
String2: "analysis"
Result: The strings "data" and "analysis" appear together twice in this text.
Note: The calculator counts exact matches only. It does not account for different word forms or synonyms.
Frequently Asked Questions
- What does this calculator measure?
- This calculator measures how often two specific strings appear consecutively in a given text.
- Does the calculator count partial matches?
- No, the calculator only counts exact matches of the entire strings you specify.
- Is the calculation case-sensitive?
- Yes, the calculator performs case-sensitive matching. "The" and "the" would be considered different strings.
- Can I analyze multiple texts at once?
- No, this calculator analyzes one text at a time. You would need to run the calculation separately for each text.
- What if the strings don't appear together at all?
- The calculator will show a count of 0 and a frequency of 0%, indicating the strings never appear consecutively in the text.