BogaNet 1.4.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Static Protected Attributes | Properties | Events | List of all members
BogaNet.BWF.Filter.BadWordFilter Class Reference

Filter to remove bad words aka profanity. More...

Inheritance diagram for BogaNet.BWF.Filter.BadWordFilter:
BogaNet.Util.Singleton< BadWordFilter > BogaNet.BWF.Filter.IBadWordFilter BogaNet.BWF.Filter.ISourceFilter BogaNet.BWF.Filter.IFilter

Public Member Functions

virtual bool Remove (string srcName)
 Removes a source and assigned data.
 
virtual bool ContainsSource (string srcName)
 Checks if a given source name exists in the filter.
 
virtual void Clear ()
 Clears all sources.
 
virtual void Load (bool isLTR, Dictionary< string, string[]> dataDict)
 Load sources from a given Dictionary.
 
virtual bool LoadFiles (bool isLTR, params Tuple< string, string >[] files)
 Load source files (CSV) from a given path.
 
virtual async Task< bool > LoadFilesAsync (bool isLTR, params Tuple< string, string >[] files)
 Load source files (CSV) from a given path asynchronously.
 
virtual bool LoadFilesFromUrl (bool isLTR, params Tuple< string, string >[] urls)
 Load source files (CSV) from given URLs.
 
virtual async Task< bool > LoadFilesFromUrlAsync (bool isLTR, params Tuple< string, string >[] urls)
 Load source files (CSV) from given URLs asynchronously.
 
virtual void Add (bool isLTR, string srcName, string[] words)
 
virtual bool Contains (string text, params string[]? sourceNames)
 Searches for bad words in a text.
 
virtual List< string > GetAll (string text, params string[]? sourceNames)
 Searches for bad words in a text.
 
virtual string ReplaceAll (string text, params string[]? sourceNames)
 Searches and replaces all bad words in a text.
 
- Public Member Functions inherited from BogaNet.BWF.Filter.IBadWordFilter
void Add (bool isLTR, string srcName, params string[] words)
 Adds a source with words.
 
- Public Member Functions inherited from BogaNet.BWF.Filter.ISourceFilter
delegate void FilesLoaded (params Tuple< string, string >[] files)
 Delegate for the load status of the files.
 

Protected Member Functions

string replaceText (string input)
 

Static Protected Member Functions

static void logFilterNotReady ()
 
static void logSourceNotFound (string res)
 

Static Protected Attributes

const string EXACT_REGEX_START = @"(?<![\w\d])"
 
const string EXACT_REGEX_END = @"s?(?![\w\d])"
 
const RegexOptions REGEX_IC = RegexOptions.IgnoreCase
 
const RegexOptions REGEX_CI = RegexOptions.CultureInvariant
 
const RegexOptions REGEX_COMPILED = RegexOptions.Compiled
 
const RegexOptions REGEX_RTL = RegexOptions.RightToLeft
 
const RegexOptions REGEX_NONE = RegexOptions.None
 

Properties

virtual int Count [get]
 Current count of sources from the filter.
 
virtual List< string > SourceNames [get]
 All source names of the current filter.
 
virtual bool IsLoaded [get]
 Is the filter loaded?
 
virtual char[] ReplaceCharacters = ['*'] [get, set]
 Replace characters for bad words.
 
virtual ReplaceMode Mode = ReplaceMode.Default [get, set]
 Replace mode operations on the input string.
 
virtual bool RemoveSpaces [get, set]
 Remove unnecessary spaces between letters in the input string.
 
virtual int MaxTextLength = 3 [get, set]
 Maximal text length for the space detection.
 
virtual string RemoveCharacters = string.Empty [get, set]
 Remove unnecessary characters from the input string.
 
virtual bool SimpleCheck [get, set]
 Use simple detection algorithm (e.g. for Chinese, Japanese, Korean, Thai etc.).
 
- Properties inherited from BogaNet.Util.Singleton< BadWordFilter >
static T Instance [get]
 
- Properties inherited from BogaNet.BWF.Filter.IBadWordFilter
- Properties inherited from BogaNet.BWF.Filter.ISourceFilter

Events

ISourceFilter.? FilesLoaded OnFilesLoaded
 
