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})
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, })
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 )
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 )
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)