Rule Based
RuleBasedFilter
Source code in engines/contentFilterEngine/other_approaches/rule_based.py
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
__init__(rules=None)
Initializes the RuleBasedFilter with a set of rules.
- rules (list of dict): A list where each rule is a dictionary containing 'keyword' and 'action' keys.
Source code in engines/contentFilterEngine/other_approaches/rule_based.py
3 4 5 6 7 8 9 10 11 12 13 14 |
|
add_rule(keyword, action)
Adds a new rule to the filter.
Parameters: - keyword (str): The keyword to look for in the content. - action (str): The action to take ('block', 'flag', etc.).
Source code in engines/contentFilterEngine/other_approaches/rule_based.py
16 17 18 19 20 21 22 23 24 25 |
|
filter_content(content)
Filters the content based on the predefined rules.
Parameters: - content (str): The content to be filtered.
Returns: - dict: A dictionary with 'status' and 'actions' applied.
Source code in engines/contentFilterEngine/other_approaches/rule_based.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|