Categorias:

Funções de cadeia de caracteres e binários (Large Language Model)

TRANSLATE (SNOWFLAKE.CORTEX)

Traduz o texto de entrada fornecido de um idioma compatível para outro.

Atenção

Esta função não transforma uma cadeia de caracteres dada uma cadeia de caracteres de pesquisa e uma cadeia de caracteres de substituição. Veja a função TRANSLATE se essa funcionalidade for o que você está procurando.

Sintaxe

SNOWFLAKE.CORTEX.TRANSLATE(
    <text>, <source_language>, <target_language>)
Copy

Argumentos

text

Uma cadeia de caracteres contendo o texto a ser traduzido.

source_language

Uma cadeia de caracteres que especifica o código do idioma em que o texto está atualmente. Consulte Notas de uso para obter uma lista de códigos de idiomas compatíveis. Se o código do idioma de origem for uma sequência vazia, '', o idioma de origem será detectado automaticamente.

target_language

Uma cadeia de caracteres que especifica o código do idioma para o qual o texto deve ser traduzido. Consulte Notas de uso para obter uma lista de códigos de idiomas compatíveis.

Retornos

Uma cadeia de caracteres contendo uma tradução do texto original para o idioma de destino.

Notas de uso

Os seguintes idiomas são suportados pela função TRANSLATE. Use o código de idioma correspondente para o idioma de origem e de destino.

O modelo TRANSLATE também oferece suporte a uma combinação de dois idiomas diferentes no texto que está sendo traduzido (por exemplo, «espanglês»). Nesse caso, especifique uma cadeia de caracteres vazia ('') como o idioma de origem para detectar automaticamente os idiomas usados no texto de origem.

Linguagem

Código

Chinês

'zh'

Holandês

'nl'

Inglês

'en'

Francês:

'fr'

Alemão

'de'

Hindi

'hi'

Italiano

'it'

Japonês

'ja'

Coreano

'ko'

Polonês

'pl'

Português

'pt'

Russo

'ru'

Espanhol

'es'

Sueco

'sv'

A função TRANSLATE produz seus melhores resultados quando o idioma de origem ou destino é o inglês (por exemplo, inglês para espanhol ou alemão para inglês). Os resultados para outros pares de idiomas, como alemão para espanhol, podem ser menos precisos.

Requisitos de controle de acesso

Os usuários devem usar uma função que tenha a função do banco de dados SNOWFLAKE.CORTEX_USER. Consulte Privilégios obrigatórios para obter mais informações sobre esse privilégio.

Exemplos

O exemplo a seguir traduz cada linha de uma tabela do inglês para o alemão (neste exemplo, review_content é uma coluna da tabela reviews):

SELECT SNOWFLAKE.CORTEX.TRANSLATE(review_content, 'en', 'de') FROM reviews LIMIT 10;
Copy

O exemplo a seguir traduz uma avaliação de produto fictícia do inglês para o espanhol:

SELECT SNOWFLAKE.CORTEX.TRANSLATE(
  'Hit the slopes with Snowflake\'s latest innovation - "Skii Headphones" designed to keep your ears warm and your soul ablaze. Engineered specifically for snow weather, these rugged headphones combine crystal-clear sound with thermally-insulated ear cups to keep the chill out and the beats in. Whether you\'re carving through powder or cruising down groomers, Skii Headphones will fuel your mountain adventures with vibrant sound and unrelenting passion. Stay warm, stay fired up, and shred the mountain with Snowflake Skii Headphones',
'en','es');
Copy

O resultado dessa consulta é:

Sube a las pistas con la última innovación de Snowflake: "Skii Headphones", diseñados para mantener tus oídos calientes y tu alma encendida. Diseñados específicamente para el clima de nieve, estos audífonos resistentes combinan un sonido cristalino con copas de oído aisladas térmicamente para mantener el frío fuera y los ritmos dentro. Ya sea que estés esculpiendo en polvo o deslizándote por pistas preparadas, los Skii Headphones alimentarán tus aventuras en la montaña con un sonido vibrante y una pasión incesante. Mantente caliente, mantente encendido y arrasa la montaña con los Skii Headphones de Snowflake.

