Skip to content

Commit

Permalink
Added more logging to try and see what the issue is
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist committed Jan 23, 2024
1 parent fd912f4 commit 08592b2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/ProfanityFilter.Services/DefaultProfaneContentCensorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ private static async Task<FrozenSet<string>> ReadAllProfaneWordsAsync()
{
var fileNames = ProfaneContentReader.GetFileNames();

Console.WriteLine("Source word list for profane content:");
foreach (var fileName in fileNames)
{
Console.WriteLine(fileName);
}

ConcurrentBag<string> allWords = [];

await Parallel.ForEachAsync(fileNames,
Expand All @@ -41,7 +47,7 @@ await Parallel.ForEachAsync(fileNames,
})
.ConfigureAwait(false);

var set = allWords.ToHashSet();
var set = allWords.ToFrozenSet();

return set.ToFrozenSet();
}
Expand Down Expand Up @@ -94,13 +100,18 @@ async ValueTask<string> IProfaneContentCensorService.CensorProfanityAsync(string

private static async ValueTask<string?> GetProfaneWordListRegexPatternAsync()
{
var wordSet = await s_getProfaneWords.Task;
var wordSet =
await s_getProfaneWords.Task.ConfigureAwait(false);

if (wordSet.Count is 0)
{
Console.WriteLine("Unable to read profane word lists.");
return null;
}
else
{
Console.WriteLine($"Found {wordSet.Count:#,#} profane source words.");
}

var pattern = $"\\b({string.Join('|', wordSet)})\\b";

Expand Down

0 comments on commit 08592b2

Please sign in to comment.