Ejemplo n.º 1
0
def populate_sentences(question):
    sentences = prep.paragraph_to_sentences(question.text)
    for index, text in sentences.iteritems():
        if Sentence.objects.filter(index=index, question=question).exists():
            sentence = Sentence.objects.get(index=index, question=question)
            sentence.text = text
        else:
            sentence = Sentence(index=index, text=text, question=question)
        sentence.save()
Ejemplo n.º 2
0
def _add_sentences(question):
    for index, text in enumerate(_split_text(question.text)):
        sentence = Sentence(question=question, text=text, index=index)
        sentence.save()