-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves #35 for comparison using byte[], or any scenarios where i.e. ReadOnlySpan might be preferred.
- Loading branch information
Showing
22 changed files
with
313 additions
and
142 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 |
---|---|---|
|
@@ -243,3 +243,4 @@ ModelManifest.xml | |
# FAKE - F# Make | ||
.fake/ | ||
*.DS_Store | ||
.idea/ |
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
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
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
23 changes: 23 additions & 0 deletions
23
src/F23.StringSimilarity/Interfaces/IMetricSpanDistance.cs
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,23 @@ | ||
using System; | ||
|
||
namespace F23.StringSimilarity.Interfaces | ||
{ | ||
/// <summary> | ||
/// Span distances that implement this interface are metrics, which means: | ||
/// - d(x, y) ≥ 0 (non-negativity, or separation axiom) | ||
/// - d(x, y) = 0 if and only if x = y (identity, or coincidence axiom) | ||
/// - d(x, y) = d(y, x) (symmetry) | ||
/// - d(x, z) ≤ d(x, y) + d(y, z) (triangle inequality). | ||
/// </summary> | ||
public interface IMetricSpanDistance : ISpanDistance | ||
{ | ||
/// <summary> | ||
/// Compute and return the metric distance. | ||
/// </summary> | ||
/// <param name="b1">The first span.</param> | ||
/// <param name="b2">The second span.</param> | ||
/// <returns>The metric distance.</returns> | ||
new double Distance<T>(ReadOnlySpan<T> b1, ReadOnlySpan<T> b2) | ||
where T : IEquatable<T>; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/F23.StringSimilarity/Interfaces/INormalizedSpanDistance.cs
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,6 @@ | ||
namespace F23.StringSimilarity.Interfaces | ||
{ | ||
public interface INormalizedSpanDistance : ISpanDistance | ||
{ | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/F23.StringSimilarity/Interfaces/INormalizedSpanSimilarity.cs
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,6 @@ | ||
namespace F23.StringSimilarity.Interfaces | ||
{ | ||
public interface INormalizedSpanSimilarity : ISpanSimilarity | ||
{ | ||
} | ||
} |
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,23 @@ | ||
using System; | ||
|
||
namespace F23.StringSimilarity.Interfaces | ||
{ | ||
public interface ISpanDistance | ||
{ | ||
/// <summary> | ||
/// Compute and return a measure of distance. | ||
/// Must be >= 0. | ||
/// | ||
/// This method operates on spans such as byte arrays. | ||
/// Note that, when used on bytes, string encodings that | ||
/// use more than one byte per codepoint (such as UTF-8) | ||
/// are not supported and will most likely return | ||
/// incorrect results. | ||
/// </summary> | ||
/// <param name="b1">The first span.</param> | ||
/// <param name="b2">The second span.</param> | ||
/// <returns>The measure of distance between the spans.</returns> | ||
double Distance<T>(ReadOnlySpan<T> b1, ReadOnlySpan<T> b2) | ||
where T : IEquatable<T>; | ||
} | ||
} |
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,16 @@ | ||
using System; | ||
|
||
namespace F23.StringSimilarity.Interfaces | ||
{ | ||
public interface ISpanSimilarity | ||
{ | ||
/// <summary> | ||
/// Compute and return a measure of similarity between 2 spans. | ||
/// </summary> | ||
/// <param name="s1">The first span</param> | ||
/// <param name="s2">The second span</param> | ||
/// <returns>Similarity (0 means both spans are completely different)</returns> | ||
double Similarity<T>(ReadOnlySpan<T> s1, ReadOnlySpan<T> s2) | ||
where T : IEquatable<T>; | ||
} | ||
} |
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
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
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
Oops, something went wrong.