def gradeQuestion(request):
	questionList = json.loads(request.POST['questions'])
	for question in questionList:
		sentenceText = question['sentence']
		questionText = question['question']
		labelText = question['label']
		gradeVal = question['grade']
		if Sentence.objects.filter(text=sentenceText).exists() :
			sentence = Sentence.objects.get(text=sentenceText)
		else:
			sentence = Sentence(text=sentenceText)
			sentence.save()

		if Question.objects.filter(text=questionText).exists():
			question = Question.objects.get(text=questionText)
		else:
			question = Question(text=questionText)
			question.save()

		if Label.objects.filter(text=labelText).exists():
			label = Label.objects.get(text = labelText)
		else:
			label = Label(text = labelText)
			label.save()
		grade = Grade(sentence=sentence,question=question,label=label,grade=gradeVal)
		grade.save()
	return HttpResponse('200')
Example #2
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()
Example #3
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()
Example #4
0
def _add_sentences(question):
    for index, text in enumerate(_split_text(question.text)):
        sentence = Sentence(question=question, text=text, index=index)
        sentence.save()