-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb4aea5
commit 6e23a5f
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# NgramSimilarity Class | ||
|
||
**Static class providing extension methods for calculating the N-gram similarity between two strings.** | ||
|
||
## Class Members | ||
|
||
```csharp | ||
CalculateNgramSimilarity( | ||
string text1, | ||
string text2, | ||
int n = 2) | ||
``` | ||
|
||
Calculates the N-gram similarity between two strings. | ||
|
||
### Parameters | ||
|
||
- `text1` (Type: `string`): The first string for comparison. | ||
- `text2` (Type: `string`): The second string for comparison. | ||
- `n` (Type: `int`): The size of N-grams to be used (default is 2). | ||
|
||
### Returns | ||
|
||
- Type: `double` | ||
- Description: A double value representing the N-gram similarity between the two strings, ranging from 0.0 to 1.0. | ||
|
||
### Example | ||
|
||
```csharp | ||
using NetPlus.Algorithms.Comparison; | ||
|
||
// Example strings | ||
string text1 = "Hello World"; | ||
string text2 = "Hello"; | ||
|
||
// Calculating N-gram similarity | ||
double similarity = text1.CalculateNgramSimilarity(text2); | ||
|
||
// Displaying similarity | ||
Console.WriteLine(similarity); | ||
``` | ||
|
||
### Usage | ||
|
||
To use the `NgramSimilarity` class, simply call the `CalculateNgramSimilarity` method with the appropriate parameters. | ||
|
||
```csharp | ||
// Example usage | ||
double similarity = text1.CalculateNgramSimilarity(text2); | ||
``` | ||
|
||
### Remarks | ||
|
||
The `NgramSimilarity` class uses the N-gram similarity algorithm to calculate the similarity between two strings. It returns a double value representing the similarity between the two strings, ranging from 0.0 to 1.0. |