O exemplo a seguir traduz uma transcrição de chamada de alemão para inglês:

SELECT SNOWFLAKE.CORTEX.TRANSLATE
  ('Kunde: Hallo
    Agent: Hallo, ich hoffe, es geht Ihnen gut. Um Ihnen am besten helfen zu können, teilen Sie bitte Ihren Vor- und Nachnamen und den Namen der Firma, von der aus Sie anrufen.
    Kunde: Ja, hier ist Thomas Müller von SkiPisteExpress.
    Agent: Danke Thomas, womit kann ich Ihnen heute helfen?
    Kunde: Also wir haben die XtremeX Helme in Größe M bestellt, die wir speziell für die kommende Wintersaison benötigen. Jedoch sind alle Schnallen der Helme defekt, und keiner schließt richtig.
    Agent: Ich verstehe, dass das ein Problem für Ihr Geschäft sein kann. Lassen Sie mich überprüfen, was mit Ihrer Bestellung passiert ist. Um zu bestätigen: Ihre Bestellung endet mit der Nummer 56682?
    Kunde: Ja, das ist meine Bestellung.
    Agent: Ich sehe das Problem. Entschuldigen Sie die Unannehmlichkeiten. Ich werde sofort eine neue Lieferung mit reparierten Schnallen für Sie vorbereiten, die in drei Tagen bei Ihnen eintreffen sollte. Ist das in Ordnung für Sie?
    Kunde: Drei Tage sind ziemlich lang, ich hatte gehofft, diese Helme früher zu erhalten. Gibt es irgendeine Möglichkeit, die Lieferung zu beschleunigen?
    Agent: Ich verstehe Ihre Dringlichkeit. Ich werde mein Bestes tun, um die Lieferung auf zwei Tage zu beschleunigen. Wie kommst du damit zurecht?
    Kunde: Das wäre großartig, ich wäre Ihnen sehr dankbar.
    Agent: Kein Problem, Thomas. Ich kümmere mich um die eilige Lieferung. Danke für Ihr Verständnis und Ihre Geduld.
    Kunde: Vielen Dank für Ihre Hilfe. Auf Wiedersehen!
    Agent: Bitte, gerne geschehen. Auf Wiedersehen und einen schönen Tag noch!'
,'de','en');
Copy

O resultado é o seguinte:

Customer: Hello
Agent: Hello, I hope you are well. To best assist you, please share your first and last name and the name of the company you are calling from.
Customer: Yes, this is Thomas Müller from SkiPisteExpress.
Agent: Thank you, Thomas, what can I help you with today?
Customer: So, we ordered the XtremeX helmets in size M, which we specifically need for the upcoming winter season. However, all the buckles on the helmets are defective and none of them close properly.
Agent: I understand that this can be a problem for your business. Let me check what happened with your order. To confirm: your order ends with the number 56682?
Customer: Yes, that's my order.
Agent: I see the issue. I apologize for the inconvenience. I will prepare a new delivery with repaired buckles for you immediately, which should arrive in three days. Is that okay for you?
Customer: Three days is quite a long time; I was hoping to receive these helmets sooner. Is there any way to expedite the delivery?
Agent: I understand your urgency. I will do my best to expedite the delivery to two days. How does that sound?
Customer: That would be great, I would be very grateful.
Agent: No problem, Thomas. I will take care of the urgent delivery. Thank you for your understanding and patience.
Customer: Thank you very much for your help. Goodbye!
Agent: You're welcome. Goodbye and have a nice day!

Por fim, o exemplo a seguir ilustra a tradução de texto de dois idiomas diferentes (neste caso, inglês e espanhol, ou «espanglês») para o inglês. Observe que a especificação do idioma de origem é a cadeia de caracteres vazia.

SELECT SNOWFLAKE.CORTEX.TRANSLATE ('Voy a likear tus fotos en Insta.', '', 'en')
Copy

Essa consulta resulta em:

I'm going to like your photos on Insta.