Skip to content

Commit f3073e8

Browse files
committed
Merge branch 'feature/netstandard2' into develop
2 parents 17ce434 + 784d403 commit f3073e8

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,34 @@ This algorithm is usually used for optical character recognition (OCR) applicati
141141

142142
It can also be used for keyboard typing auto-correction. Here the cost of substituting E and R is lower for example because these are located next to each other on an AZERTY or QWERTY keyboard. Hence the probability that the user mistyped the characters is higher.
143143

144-
<!-- TODO.JB - port Java example code -->
144+
```cs
145+
using System;
146+
using F23.StringSimilarity;
147+
148+
public class Program
149+
{
150+
public static void Main(string[] args)
151+
{
152+
var l = new WeightedLevenshtein(new ExampleCharSub());
153+
154+
Console.WriteLine(l.Distance("String1", "String1"));
155+
Console.WriteLine(l.Distance("String1", "Srring1"));
156+
Console.WriteLine(l.Distance("String1", "Srring2"));
157+
}
158+
}
159+
160+
private class ExampleCharSub : ICharacterSubstitution
161+
{
162+
public double Cost(char c1, char c2)
163+
{
164+
// The cost for substituting 't' and 'r' is considered smaller as these 2 are located next to each other on a keyboard
165+
if (c1 == 't' && c2 == 'r') return 0.5;
166+
167+
// For most cases, the cost of substituting 2 characters is 1.0
168+
return 1.0;
169+
}
170+
}
171+
```
145172

146173
## Damerau-Levenshtein
147174
Similar to Levenshtein, Damerau-Levenshtein distance with transposition (also sometimes calls unrestricted Damerau-Levenshtein distance) is the minimum number of operations needed to transform one string into the other, where an operation is defined as an insertion, deletion, or substitution of a single character, or a **transposition of two adjacent characters**.

src/F23.StringSimilarity/F23.StringSimilarity.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard1.0</TargetFramework>
4+
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
55
<PackageId>F23.StringSimilarity</PackageId>
6-
<PackageVersion>3.1.0</PackageVersion>
6+
<PackageVersion>3.2.0</PackageVersion>
7+
<PackageTags>string;similarity;distance;levenshtein;jaro-winkler;lcs;cosine</PackageTags>
78
<Title>StringSimilarity.NET</Title>
89
<Authors>James Blair, Paul Irwin</Authors>
910
<Copyright>Copyright 2018 feature[23]</Copyright>
@@ -17,7 +18,7 @@
1718
</PropertyGroup>
1819

1920
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
20-
<DocumentationFile>bin\Release\netstandard1.0\F23.StringSimilarity.xml</DocumentationFile>
21+
<DocumentationFile>bin\Release\netstandard2.0\F23.StringSimilarity.xml</DocumentationFile>
2122
</PropertyGroup>
2223

2324
</Project>

test/F23.StringSimilarity.Tests/F23.StringSimilarity.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>

0 commit comments

Comments
 (0)