Skip to content

Commit

Permalink
Update seperation chars, move to containedWords
Browse files Browse the repository at this point in the history
  • Loading branch information
hhvrc authored Sep 13, 2024
1 parent 9924553 commit df3f178
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions DiscordBot/Utils/ProfanityDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public static class ProfanityDetector
{ "shit", 0.3f },
{ "slut", 0.6f },
{ "fuck", 0.3f },
{ "wtf", 0.15f },
{ "omfg", 0.15f },
{ "i use arch b", 0.9f }
};

Expand All @@ -31,7 +33,6 @@ public static class ProfanityDetector
{ "micropython", 0.5f },
{ "piss", 0.3f },
{ "ass", 0.2f },
{ "wtf", 0.15f },
};

private static float CalculateWeight(float accumulated, float weight) => accumulated == 0 ? weight : MathF.Max(accumulated, weight) + 0.1f;
Expand All @@ -55,7 +56,7 @@ private static void GetContainedWordsCountAndWeight(ReadOnlySpan<char> lowerCase
}

private readonly record struct WordRange(int Start, int End);
private static readonly SearchValues<char> _seperationValues = SearchValues.Create([' ', '\t', '\r', '\n', '?', '!', ',', '.', '(', ')']);
private static readonly SearchValues<char> _seperationValues = SearchValues.Create([' ', '\t', '\r', '\n', '?', '!', ',', '.', '(', ')', '"']);
private static List<WordRange> GetWordRanges(ReadOnlySpan<char> span)
{
List<WordRange> wordRanges = [];
Expand Down

0 comments on commit df3f178

Please sign in to comment.