U
    ˱}j                     @   s   d dl mZ dd ZdS )   )get_dbc                  G   s   t  }| }z |d dd | D }W 5 |  X |sBdS | D ]<}|sPqFt| }|D ] }| |kr`d|f    S q`qFdS )uu   
    检查文本中是否包含敏感词
    返回 (found, word) - found为True时word为匹配到的敏感词
    z SELECT word FROM sensitive_wordsc                 S   s   g | ]}|d  qS )word ).0rowr   r   DD:\Project\Python Project\BangBang\backend\utils\sensitive_filter.py
<listcomp>   s     z)check_sensitive_words.<locals>.<listcomp>)FNT)r   cursorcloseexecutefetchallstrlower)Ztextsconnr	   wordstextZ
text_lowerr   r   r   r   check_sensitive_words   s     

r   N)databaser   r   r   r   r   r   <module>   s   