Exemple #1
0
def analyze_feed_spam(analyzer, group, message):
    """
    Return true if analyzed words and spam words are same
    :param analyzer: analyzer for analysis
    :param group: group object
    :param message: message of post or comment
    :return: true or false
    """
    spam_db = SpamWordList.objects.filter(Q(group=group), Q(status='filter') | Q(status='user'))
    data_set = [sp.word for sp in spam_db]
    word_set = core.analyze_articles(analyzer, message)

    return core.analysis_text_by_words(data_set, word_set)
Exemple #2
0
def analyze_feed_spam(group, message):
    """
    Return true if analyzed words and spam words are same
    :param group: group object
    :param message: message of post or comment
    :return: true or false
    """
    spam_db = SpamWordList.objects.filter(
        Q(group=group),
        Q(status='filter') | Q(status='user'))
    data_set = [sp.word for sp in spam_db]
    word_set = core.analyze_articles(analyzer, message)

    # arg = SpamWordList.objects.filter(group=group).aggregate(avgcount=Avg('count'))

    return core.analysis_text_by_words(data_set, word_set, 0)
Exemple #3
0
def analyze_feed(analyzer, data_object, group):
    """
    analyze a feed
    :param analyzer: analyzer for analysis
    :param data_object: data object
    :return: words from analyzed feed
    """
    #if data_object.message is not None:
    #    message = data_object.message
    #else:
    #    message = ''

    #if 'attachment' in data_object:
    #    attach = data_object.get('attachment')
    #    if 'description' in attach:
    #        attach_message = attach.get('description')
    #    elif 'title' in attach:
    #        attach_message = attach.get('title')
    #    else:
    #        attach_message = ''
    #else:
    #    attach_message = ''

    message = data_object
    attach_message = ''

    if message is not '':
        message_word_set = core.analyze_articles(analyzer, message)
    else:
        message_word_set = []

    if attach_message is not '':
        attach_word_set = core.analyze_articles(analyzer, attach_message)
    else:
        attach_word_set = []

    temp_set = message_word_set + attach_word_set
    word_set = list(set(temp_set))      # make better algorithm

    word_db = ArchiveAnalysisWord.objects.filter(group=group, weigh__gte=100)
    data_set = [sp.word for sp in word_db]

    return core.analysis_text_by_words(data_set, word_set)
Exemple #4
0
def analyze_feed(data_object):
    """
    analyze a feed
    :param data_object: data object
    :return: words from analyzed feed
    """
    if data_object.message is not None:
        message = data_object.message
    else:
        message = ''

    if 'attachment' in data_object:
        attach = data_object.get('attachment')
        if 'description' in attach:
            attach_message = attach.get('description')
        elif 'title' in attach:
            attach_message = attach.get('title')
        else:
            attach_message = ''
    else:
        attach_message = ''

    # message = data_object
    # attach_message = ''

    if message is not '':
        message_word_set = core.analyze_articles(message)
    else:
        message_word_set = []

    if attach_message is not '':
        attach_word_set = core.analyze_articles(attach_message)
    else:
        attach_word_set = []

    temp_set = message_word_set + attach_word_set
    word_set = list(set(temp_set))      # make better algorithm

    word_db = MonthlyWords.objects.filter(group=data_object.group)
    data_set = [sp.word for sp in word_db]

    return core.analysis_text_by_words(data_set, word_set, 5)
Exemple #5
0
def analyze_feed(data_object):
    """
    analyze a feed
    :param data_object: data object
    :return: words from analyzed feed
    """
    if data_object.message is not None:
        message = data_object.message
    else:
        message = ""

    if "attachment" in data_object:
        attach = data_object.get("attachment")
        if "description" in attach:
            attach_message = attach.get("description")
        elif "title" in attach:
            attach_message = attach.get("title")
        else:
            attach_message = ""
    else:
        attach_message = ""

    # message = data_object
    # attach_message = ''

    if message is not "":
        message_word_set = core.analyze_articles(message)
    else:
        message_word_set = []

    if attach_message is not "":
        attach_word_set = core.analyze_articles(attach_message)
    else:
        attach_word_set = []

    temp_set = message_word_set + attach_word_set
    word_set = list(set(temp_set))  # make better algorithm

    word_db = MonthlyWords.objects.filter(group=data_object.group)
    data_set = [sp.word for sp in word_db]

    return core.analysis_text_by_words(data_set, word_set, 5)