Esempio n. 1
0
def save_user_word(group_id, word):
    """
    Save user's words in DB
    :param group_id: group id
    :param word: target word
    """
    group = Group.objects.filter(id=group_id)[0]
    store_data = SpamWordList(word=word, group=group, status='user')
    store_data.save()
Esempio n. 2
0
def save_user_word(group_id, word):
    """
    Save user's words in DB
    :param group_id: group id
    :param word: target word
    """
    group = Group.objects.filter(id=group_id)[0]
    store_data = SpamWordList(word=word, group=group, status='user')
    store_data.save()
Esempio n. 3
0
def init_db(group):
    """
    save standard word from spam.txt to database when initialize database
    :param group: group object
    """
    data_set = [line.strip() for line in open("analysis/texts/spam.txt", 'r')]
    words = SpamWordList.objects.filter(group=group)

    for i in data_set:
        if i in words:
            continue

        store_data = SpamWordList(word=i, group=group, status='filter')
        store_data.save()
Esempio n. 4
0
def init_db(group):
    """
    save standard word from spam.txt to database when initialize database
    :param group: group object
    """
    data_set = [line.strip() for line in open("analysis/texts/spam.txt", 'r')]
    words = SpamWordList.objects.filter(group=group)

    for i in data_set:
        if i in words:
            continue

        store_data = SpamWordList(word=i, group=group, status='filter')
        store_data.save()
Esempio n. 5
0
def update_words_level(group):
    """
    change temp and deleted status of words which are greater than critical point to filter status
    :param group: group object
    """
    words_db = SpamWordList.objects.filter(group=group, status='temp', count__gte=10)
    for i in words_db:
        word = SpamWordList(group=group, word=i.word)
        word.status = 'filter'
        word.save()

    words = SpamWordList.objects.filter(group=group, status='deleted', count__gte=30)
    if words is not None:
        for i in words:
            word = SpamWordList(group=group, word=i.word)
            word.status = 'filter'
            word.save()
Esempio n. 6
0
def update_words_level(group):
    """
    change temp and deleted status of words which are greater than critical point to filter status
    :param group: group object
    """
    words_db = SpamWordList.objects.filter(group=group,
                                           status='temp',
                                           count__gte=10)
    for i in words_db:
        word = SpamWordList(group=group, word=i.word)
        word.status = 'filter'
        word.save()

    words = SpamWordList.objects.filter(group=group,
                                        status='deleted',
                                        count__gte=30)
    if words is not None:
        for i in words:
            word = SpamWordList(group=group, word=i.word)
            word.status = 'filter'
            word.save()