def decide_context(term,chunks,eojeol,i,j): if len(chunks) == 1: ## Only one eojeol if len(eojeol) == 1: ## Eojeol has a single morpheme return readNumber(term) else: ## Multiple morphemes if j == len(eojeol)-1: return chunks[i][j-1],chunks[i][j-1] elif j == 0: return chunks[i][j+1],chunks[i][j+1] else: return chunks[i][j-1],chunks[i][j+1] else: ## Multiple eojeols if len(eojeol) == 1: ## Eojeol has a single morpheme if i == len(chunks)-1: return chunks[i-1][-1],chunks[i-1][-1] elif i == 0: return chunks[i+1][0],chunks[i+1][0] else: return chunks[i-1][-1],chunks[i+1][0] else: ## Multiple morphemes if j == len(eojeol)-1: if i == len(chunks)-1: ## Truly last morpheme return chunks[i][j-1],chunks[i][j-1] else: return chunks[i][j-1],chunks[i+1][0] elif j == 0: if i == 0: ## Truly first morpheme return chunks[i][j+1],chunks[i][j+1] else: return chunks[i-1][-1],chunks[i][j+1] else: return chunks[i][j-1],chunks[i][j+1]
def trans_number(n,prev_term,next_term): ## Context-given number reading if hgtk.checker.is_hangul(prev_term) and hgtk.checker.is_hangul(next_term): return readNumberKor(n,next_term) elif real_latin(prev_term) or real_latin(next_term): if hgtk.checker.is_hangul(next_term) and n>10: return readNumberKor(n,next_term) else: return readNumberEng(n) else: ## Maybe hanja if prev_term in symbols or next_term in symbols: return readOnlyNum(n) elif n > 99999: return readBigNum(n) else: return readNumber(n)
def promptQuestionAndSendAnswer(sessionInfo, sessionState, httpClient): question = sessionState.question answersTxt = '' for i in range(0, len(question.answers)): answersTxt += f"{i + 1}: {question.answers[i].text}\n" print(f""" ########### Question: {question.text} {answersTxt} ########### """) answerIndex = readNumber("Select Answer:", 1, len(question.answers)) - 1 answerId = question.answers[answerIndex].id return httpClient.submitResponse(sessionInfo.playerToken, sessionState.round, question.id, answerId)