Skip to content

Commit

Permalink
TargetFrameworks changed
Browse files Browse the repository at this point in the history
- TargetFrameworks changed from `netstandard2.0;net461;net47;netcoreapp3.0` to `netstandard2.0;net9.0`.
- PackageReferences updated.
- In SymSpell.Test all Assert.AreEqual changed to Assert.That
  • Loading branch information
wolfgarbe committed Jan 4, 2025
1 parent 2fbee36 commit 2ac2df1
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 60 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ If you like SymSpell, try [**SeekStorm**](https://github.com/SeekStorm/SeekStorm
<br>

```
Copyright (c) 2022 Wolf Garbe
Version: 6.7.2
Copyright (c) 2025 Wolf Garbe
Version: 6.7.3
Author: Wolf Garbe <[email protected]>
Maintainer: Wolf Garbe <[email protected]>
URL: https://github.com/wolfgarbe/symspell
Description: https://seekstorm.com/blog/1000x-spelling-correction/
MIT License
Copyright (c) 2022 Wolf Garbe
Copyright (c) 2025 Wolf Garbe
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
Expand Down Expand Up @@ -489,6 +489,13 @@ https://www.sciencedirect.com/science/article/pii/S2215016124001225
2. Option to preserve case (upper/lower case) of input term.
3. Open source the code for creating custom frequency dictionaries in any language and size as intersection between Google Books Ngram data (Provides representative word frequencies) and SCOWL Spell Checker Oriented Word Lists (Ensures genuine English vocabulary).

#### Changes in v6.7.3

- TargetFrameworks changed from `netstandard2.0;net461;net47;netcoreapp3.0` to `netstandard2.0;net9.0`.
- PackageReferences updated.
- In SymSpell.Test all Assert.AreEqual changed to Assert.That
- Incorporates PR #126 that fixes null reference exception in CommitStaged (#139).

#### Changes in v6.7.2

1. Exception fixed in WordSegmentation
Expand Down
9 changes: 7 additions & 2 deletions SymSpell.Benchmark/SymSpell.Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -15,4 +15,9 @@
<ProjectReference Include="..\SymSpell\SymSpell.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Net.Compilers.Toolset" Version="4.12.0" />
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
</ItemGroup>

</Project>
9 changes: 7 additions & 2 deletions SymSpell.CommandLine/SymSpell.CommandLine.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SymSpell\SymSpell.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Net.Compilers.Toolset" Version="4.12.0" />
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
</ItemGroup>

</Project>
9 changes: 7 additions & 2 deletions SymSpell.CompoundDemo/SymSpell.CompoundDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -15,4 +15,9 @@
<ProjectReference Include="..\SymSpell\SymSpell.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Net.Compilers.Toolset" Version="4.12.0" />
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
</ItemGroup>

</Project>
7 changes: 6 additions & 1 deletion SymSpell.Demo/SymSpell.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -15,4 +15,9 @@
<ProjectReference Include="..\SymSpell\SymSpell.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Net.Compilers.Toolset" Version="4.12.0" />
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
</ItemGroup>

</Project>
9 changes: 7 additions & 2 deletions SymSpell.SegmentationDemo/SymSpell.SegmentationDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -14,5 +14,10 @@
<ItemGroup>
<ProjectReference Include="..\SymSpell\SymSpell.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Net.Compilers.Toolset" Version="4.12.0" />
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
</ItemGroup>

</Project>
68 changes: 34 additions & 34 deletions SymSpell.Test/SymSpell.Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ public void WordsWithSharedPrefixShouldRetainCounts()
symSpell.CreateDictionaryEntry("pipe", 5);
symSpell.CreateDictionaryEntry("pips", 10);
var result = symSpell.Lookup("pipe", SymSpell.Verbosity.All, 1);
Assert.AreEqual(2, result.Count);
Assert.AreEqual("pipe", result[0].term);
Assert.AreEqual(5, result[0].count);
Assert.AreEqual("pips", result[1].term);
Assert.AreEqual(10, result[1].count);
Assert.That(result.Count, Is.EqualTo(2));
Assert.That(result[0].term, Is.EqualTo("pipe"));
Assert.That(result[0].count, Is.EqualTo(5));
Assert.That(result[1].term, Is.EqualTo("pips"));
Assert.That(result[1].count, Is.EqualTo(10));
result = symSpell.Lookup("pips", SymSpell.Verbosity.All, 1);
Assert.AreEqual(2, result.Count);
Assert.AreEqual("pips", result[0].term);
Assert.AreEqual(10, result[0].count);
Assert.AreEqual("pipe", result[1].term);
Assert.AreEqual(5, result[1].count);
Assert.That(result.Count, Is.EqualTo(2));
Assert.That(result[0].term, Is.EqualTo("pips"));
Assert.That(result[0].count, Is.EqualTo(10));
Assert.That(result[1].term, Is.EqualTo("pipe"));
Assert.That(result[1].count, Is.EqualTo(5));
result = symSpell.Lookup("pip", SymSpell.Verbosity.All, 1);
Assert.AreEqual(2, result.Count);
Assert.AreEqual("pips", result[0].term);
Assert.AreEqual(10, result[0].count);
Assert.AreEqual("pipe", result[1].term);
Assert.AreEqual(5, result[1].count);
Assert.That(result.Count, Is.EqualTo(2));
Assert.That(result[0].term, Is.EqualTo("pips"));
Assert.That(result[0].count, Is.EqualTo(10));
Assert.That(result[1].term, Is.EqualTo("pipe"));
Assert.That(result[1].count, Is.EqualTo(5));
}

[Test]
Expand All @@ -39,9 +39,9 @@ public void AddAdditionalCountsShouldNotAddWordAgain()
var symSpell = new SymSpell();
var word = "hello";
symSpell.CreateDictionaryEntry(word, 11);
Assert.AreEqual(1, symSpell.WordCount);
Assert.That(symSpell.WordCount, Is.EqualTo(1));
symSpell.CreateDictionaryEntry(word, 3);
Assert.AreEqual(1, symSpell.WordCount);
Assert.That(symSpell.WordCount, Is.EqualTo(1));
}
[Test]
public void AddAdditionalCountsShouldIncreaseCount()
Expand All @@ -52,12 +52,12 @@ public void AddAdditionalCountsShouldIncreaseCount()
var result = symSpell.Lookup(word, SymSpell.Verbosity.Top);
long count = 0;
if (result.Count == 1) count = result[0].count;
Assert.AreEqual(11, count);
Assert.That(count, Is.EqualTo(11));
symSpell.CreateDictionaryEntry(word, 3);
result = symSpell.Lookup(word, SymSpell.Verbosity.Top);
count = 0;
if (result.Count == 1) count = result[0].count;
Assert.AreEqual(11 + 3, count);
Assert.That(count, Is.EqualTo(11+3));
}
[Test]
public void AddAdditionalCountsShouldNotOverflow()
Expand All @@ -68,12 +68,12 @@ public void AddAdditionalCountsShouldNotOverflow()
var result = symSpell.Lookup(word, SymSpell.Verbosity.Top);
long count = 0;
if (result.Count == 1) count = result[0].count;
Assert.AreEqual(long.MaxValue - 10, count);
Assert.That(count, Is.EqualTo(long.MaxValue - 10));
symSpell.CreateDictionaryEntry(word, 11);
result = symSpell.Lookup(word, SymSpell.Verbosity.Top);
count = 0;
if (result.Count == 1) count = result[0].count;
Assert.AreEqual(long.MaxValue, count);
Assert.That(count, Is.EqualTo(long.MaxValue));
}
[Test]
public void VerbosityShouldControlLookupResults()
Expand All @@ -83,11 +83,11 @@ public void VerbosityShouldControlLookupResults()
symSpell.CreateDictionaryEntry("steams", 2);
symSpell.CreateDictionaryEntry("steem", 3);
var result = symSpell.Lookup("steems", SymSpell.Verbosity.Top, 2);
Assert.AreEqual(1, result.Count);
Assert.That(result.Count, Is.EqualTo(1));
result = symSpell.Lookup("steems", SymSpell.Verbosity.Closest, 2);
Assert.AreEqual(2, result.Count);
Assert.That(result.Count, Is.EqualTo(2));
result = symSpell.Lookup("steems", SymSpell.Verbosity.All, 2);
Assert.AreEqual(3, result.Count);
Assert.That(result.Count, Is.EqualTo(3));
}
[Test]
public void LookupShouldReturnMostFrequent()
Expand All @@ -97,9 +97,9 @@ public void LookupShouldReturnMostFrequent()
symSpell.CreateDictionaryEntry("steamb", 6);
symSpell.CreateDictionaryEntry("steamc", 2);
var result = symSpell.Lookup("steam", SymSpell.Verbosity.Top, 2);
Assert.AreEqual(1, result.Count);
Assert.AreEqual("steamb", result[0].term);
Assert.AreEqual(6, result[0].count);
Assert.That(result.Count, Is.EqualTo(1));
Assert.That(result[0].term, Is.EqualTo("steamb"));
Assert.That(result[0].count, Is.EqualTo(6));
}
[Test]
public void LookupShouldFindExactMatch()
Expand All @@ -109,26 +109,26 @@ public void LookupShouldFindExactMatch()
symSpell.CreateDictionaryEntry("steamb", 6);
symSpell.CreateDictionaryEntry("steamc", 2);
var result = symSpell.Lookup("steama", SymSpell.Verbosity.Top, 2);
Assert.AreEqual(1, result.Count);
Assert.AreEqual("steama", result[0].term);
Assert.That(result.Count, Is.EqualTo(1));
Assert.That(result[0].term, Is.EqualTo("steama"));
}
[Test]
public void LookupShouldNotReturnNonWordDelete()
{
var symSpell = new SymSpell(16, 2, 7, 10);
symSpell.CreateDictionaryEntry("pawn", 10);
var result = symSpell.Lookup("paw", SymSpell.Verbosity.Top, 0);
Assert.AreEqual(0, result.Count);
Assert.That(result.Count, Is.EqualTo(0));
result = symSpell.Lookup("awn", SymSpell.Verbosity.Top, 0);
Assert.AreEqual(0, result.Count);
Assert.That(result.Count, Is.EqualTo(0));
}
[Test]
public void LookupShouldNotReturnLowCountWord()
{
var symSpell = new SymSpell(16, 2, 7, 10);
symSpell.CreateDictionaryEntry("pawn", 1);
var result = symSpell.Lookup("pawn", SymSpell.Verbosity.Top, 0);
Assert.AreEqual(0, result.Count);
Assert.That(result.Count, Is.EqualTo(0));
}
[Test]
public void LookupShouldNotReturnLowCountWordThatsAlsoDeleteWord()
Expand All @@ -137,7 +137,7 @@ public void LookupShouldNotReturnLowCountWordThatsAlsoDeleteWord()
symSpell.CreateDictionaryEntry("flame", 20);
symSpell.CreateDictionaryEntry("flam", 1);
var result = symSpell.Lookup("flam", SymSpell.Verbosity.Top, 0);
Assert.AreEqual(0, result.Count);
Assert.That(result.Count, Is.EqualTo(0));
}
//[Test]
//public void DeleteInSuggestionPrefixEdgeCases()
Expand Down Expand Up @@ -194,7 +194,7 @@ public void LookupShouldReplicateNoisyResults()
{
resultSum += symSpell.Lookup(testList[i], verbosity, symSpell.MaxDictionaryEditDistance ).Count;
}
Assert.AreEqual( 4955 , resultSum);
Assert.That(resultSum, Is.EqualTo(4955));
}
}
}
14 changes: 10 additions & 4 deletions SymSpell.Test/SymSpell.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp3.0;</TargetFrameworks>
<LangVersion>preview</LangVersion>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>symspellTest</RootNamespace>
<AssemblyName>symspellTest</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SymSpell\SymSpell.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Net.Compilers.Toolset" Version="4.12.0" />
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
</ItemGroup>

</Project>
13 changes: 6 additions & 7 deletions SymSpell/SymSpell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
// 2. mistakenly omitted space between two correct words led to one incorrect combined term
// 3. multiple independent input terms with/without spelling errors

// Copyright (C) 2022 Wolf Garbe
// Version: 6.7.2
// Copyright (C) 2025 Wolf Garbe
// Version: 6.7.3
// Author: Wolf Garbe [email protected]
// Maintainer: Wolf Garbe [email protected]
// URL: https://github.com/wolfgarbe/symspell
// Description: https://seekstorm.com/blog/1000x-spelling-correction/
//
// MIT License
// Copyright (c) 2022 Wolf Garbe
// Copyright (c) 2025 Wolf Garbe
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
Expand Down Expand Up @@ -224,9 +224,9 @@ public bool CreateDictionaryEntry(string key, Int64 count, SuggestionStage stagi
//even if the same term existed before in the dictionary as an edit from another word
if (key.Length > maxDictionaryWordLength) maxDictionaryWordLength = key.Length;

if (deletes == null) this.deletes = new Dictionary<int, string[]>(initialCapacity); //initialisierung
if (deletes == null) deletes = new Dictionary<int, string[]>(initialCapacity); //initialisierung

//create deletes
//create deletes
var edits = EditsPrefix(key);
// if not staging suggestions, put directly into main data structure
if (staging != null)
Expand Down Expand Up @@ -353,7 +353,6 @@ public bool LoadDictionary(Stream corpusStream, int termIndex, int countIndex, c
}
}
}
if (this.deletes == null) this.deletes = new Dictionary<int, string[]>(staging.DeleteCount);
CommitStaged(staging);
return true;
}
Expand Down Expand Up @@ -390,7 +389,6 @@ public bool CreateDictionary(Stream corpusStream)
}
}
}
if (this.deletes == null) this.deletes = new Dictionary<int, string[]>(staging.DeleteCount);
CommitStaged(staging);
return true;
}
Expand All @@ -410,6 +408,7 @@ public void PurgeBelowThresholdWords()
/// <param name="staging">The SuggestionStage object storing the staged data.</param>
public void CommitStaged(SuggestionStage staging)
{
if (deletes == null) deletes = new Dictionary<int, string[]>(staging.DeleteCount);
staging.CommitTo(deletes);
}

Expand Down
Loading

0 comments on commit 2ac2df1

Please sign in to comment.