예제 #1
0
파일: views.py 프로젝트: recsm/SQP
def get_num_syllables(request):
    """A view used to test NLP"""
    key_string = 'English (United States)'
    if request.method == 'POST':
        try:
            original = request.POST['original']
            key_string = request.POST['language']
            num_syllables = nlp_tools.count_syllables(original, key_string)
        except:
            num_syllables = 'Sorry, could not hyphenate for '\
                 + key_string + '.'
    else:
        num_syllables = ''
    return render_to_response('sqp/get_quantity.html', {'quantity'
                              : num_syllables})
예제 #2
0
파일: views.py 프로젝트: recsm/SQP
def syllable_tool(request):
    """A view used to test NLP"""
    original = ''
    inserted = ''
    key_string = 'English (United States)'

    if request.method == 'POST':
        form_data = request.POST.copy()
        key_string = request.POST['language']
        original = request.POST['original']
        form_data['inserted'] = nlp_tools.show_syllables(original, key_string)
        form = SyllableForm(form_data)
    else:
        form = SyllableForm({'language': key_string})

    num_syllables = nlp_tools.count_syllables(original, key_string)

    return render_to_response('sqp/syllable_tool.html', {
        'num_syllables': num_syllables,
        'form': form,
        'request': request,
        'keystring': key_string,
        })
예제 #3
0
파일: suggestions.py 프로젝트: recsm/SQP
def int_num_syllables(question, characteristic):
    "Suggestion for number of syllables in introduction."
    return nlp_tools.count_syllables(
        question.introduction_text, language=question.language.iso2, country=question.country.iso
    )
예제 #4
0
파일: suggestions.py 프로젝트: recsm/SQP
def ans_num_syllables(question, characteristic):
    "Suggestion for number of syllables in answer categories."
    return nlp_tools.count_syllables(
        question.answer_text, language=question.language.iso2, country=question.country.iso
    )
예제 #5
0
파일: suggestions.py 프로젝트: recsm/SQP
def rfa_num_syllables(question, characteristic):
    "Suggestion for number of syllables in Request for an Answer (RFA)."
    return nlp_tools.count_syllables(question.rfa_text, language=question.language.iso2, country=question.country.iso)