Exemplo n.º 1
0
    def post(self, request_id):
        user = users.get_current_user()
        request = models.read(request_id)

        for q in request.questions:
            feedback = self.request.POST.get(q)
            if not feedback:
                continue

            saved_feedback = models.feedback(user, request, q, feedback)

            saved_feedback.feedback = feedback
            saved_feedback.put()

        return webapp2.redirect('/request/{0}?status=saved'.format(request_id))
Exemplo n.º 2
0
    def api_put(request):
        """
		响应PUT
		"""
        data = request_util.get_fields_to_be_save(request)
        feedback = app_models.feedback(**data)
        feedback.save()
        error_msg = None

        data = json.loads(feedback.to_json())
        data['id'] = data['_id']['$oid']
        if error_msg:
            data['error_msg'] = error_msg
        response = create_response(200)
        response.data = data
        return response.get_response()
Exemplo n.º 3
0
def addfeedback(request):
    res = {'code': 1, 'message': ''}
    try:
        uid = request.GET['uid']
        txt = request.GET['txt']
    except:
        return HttpResponse(json.dumps(res))
        #if True:
    try:
        feed = feedback()
        feed.uid = uid
        feed.txt = txt
        feed.save()
    #else:
    except:
        return HttpResponse(json.dumps(res))
    res['code'] = 0
    res['message'] = 'ok'
    return HttpResponse(json.dumps(res))
Exemplo n.º 4
0
def addfeedback(request):
    res={'code':1,'message':''}
    try:
        uid=request.GET['uid']
        txt=request.GET['txt']
    except:
        return HttpResponse(json.dumps(res))
        #if True:
    try:
       feed=feedback()
       feed.uid=uid
       feed.txt=txt
       feed.save()
    #else:
    except:
        return HttpResponse(json.dumps(res))
    res['code']=0
    res['message']='ok'
    return HttpResponse(json.dumps(res))
Exemplo n.º 5
0
Arquivo: demo.py Projeto: FTAsr/STS
                    score = raw_input('Enter target score:')
                    threshold = raw_input(
                        'Enter threshold for word importance:')
                    input_scale = raw_input(
                        'Choose 1 for 0-1 scale, 2 for 0-5 scale:')
                    if int(input_scale) == 1:
                        score = float(score) * 5

                    testSet = [[goldA], [studA], [float(score)]]
                    result = app.test(usedModels, classifier, testSet)
                    # Covert result into required grading scale.
                    result = post_process(result)
                    print result

                    #feedback_model.build_vocab([sentA, sentB], tokenize=True)
                    keywords = models.feedback(feedm.feedback_model, goldA,
                                               float(threshold))
                    #print 'keywords:', keywords
                    sent = nltk.word_tokenize(studA)
                    sent = [word.lower() for word in sent]
                    #print 'sent', sent
                    feedback = set(keywords) - set(sent) - set(['<s>', '</s>'])
                    print 'Hey there, you missed following keywords:\n', list(
                        feedback)

                elif BATCH_MODE:
                    input_path = raw_input(
                        'Enter the complete file path for test data. \n')
                    trainSet, devSet, testSet = app.load_data_nosplit(
                        input_path)
                    result = app.test([feedm, fbm], classifier, testSet)
                    result = post_process(result)