- Events inherited from BogaNet.BWF.Filter.ISourceFilter
FilesLoaded OnFilesLoaded
 Event triggered whenever the files are loaded.
 

Detailed Description

Filter to remove bad words aka profanity.

Member Function Documentation

◆ Add()

virtual void BogaNet.BWF.Filter.BadWordFilter.Add ( bool isLTR,
string srcName,
string[] words )
virtual

◆ Clear()

virtual void BogaNet.BWF.Filter.BadWordFilter.Clear ( )
virtual

Clears all sources.

Implements BogaNet.BWF.Filter.ISourceFilter.

◆ Contains()

virtual bool BogaNet.BWF.Filter.BadWordFilter.Contains ( string text,
params string?[] sourceNames )
virtual

Searches for bad words in a text.

Parameters
textText to check
sourceNamesRelevant sources (e.g. "english", optional)
Returns
True if a match was found

Implements BogaNet.BWF.Filter.IFilter.

◆ ContainsSource()

virtual bool BogaNet.BWF.Filter.BadWordFilter.ContainsSource ( string srcName)
virtual

Checks if a given source name exists in the filter.

Parameters
srcNameSource name to check
Returns
True if the key exists in the filter
Exceptions
ArgumentNullException

Implements BogaNet.BWF.Filter.ISourceFilter.

◆ GetAll()

virtual List< string > BogaNet.BWF.Filter.BadWordFilter.GetAll ( string text,
params string?[] sourceNames )
virtual

Searches for bad words in a text.

Parameters
textText to check
sourceNamesRelevant sources (e.g. "english", optional)
Returns
List with all the matches

Implements BogaNet.BWF.Filter.IFilter.

◆ Load()

virtual void BogaNet.BWF.Filter.BadWordFilter.Load ( bool isLTR,
Dictionary< string, string[]> dataDict )
virtual

Load sources from a given Dictionary.

Parameters
isLTRIs source written left-to-right?
dataDictDictionary to load

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.BWF.Filter.IBadWordFilter.

◆ LoadFiles()

virtual bool BogaNet.BWF.Filter.BadWordFilter.LoadFiles ( bool isLTR,
params Tuple< string, string >[] files )
virtual

Load source files (CSV) from a given path.

Parameters
isLTRIs source written left-to-right?
filesFiles to load (Item1 = source name, Item2 = file)

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.BWF.Filter.IBadWordFilter.

◆ LoadFilesAsync()

virtual async Task< bool > BogaNet.BWF.Filter.BadWordFilter.LoadFilesAsync ( bool isLTR,
params Tuple< string, string >[] files )
virtual

Load source files (CSV) from a given path asynchronously.

Parameters
isLTRIs source written left-to-right?
filesFiles to load (Item1 = source name, Item2 = file)

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.BWF.Filter.IBadWordFilter.

◆ LoadFilesFromUrl()

virtual bool BogaNet.BWF.Filter.BadWordFilter.LoadFilesFromUrl ( bool isLTR,
params Tuple< string, string >[] urls )
virtual

Load source files (CSV) from given URLs.

Parameters
isLTRIs source written left-to-right?
urlsURLs of files to load (Item1 = source name, Item2 = file)

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.BWF.Filter.IBadWordFilter.

◆ LoadFilesFromUrlAsync()

virtual async Task< bool > BogaNet.BWF.Filter.BadWordFilter.LoadFilesFromUrlAsync ( bool isLTR,
params Tuple< string, string >[] urls )
virtual

Load source files (CSV) from given URLs asynchronously.

Parameters
isLTRIs source written left-to-right?
urlsURLs of files to load (Item1 = source name, Item2 = file)

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.BWF.Filter.IBadWordFilter.

◆ logFilterNotReady()

static void BogaNet.BWF.Filter.BadWordFilter.logFilterNotReady ( )
staticprotected

◆ logSourceNotFound()

static void BogaNet.BWF.Filter.BadWordFilter.logSourceNotFound ( string res)
staticprotected

◆ Remove()

virtual bool BogaNet.BWF.Filter.BadWordFilter.Remove ( string srcName)
virtual

Removes a source and assigned data.

Parameters
srcNameSource name to remove

returns>True if the operation was successful

