Skip to content

Commit

Permalink
Ajuste na lógica que removia todos os caracteres especiais, colocando…
Browse files Browse the repository at this point in the history
… de volta vogais e consoantes com acento, pois estava gerando problema com outros idiomas.
  • Loading branch information
fabianosan committed Dec 28, 2024
1 parent 9510e4d commit cbd8649
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lambda_functions/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def keywords_exec(query, handler_input):
open_page(handler_input)
return handler_input.response_builder.speak(globals().get("alexa_speak_open_dashboard")).response

# Se o usuário der um comando para 'abrir dashboard' ou 'abrir home assistant', abre o dashboard e interrompe a skill
# Se o usuário der um comando de agradecimento o upara sair, interrompe a skill
keywords_close_skill = globals().get("keywords_to_close_skill").split(";")
if any(kc.strip().lower() in query.lower() for kc in keywords_close_skill):
logger.info("Closing skill from keyword command")
Expand Down Expand Up @@ -245,9 +245,10 @@ def replace_words(query):
def improve_response(speech):
# Função para melhorar a legibilidade da resposta
speech = speech.replace(':\n\n', '').replace('\n\n', '. ').replace('\n', ',').replace('-', '').replace('_', ' ')
replacements = str.maketrans('ïöüÏÖÜ', 'iouIOU')
speech = speech.translate(replacements)
speech = re.sub(r'[^A-Za-z0-9çÇáàâãéèêíóôõúñÁÀÂÃÉÈÊÍÓÔÕÚÑ\s.,!?]', '', speech)
#replacements = str.maketrans('ïöüÏÖÜ', 'iouIOU')
#speech = speech.translate(replacements)
#speech = re.sub(r'[^A-Za-z0-9çÇáàâãéèêíóôõúñÁÀÂÃÉÈÊÍÓÔÕÚÑ\s.,!?]', '', speech)
speech = re.sub(r'[^A-Za-z0-9\s.,!?]', '', speech)
return speech

# Carrega o template do APL da tela inicial
Expand Down

0 comments on commit cbd8649

Please sign in to comment.