-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgate_engine.py
More file actions
43 lines (33 loc) · 1.07 KB
/
gate_engine.py
File metadata and controls
43 lines (33 loc) · 1.07 KB
1
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
class WordGateEngine:
def __init__(self, index):
self.index = index
self.blacklist = {"the", "and", "is", "a"} # example
# --- SIGNALS ---
def is_in_index(self, word):
return word.lower() in self.index
def is_blacklisted(self, word):
return word.lower() in self.blacklist
def is_long_enough(self, word):
return len(word) > 2
def is_high_signal(self, word):
# simple proxy heuristic
return word[0].isalpha() and word.lower() not in self.blacklist
# --- LOGIC GATES ---
def AND(self, *signals):
return all(signals)
def OR(self, *signals):
return any(signals)
def NOT(self, signal):
return not signal
# --- DECISION CIRCUIT ---
def allow_word(self, word):
a = self.is_in_index(word)
b = self.is_blacklisted(word)
c = self.is_long_enough(word)
d = self.is_high_signal(word)
# CIRCUIT DESIGN
decision = self.OR(
self.AND(a, c),
self.AND(d, self.NOT(b))
)
return decision