#coding=utf-8
from django.conf import settings

from celery import shared_task
from word.models import Word, StopWord


@shared_task
def generate_word():
    txt = open(settings.WORD_FILE,"w", encoding='utf-8')
    words = Word.objects.all()
    values = ["%s\n" % word.value for word in words]
    txt.writelines(values)
    txt.close()

@shared_task
def generate_stopword():
    txt = open(settings.STOP_WORD_FILE,"w", encoding='utf-8')
    words = StopWord.objects.all()
    values = ["%s\n" % word.value for word in words]
    txt.writelines(values)
    txt.close()
