Hi,
I’m creating a class to detect and filter profane words. I’m using this library : [url]https://github.com/areebbeigh/profanityfilter[/url]
In my class I’m calling a function in another Thread. I’m using a timer to check the data before adding it to a tableDAT. The method is explained here : [url]Wisdom about python threads? - #4 by hypnokevin]
The problem is: when I try to initialize the profanityfilter library in the threaded function, I get this error :
Exception in thread Thread-27:
Traceback (most recent call last):
File "C:\Program Files\Derivative\TouchDesigner099\bin\lib\threading.py", line 914, in _bootstrap_inner
self.run()
File "C:\Program Files\Derivative\TouchDesigner099\bin\lib\threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/project1/profanity_filter/Profanity_filter", line 29, in analyze
TypeError: __init__() missing 1 required positional argument: 'owner'
Here’s my code :
[code]from threading import Thread, Lock
from profanityfilter import ProfanityFilter
class ProfanityFilter:
def init(self,owner):
self.text = None
self.lock = Lock()
self.pollTimer = op(‘polltimer’)
self.profanityFree = op(‘profanity_free_table’)
#@Desc : Called by a timer to see if the thread is done doing is job
def Poll(self):
text = None
with self.lock:
text = self.text
if text is not None:
if text is not False:
self.profanityFree.appendRow(text)
self.text = None
def Check(self,txt):
self.pollTimer.par.start.pulse()
process = Thread(target=self.analyze, args=(txt,))
process.daemon = True
process.start()
def analyze(self,txt):
pf = ProfanityFilter()
if pf.is_profane(txt):
self.text = False
print('CENSORED : ', txt)
else:
self.text = txt[/code]
Any ideas ?
Thanks !