Skip to content

Commit b1b6399

Browse files
committed
Merge branch 'release/4.0.0'
2 parents 17ce434 + f9c152c commit b1b6399

File tree

4 files changed

+46
-7
lines changed

4 files changed

+46
-7
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**.
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
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>4.0.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>
1011
<Description>A .NET port of java-string-similarity.</Description>
1112
<Summary>A .NET port of java-string-similarity (https://github.com/tdebatty/java-string-similarity). A library implementing different string similarity and distance measures. Several algorithms (including Levenshtein edit distance and sibblings, Jaro-Winkler, Longest Common Subsequence, cosine similarity etc.) are currently implemented.</Summary>
1213
<PackageProjectUrl>https://github.com/feature23/StringSimilarity.NET</PackageProjectUrl>
13-
<PackageLicenseUrl>https://raw.githubusercontent.com/feature23/StringSimilarity.NET/master/LICENSE</PackageLicenseUrl>
14-
<PackageIconUrl>https://raw.githubusercontent.com/feature23/StringSimilarity.NET/master/logo.png</PackageIconUrl>
14+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
15+
<PackageIcon>logo.png</PackageIcon>
1516
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1617
<PackageTags>string similarity distance cosine damerau jaccard jaro-winkler levenshtein ngram qgram shingle sift4</PackageTags>
18+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
19+
<IncludeSymbols>true</IncludeSymbols>
20+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1721
</PropertyGroup>
1822

23+
<ItemGroup>
24+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
25+
</ItemGroup>
26+
27+
<ItemGroup>
28+
<None Include="logo.png" Pack="true" PackagePath="\" />
29+
</ItemGroup>
30+
1931
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
20-
<DocumentationFile>bin\Release\netstandard1.0\F23.StringSimilarity.xml</DocumentationFile>
32+
<DocumentationFile>bin\Release\netstandard2.0\F23.StringSimilarity.xml</DocumentationFile>
2133
</PropertyGroup>
2234

2335
</Project>
File renamed without changes.

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)