Exceptions
ArgumentNullException

Implements BogaNet.BWF.Filter.ISourceFilter.

◆ ReplaceAll()

virtual string BogaNet.BWF.Filter.BadWordFilter.ReplaceAll ( string text,
params string?[] sourceNames )
virtual

Searches and replaces all bad words in a text.

Parameters
textText to check
sourceNamesRelevant sources (e.g. "english", optional)
Returns
Clean text

Implements BogaNet.BWF.Filter.IFilter.

◆ replaceText()

string BogaNet.BWF.Filter.BadWordFilter.replaceText ( string input)
protected

Member Data Documentation

◆ EXACT_REGEX_END

const string BogaNet.BWF.Filter.BadWordFilter.EXACT_REGEX_END = @"s?(?![\w\d])"
staticprotected

◆ EXACT_REGEX_START

const string BogaNet.BWF.Filter.BadWordFilter.EXACT_REGEX_START = @"(?<![\w\d])"
staticprotected

◆ REGEX_CI

const RegexOptions BogaNet.BWF.Filter.BadWordFilter.REGEX_CI = RegexOptions.CultureInvariant
staticprotected

◆ REGEX_COMPILED

const RegexOptions BogaNet.BWF.Filter.BadWordFilter.REGEX_COMPILED = RegexOptions.Compiled
staticprotected

◆ REGEX_IC

const RegexOptions BogaNet.BWF.Filter.BadWordFilter.REGEX_IC = RegexOptions.IgnoreCase
staticprotected

◆ REGEX_NONE

const RegexOptions BogaNet.BWF.Filter.BadWordFilter.REGEX_NONE = RegexOptions.None
staticprotected

◆ REGEX_RTL

const RegexOptions BogaNet.BWF.Filter.BadWordFilter.REGEX_RTL = RegexOptions.RightToLeft
staticprotected

Property Documentation

◆ Count

virtual int BogaNet.BWF.Filter.BadWordFilter.Count
get

Current count of sources from the filter.

Implements BogaNet.BWF.Filter.ISourceFilter.

◆ IsLoaded

virtual bool BogaNet.BWF.Filter.BadWordFilter.IsLoaded
get

Is the filter loaded?

Implements BogaNet.BWF.Filter.ISourceFilter.

◆ MaxTextLength

virtual int BogaNet.BWF.Filter.BadWordFilter.MaxTextLength = 3
getset

Maximal text length for the space detection.

Implements BogaNet.BWF.Filter.IBadWordFilter.

◆ Mode

virtual ReplaceMode BogaNet.BWF.Filter.BadWordFilter.Mode = ReplaceMode.Default
getset

Replace mode operations on the input string.

Implements BogaNet.BWF.Filter.IBadWordFilter.

◆ RemoveCharacters

virtual string BogaNet.BWF.Filter.BadWordFilter.RemoveCharacters = string.Empty
getset

Remove unnecessary characters from the input string.

Implements BogaNet.BWF.Filter.IBadWordFilter.

◆ RemoveSpaces

virtual bool BogaNet.BWF.Filter.BadWordFilter.RemoveSpaces
getset

Remove unnecessary spaces between letters in the input string.

Implements BogaNet.BWF.Filter.IBadWordFilter.

◆ ReplaceCharacters

virtual char [] BogaNet.BWF.Filter.BadWordFilter.ReplaceCharacters = ['*']
getset

Replace characters for bad words.

Implements BogaNet.BWF.Filter.IBadWordFilter.

◆ SimpleCheck

virtual bool BogaNet.BWF.Filter.BadWordFilter.SimpleCheck
getset

Use simple detection algorithm (e.g. for Chinese, Japanese, Korean, Thai etc.).

Implements BogaNet.BWF.Filter.IBadWordFilter.

◆ SourceNames

virtual List<string> BogaNet.BWF.Filter.BadWordFilter.SourceNames
get

All source names of the current filter.

Returns
List with all source names of the current filter

Implements BogaNet.BWF.Filter.ISourceFilter.

Event Documentation

◆ OnFilesLoaded

ISourceFilter.? FilesLoaded BogaNet.BWF.Filter.BadWordFilter.OnFilesLoaded

The documentation for this class was generated from the following file: