UNPKG

textanalysis-tool

Version:

A TypeScript module providing text analysis functionalities with various operations.

774 lines (605 loc) โ€ข 27.1 kB
# ๐ŸŒŸ Text Analysis Tools ๐ŸŒŸ [![npm version](https://img.shields.io/npm/v/textanalysis-tool.svg)](https://www.npmjs.com/package/textanalysis-tool) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![TypeScript](https://img.shields.io/badge/%3C/%3E-TypeScript-blue)](https://www.typescriptlang.org/) > ๐Ÿš€ A lightning-fast โšก TypeScript library for ๐Ÿค– text analysis and ๐Ÿ”ง manipulation. Bundled with everything from simple cleanup to deep linguistic insights! ๐Ÿ“ฆ --- ## ๐Ÿ—‚๏ธ Table of Contents - [๐ŸŒŸ Text Analysis Tools ๐ŸŒŸ](#-text-analysis-tools-) - [๐Ÿ—‚๏ธ Table of Contents](#๏ธ-table-of-contents) - [โฌ‡๏ธ Installation](#๏ธ-installation) - [๐Ÿงฉ Usage](#-usage) - [๐Ÿ”ฐ Basic Usage](#-basic-usage) - [โš™๏ธ Working with Operations](#๏ธ-working-with-operations) - [๐Ÿง  Advanced Analysis](#-advanced-analysis) - [๐Ÿญ Using Factory Methods](#-using-factory-methods) - [๐Ÿ“ฆ Batch Processing](#-batch-processing) - [๐Ÿ› ๏ธ Available Operations](#๏ธ-available-operations) - [๐Ÿ—‘๏ธ Text Removal](#๏ธ-text-removal) - [๐Ÿ“ค Text Extraction](#-text-extraction) - [๐Ÿ”„ Text Transformation](#-text-transformation) - [๐Ÿ”ข Text Counting](#-text-counting) - [๐Ÿ”ฎ Advanced Analysis Options](#-advanced-analysis-options) - [๐ŸŽจ Custom Operations](#-custom-operations) - [โž• Adding Custom Operations](#-adding-custom-operations) - [๐Ÿ“Š With Metadata Extraction](#-with-metadata-extraction) - [๐Ÿš€ Advanced Usage](#-advanced-usage) - [๐Ÿ”˜ Toggling Operations](#-toggling-operations) - [๐Ÿ”€ Managing Multiple Operations](#-managing-multiple-operations) - [๐Ÿ”„ Resetting Text](#-resetting-text) - [โœ‚๏ธ Truncating Text](#๏ธ-truncating-text) - [๐Ÿ“˜ API Reference](#-api-reference) - [๐Ÿงฐ Tools.Analyser Class](#-toolsanalyser-class) - [๐Ÿงฉ Tools.Operations Enum](#-toolsoperations-enum) - [๐Ÿ” Tools.ToolsConstant Class](#-toolstoolsconstant-class) - [๐Ÿ“‹ Interface Types](#-interface-types) - [๐Ÿ”Œ Extensions](#-extensions) - [๐Ÿ˜Š SentimentAnalyzer](#-sentimentanalyzer) - [๐Ÿ“ TextSummarizer](#-textsummarizer) - [๐Ÿ“Š TextStatistics](#-textstatistics) - [๐ŸŒ LanguageDetector](#-languagedetector) - [๐Ÿ” TextDiff](#-textdiff) - [๐Ÿงฉ Interfaces \& Types](#-interfaces--types) - [๐Ÿ˜€ SentimentResult](#-sentimentresult) - [๐Ÿท๏ธ SentimentClassification](#๏ธ-sentimentclassification) - [๐Ÿ“– ReadabilityResult](#-readabilityresult) - [๐Ÿ—ฃ๏ธ LanguageDetectionResult](#๏ธ-languagedetectionresult) - [๐Ÿ”„ TextDiffResult](#-textdiffresult) - [๐Ÿค Contributing](#-contributing) - [๐Ÿ“ License](#-license) --- ## โฌ‡๏ธ Installation > _Install in one click! โœจ_ ```bash npm install textanalysis-tool ``` or via Yarn: ```bash yarn add textanalysis-tool ``` --- ## ๐Ÿงฉ Usage ### ๐Ÿ”ฐ Basic Usage ```typescript import { Tools } from 'textanalysis-tool'; const text = "This is a sample text with 123 numbers and https://example.com URL!"; // Create analyzer with specific operations enabled const analyser = new Tools.Analyser(text, { [Tools.Operations.CountCharacters]: true, [Tools.Operations.CountWords]: true, [Tools.Operations.ExtractUrls]: true }); // Run the analysis analyser.main() .then(result => { console.log("Text analysis results:"); console.log(`- Character count: ${result.metadata.counts.characterCount}`); console.log(`- Word count: ${result.metadata.counts.wordCount}`); console.log(`- URLs found: ${result.metadata.urls?.join(', ')}`); console.log(`- Operations performed: ${result.operations.join(', ')}`); console.log(`- Execution time: ${result.executionTime}ms`); }) .catch(error => { console.error('Analysis failed:', error); }); ``` ### โš™๏ธ Working with Operations ```typescript import { Tools } from 'textanalysis-tool'; const analyser = new Tools.Analyser("Hello, world! 123 #hashtag @mention", { // Enable specific operations [Tools.Operations.RemovePunctuations]: true, [Tools.Operations.RemoveNumbers]: true, [Tools.Operations.ConvertToUppercase]: true }); analyser.main().then(result => { console.log(result.output); // "HELLO WORLD HASHTAG MENTION" }); ``` ### ๐Ÿง  Advanced Analysis ```typescript import { Tools } from 'textanalysis-tool'; const paragraph = `This tool is amazing ๐ŸŽฏ. Sometimes you need exact control.`; const analyser = new Tools.Analyser(paragraph, { [Tools.Operations.AnalyzeSentiment]: { positive: ['amazing'], negative: ['need'] }, [Tools.Operations.SummarizeText]: { sentenceCount: 2 }, [Tools.Operations.CalculateReadability]: true, [Tools.Operations.DetectLanguage]: true, [Tools.Operations.CompareTexts]: { compareWith: 'Other example text.' } }); analyser.main().then(result => { console.log('โค๏ธ Sentiment:', result.sentiment); console.log('โœ‚๏ธ Summary:', result.summary); console.log('๐Ÿ“– Readability:', result.readability); console.log('๐ŸŒ Language:', result.language); console.log('๐Ÿ” Text Diff:', result.diff); }); ``` ### ๐Ÿญ Using Factory Methods ```typescript import { Tools } from 'textanalysis-tool'; // Create an analyzer with specific operations enabled const analyser = Tools.Analyser.createWithEnabledOperations( "Hello, world! 123", ['CountCharacters', 'CountWords', 'RemovePunctuations'] ); analyser.main().then(result => { console.log(result.output); // "Hello world 123" console.log(`Words: ${result.metadata.counts.wordCount}`); console.log(`Characters: ${result.metadata.counts.characterCount}`); }); ``` ### ๐Ÿ“ฆ Batch Processing ```typescript import { Tools } from 'textanalysis-tool'; const texts = [ "First sample with https://example1.com", "Second sample 12345 with #hashtags", "Third sample with @mentions and emails@example.com" ]; const options = { [Tools.Operations.CountWords]: true, [Tools.Operations.ExtractUrls]: true, [Tools.Operations.ExtractHashtags]: true, [Tools.Operations.ExtractMentions]: true, [Tools.Operations.ExtractEmails]: true }; Tools.Analyser.batch(texts, options) .then(results => { results.forEach((result, index) => { console.log(`\nAnalysis of text #${index + 1}:`); console.log(`- Word count: ${result.metadata.counts.wordCount}`); console.log(`- URLs: ${result.metadata.urls?.join(', ') || 'None'}`); console.log(`- Hashtags: ${result.metadata.hashtags?.join(', ') || 'None'}`); console.log(`- Mentions: ${result.metadata.mentions?.join(', ') || 'None'}`); console.log(`- Emails: ${result.metadata.emails?.join(', ') || 'None'}`); }); }); ``` ## ๐Ÿ› ๏ธ Available Operations ### ๐Ÿ—‘๏ธ Text Removal | Operation | Description | Example Input | Example Output | | --------------------- | -------------------------- | ------------------- | ----------------- | | `RemovePunctuations` | ๐Ÿงน Remove punctuation | "Hello, world!" | "Hello world" | | `RemoveNumbers` | ๐Ÿ”ข Remove numbers | "abc123def" | "abcdef" | | `RemoveAlphabets` | ๐Ÿ”ก Remove alphabets | "abc123def" | "123" | | `RemoveSpecialChars` | โœจ Remove special chars | "Hi @you #1!" | "Hi you 1" | | `RemoveNewlines` | โ†ฉ๏ธ Remove newlines | "Hello\nWorld" | "Hello World" | | `RemoveExtraSpaces` | ๐Ÿ“ Trim extra spaces | " Hi there " | "Hi there" | ### ๐Ÿ“ค Text Extraction | Operation | Description | Example Input | Example Output | | ---------------------- | ------------------------ | ------------------------------------ | ------------------------- | | `ExtractUrls` | ๐ŸŒ Extract URLs | "Visit https://a.com and b.org" | ["https://a.com"] | | `ExtractEmails` | โœ‰๏ธ Extract emails | "Email me at user@test.com" | ["user@test.com"] | | `ExtractPhoneNumbers` | ๐Ÿ“ž Extract phone numbers | "Call 123-456-7890" | ["123-456-7890"] | | `ExtractHashtags` | #๏ธโƒฃ Extract hashtags | "#fun #code" | ["#fun","#code"] | | `ExtractMentions` | @๏ธโƒฃ Extract mentions | "Hi @user!" | ["@user"] | ### ๐Ÿ”„ Text Transformation | Operation | Description | Example Input | Example Output | | --------------------- | ----------------------- | ---------------------- | ---------------- | | `ConvertToUppercase` | ๐Ÿ”  UPPERCASE conversion | "Hello World" | "HELLO WORLD" | | `ConvertToLowercase` | ๐Ÿ”ก lowercase conversion | "Hello World" | "hello world" | | `ConvertToTitleCase` | ๐Ÿ†Ž Title Case | "hello world" | "Hello World" | | `ReverseText` | ๐Ÿ” Reverse text | "abcde" | "edcba" | | `Truncate` | โœ‚๏ธ Truncate text | (maxLength=5) "abcdef"| "abcde..." | ### ๐Ÿ”ข Text Counting | Operation | Description | Example Input | Example Output | | ---------------------- | ------------------------ | ------------- | ------------------- | | `CountCharacters` | ๐Ÿ”  Count non-space chars | "Hi!" | 3 | | `CountAlphabets` | ๐Ÿ“ Count letters | "A1b2C" | 3 | | `CountNumbers` | ๐Ÿ”ข Count digits | "A1b2C" | 2 | | `CountAlphanumeric` | ๐Ÿ”ค Letters+digits count | "A1 b2!" | { alph:3, num:2 } | | `CountWords` | ๐Ÿ“ Count words | "Hello world"| 2 | | `CountSentences` | ๐Ÿ“‘ Count sentences | "Hi. Bye?" | 2 | ### ๐Ÿ”ฎ Advanced Analysis Options | Operation | Description | Example Input | Example Output | | ----------------------- | -------------------------------- | ------------------------------------ | ------------------------------- | | `AnalyzeSentiment` | โค๏ธ Sentiment analysis | "I love this!" | { score:1, positive:["love"] }| | `SummarizeText` | โœ‚๏ธ Extractive summary | (3 sentences) long paragraph | (2 sentence summary) | | `CalculateReadability` | ๐Ÿ“– Flesch-Kincaid score | "The quick brown fox jumps..." | { score:70, grade:5 } | | `DetectLanguage` | ๐ŸŒ Language detection | "Bonjour le monde" | "fr" | | `CompareTexts` | ๐Ÿ” Text diff | { text1, text2 } | { added:[...], removed:[...] } | --- ## ๐ŸŽจ Custom Operations _Easily plug in your own workflows! โœจ_ ### โž• Adding Custom Operations You can extend functionality by adding your own custom operations: ```typescript import { Tools } from 'textanalysis-tool'; const analyser = new Tools.Analyser("Sample text for custom operation"); // Add a simple custom operation await analyser.addCustomOperation( "surroundWithAsterisks", // Command name "Surround With Asterisks", // Log name { operation: (text) => `*${text}*`, // Operation function isEnabled: true, // Enable immediately metadata: { decorationType: "asterisks" } // Additional metadata } ); // Run the analysis with the custom operation const result = await analyser.main(); console.log(result.output); // "*Sample text for custom operation*" console.log(result.metadata.custom.surroundWithAsterisks); // { decorationType: "asterisks" } ``` ### ๐Ÿ“Š With Metadata Extraction ```typescript import { Tools } from 'textanalysis-tool'; const analyser = new Tools.Analyser("The code is 12345 and the pin is 6789"); // Add a custom operation with metadata extraction await analyser.addCustomOperation( "extractNumericCodes", "Extract Numeric Codes", { operation: (text) => text, // Operation doesn't change the text isEnabled: true, metadataExtractor: (text) => { const allNumbers = text.match(/\d+/g) || []; return { codes: allNumbers, codeCount: allNumbers.length }; } } ); const result = await analyser.main(); console.log(result.metadata.extractNumericCodes); // Output: { codes: ["12345", "6789"], codeCount: 2 } ``` --- ## ๐Ÿš€ Advanced Usage ### ๐Ÿ”˜ Toggling Operations Enable or disable operations dynamically: ```typescript import { Tools } from 'textanalysis-tool'; const analyser = new Tools.Analyser("Sample text with 123 numbers"); // Enable specific operations await analyser.toggleOperation(Tools.Operations.RemoveNumbers, true); await analyser.toggleOperation(Tools.Operations.CountCharacters, true); // Run analysis let result = await analyser.main(); console.log(result.output); // "Sample text with numbers" // Disable and enable different operations await analyser.toggleOperation(Tools.Operations.RemoveNumbers, false); await analyser.toggleOperation(Tools.Operations.ConvertToUppercase, true); // Run analysis again with new settings result = await analyser.main(); console.log(result.output); // "SAMPLE TEXT WITH 123 NUMBERS" ``` ### ๐Ÿ”€ Managing Multiple Operations ```typescript import { Tools } from 'textanalysis-tool'; const analyser = new Tools.Analyser("Hello, world! 123"); // Enable all available operations await analyser.enableAllOperations(); // Run with all operations let result = await analyser.main(); console.log("With all operations:", result.output); // Disable all operations await analyser.disableAllOperations(); // Enable only specific operations await analyser.toggleOperation(Tools.Operations.RemovePunctuations, true); await analyser.toggleOperation(Tools.Operations.ConvertToUppercase, true); // Run with only selected operations result = await analyser.main(); console.log("With selected operations:", result.output); // "HELLO WORLD 123" ``` ### ๐Ÿ”„ Resetting Text ```typescript import { Tools } from 'textanalysis-tool'; const analyser = new Tools.Analyser("Original text", { [Tools.Operations.ConvertToUppercase]: true }); // Run first analysis let result = await analyser.main(); console.log(result.output); // "ORIGINAL TEXT" // Reset with new text await analyser.resetText("New content"); // Run analysis again result = await analyser.main(); console.log(result.output); // "NEW CONTENT" ``` ### โœ‚๏ธ Truncating Text ```typescript import { Tools } from 'textanalysis-tool'; const longText = "This is a very long text that needs to be truncated to a reasonable length."; const analyser = new Tools.Analyser(longText, { [Tools.Operations.Truncate]: { maxLength: 20, suffix: "..." // Optional, defaults to "..." } }); analyser.main().then(result => { console.log(result.output); // "This is a very long..." }); ``` --- ## ๐Ÿ“˜ API Reference ### ๐Ÿงฐ Tools.Analyser Class The main class for text analysis operations. **Constructor:** ```typescript constructor(raw_text: string, options: AnalyserBuiltInOptions = {}) ``` **Properties:** | Property | Type | Description | |----------|------|-------------| | `raw_text` | string | The input text being analyzed | | `count` | number | The character count | | `alphacount` | number | The alphabetic character count | | `numericcount` | number | The numeric character count | | `wordCount` | number | The word count | | `sentenceCount` | number | The sentence count | | `urls` | string[] | Extracted URLs | | `emails` | string[] | Extracted email addresses | | `phoneNumbers` | string[] | Extracted phone numbers | | `hashtags` | string[] | Extracted hashtags | | `mentions` | string[] | Extracted mentions | | `operations` | string[] | Log of operations performed | | `availableOperations` | Record<string, string> | All available operations | | `options` | AnalyserBuiltInOptions | Current operation options | **Methods:** | Method | Parameters | Return Type | Description | |--------|------------|-------------|-------------| | `main` | None | Promise<AnalyserResult> | Executes all enabled operations | | `addCustomOperation` | commandName: string, logName: string, config: object | Promise<void> | Adds a custom operation | | `toggleOperation` | commandName: string, isEnabled: boolean | Promise<void> | Enables/disables an operation | | `enableAllOperations` | None | Promise<void> | Enables all operations | | `disableAllOperations` | None | Promise<void> | Disables all operations | | `resetText` | newText?: string | Promise<void> | Resets text to original or new value | **Static Methods:** | Method | Parameters | Return Type | Description | |--------|------------|-------------|-------------| | `createWithEnabledOperations` | text: string, operations: (keyof typeof Operations)[] | Analyser | Creates instance with specific operations | | `batch` | texts: string[], options: AnalyserBuiltInOptions | Promise<AnalyserResult[]> | Processes multiple texts with same options | ### ๐Ÿงฉ Tools.Operations Enum Enum of all built-in operations: ```typescript export enum Operations { RemovePunctuations = "removepunc", RemoveNumbers = "removenum", RemoveAlphabets = "removealpha", RemoveSpecialChars = "removespecialchar", RemoveNewlines = "newlineremover", RemoveExtraSpaces = "extraspaceremover", ExtractUrls = "extractUrls", ExtractEmails = "extractEmails", ExtractPhoneNumbers = "extractPhoneNumbers", ExtractHashtags = "extractHashtags", ExtractMentions = "extractMentions", ConvertToUppercase = "fullcaps", ConvertToLowercase = "lowercaps", ConvertToTitleCase = "titlecase", CountCharacters = "charcount", CountAlphabets = "alphacount", CountNumbers = "numcount", CountAlphanumeric = "alphanumericcount", CountWords = "wordcount", CountSentences = "sentencecount", ReverseText = "reversetext", Truncate = "truncate", AnalyzeSentiment = "analyzeSentiment", SummarizeText = "summarizeText", CalculateReadability = "calculateReadability", DetectLanguage = "detectLanguage", CompareTexts = "compareTexts", } ``` ### ๐Ÿ” Tools.ToolsConstant Class Contains regular expression patterns used throughout the library: ```typescript export class ToolsConstant { static readonly regex = { alphabets: /[a-zA-Z]/g, numbers: /\d/g, punctuations: /[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/g, specialCharacters: /[^a-zA-Z0-9\s!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/g, urls: /https?:\/\/\S+/gi, newlines: /^\s*$(?:\r\n?|\n)/gm, extraSpaces: / +/g, character: /[^\s\p{Cf}]/gu, email: /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g, phoneNumber: /(?:\+\d{1,3}[-\s]?)?\(?\d{3}\)?[-\s]?\d{3}[-\s]?\d{4}/g, hashtags: /#[a-zA-Z0-9_]+/g, mentions: /@[a-zA-Z0-9_]+/g }; } ``` ### ๐Ÿ“‹ Interface Types **AnalyserBuiltInOptions:** ```typescript type AnalyserBuiltInOptions = Partial<Record<Operations | string, boolean | any>>; ``` **AnalyserResult:** ```typescript interface AnalyserResult { purpose: string; output: string; metadata: { counts: { characterCount: number; alphabetCount: number; numericCount: number; wordCount?: number; sentenceCount?: number; }; urls?: string[]; emails?: string[]; phoneNumbers?: string[]; hashtags?: string[]; mentions?: string[]; custom?: { [key: string]: any; }; }; operations: string[]; builtInOperations: string[]; customOperations: string[]; executionTime?: number; } ``` **AnalyserResult (Extended):** ```typescript interface AnalyserExtendedResult extends AnalyserResult { sentiment?: SentimentResult; summary?: string; readability?: ReadabilityResult; languageDetection?: LanguageDetectionResult; textComparison?: TextDiffResult; } ``` **TruncateConfig:** ```typescript interface TruncateConfig { maxLength: number; suffix?: string; } ``` ### ๐Ÿ”Œ Extensions ## ๐Ÿ˜Š SentimentAnalyzer A utility class for analyzing text sentiment. **Constructor:** ```typescript constructor() ``` **Properties:** | Property | Type | Description | |----------------|----------------|--------------------------------------| | `positiveWords`| `Set<string>` | The set of positive sentiment words | | `negativeWords`| `Set<string>` | The set of negative sentiment words | **Methods:** | Method | Parameters | Return Type | Description | |--------------------|---------------------------------------------------------|-------------------|--------------------------------------------------| | `analyze` | `text: string` | `SentimentResult` | Executes sentiment analysis on the input text | | `addCustomLexicon` | `lexicon: { positive?: string[]; negative?: string[] }` | `void` | Adds custom positive/negative words to the lexicons | **Static Methods:** _None_ --- ## ๐Ÿ“ TextSummarizer A utility class for generating extractive summaries from text. **Constructor:** ```typescript constructor() ``` **Properties:** | Property | Type | Description | |-------------|----------------|--------------------------------------------------| | `stopWords` | `Set<string>` | The set of stop words to ignore when scoring sentences | **Methods:** | Method | Parameters | Return Type | Description | |----------------------|------------------------------------------|-------------|--------------------------------------------------------| | `extractiveSummarize` | `text: string, sentenceCount?: number` | `string` | Generates an extractive summary with the top sentences | | `addStopWords` | `words: string[]` | `void` | Adds custom words to the stopโ€‘word list | **Static Methods:** _None_ --- ## ๐Ÿ“Š TextStatistics A utility class for computing readability metrics such as the Fleschโ€“Kincaid score. **Constructor:** ```typescript // No constructor parameters; all methods are stateless constructor() ``` **Properties:** _None_ **Methods:** | Method | Parameters | Return Type | Description | |----------------------------|----------------|---------------------|-----------------------------------------------| | `fleschKincaidReadability` | `text: string` | `ReadabilityResult` | Calculates readability and grade level scores | **Static Methods:** _None_ --- ## ๐ŸŒ LanguageDetector A trigramโ€‘based language detection utility supporting English, Spanish, French, and German. **Constructor:** ```typescript constructor() ``` **Properties:** | Property | Type | Description | |--------------------|------------------------------------|--------------------------------------------------| | `languageProfiles` | `Map<string, Map<string, number>>` | Mapping of language names to frequency profiles | **Methods:** | Method | Parameters | Return Type | Description | |----------------------|----------------------------------------------|---------------------------|------------------------------------------------| | `detect` | `text: string` | `LanguageDetectionResult` | Detects the most likely language for the text | | `addCustomLanguage` | `language: string, profile: Record<string, number>` | `void` | Registers a new language profile | **Static Methods:** _None_ --- ## ๐Ÿ” TextDiff A utility class for comparing two texts and computing similarity metrics. **Constructor:** ```typescript // No constructor parameters; all methods are invoked directly constructor() ``` **Properties:** _None_ **Methods:** | Method | Parameters | Return Type | Description | |-----------|--------------------------------|------------------|----------------------------------------------------------| | `compare` | `text1: string, text2: string` | `TextDiffResult` | Computes similarity, edit distance, and common substrings | **Static Methods:** _None_ --- ## ๐Ÿงฉ Interfaces & Types ### ๐Ÿ˜€ SentimentResult ```typescript interface SentimentResult { score: number; positiveWordCount: number; negativeWordCount: number; totalWords: number; classification: SentimentClassification; } ``` ### ๐Ÿท๏ธ SentimentClassification ```typescript type SentimentClassification = "positive" | "negative" | "neutral"; ``` ### ๐Ÿ“– ReadabilityResult ```typescript interface ReadabilityResult { readabilityScore: number; gradeLevel: number; wordCount: number; sentenceCount: number; syllableCount: number; avgWordsPerSentence: number; avgSyllablesPerWord: number; complexity: string; } ``` ### ๐Ÿ—ฃ๏ธ LanguageDetectionResult ```typescript interface LanguageDetectionResult { detectedLanguage: string; confidence: number; scores: Record<string, number>; } ``` ### ๐Ÿ”„ TextDiffResult ```typescript interface TextDiffResult { similarity: number; editDistance: number; commonSubstrings: Array<{ substring: string; length: number }>; wordDifference: { added: string[]; removed: string[]; unchanged: string[]; addedCount: number; removedCount: number; unchangedCount: number; }; } ``` --- ## ๐Ÿค Contributing Love it? Spread the word! ๐ŸŒ 1. Fork the repo ๐Ÿด 2. Create a branch `git checkout -b feature/amazing-feature` ๐ŸŒฟ 3. Commit your changes `git commit -m 'Add some amazing feature'` โœจ 4. Push and create a PR `git push origin feature/amazing-feature` ๐Ÿš€ --- ## ๐Ÿ“ License This project is licensed under the MIT License - see the [LICENSE](https://github.com/abindent/textanalyser/blob/master/LICENSE) file for details.# ๐ŸŒŸ Text Analysis Tools ๐ŸŒŸ