コード例 #1
0
ファイル: tasks.py プロジェクト: DerekRies/fjord
def classify(response, flag):
    """Run response.description through classifier"""
    try:
        score = get_spicedham().classify(tokenize(response.description))
        if score > ABUSE_CUTOFF:
            return True
    except (ZeroDivisionError, TypeError):
        # If there isn't any training data (and possibly some other
        # situations), classify can raise a TypeError or
        # ZeroDivisionError.
        #
        # https://github.com/mozilla/spicedham/issues/21
        #
        # For now, we'll assume that means it's not abuse.
        pass

    return False
コード例 #2
0
ファイル: test_tasks.py プロジェクト: DerekRies/fjord
 def train(self, descriptions, is_abuse=True):
     # Note: This is probably a cached Spicedham object.
     sham = get_spicedham()
     for desc in descriptions:
         sham.train(tokenize(desc), match=is_abuse)