Sono disponibili altri esempi di AWS SDK nel repository AWS Doc SDK Examples. GitHub
Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
Da utilizzare con un GetVocabulary AWS SDK o CLI
Gli esempi di codice seguenti mostrano come utilizzare GetVocabulary.
Gli esempi di operazioni sono estratti di codice da programmi più grandi e devono essere eseguiti nel contesto. È possibile visualizzare questa operazione nel contesto nel seguente esempio di codice:
- .NET
-
- SDK per .NET
-
/// <summary>
/// Get information about a custom vocabulary.
/// </summary>
/// <param name="vocabularyName">Name of the vocabulary.</param>
/// <returns>The state of the custom vocabulary.</returns>
public async Task<VocabularyState> GetCustomVocabulary(string vocabularyName)
{
var response = await _amazonTranscribeService.GetVocabularyAsync(
new GetVocabularyRequest()
{
VocabularyName = vocabularyName
});
return response.VocabularyState;
}
- CLI
-
- AWS CLI
-
Ottenere informazioni su un vocabolario personalizzato
L’esempio get-vocabulary seguente ottiene informazioni su un vocabolario personalizzato creato in precedenza.
aws transcribe get-vocabulary \
--vocabulary-name cli-vocab-1
Output:
{
"VocabularyName": "cli-vocab-1",
"LanguageCode": "language-code",
"VocabularyState": "READY",
"LastModifiedTime": "2020-09-19T23:22:32.836000+00:00",
"DownloadUri": "https://link-to-download-the-text-file-used-to-create-your-custom-vocabulary"
}
Per ulteriori informazioni, consulta Vocabolari personalizzati nella Guida per gli sviluppatori di Amazon Transcribe.
- Python
-
- SDK per Python (Boto3)
-
def get_vocabulary(vocabulary_name, transcribe_client):
"""
Gets information about a custom vocabulary.
:param vocabulary_name: The name of the vocabulary to retrieve.
:param transcribe_client: The Boto3 Transcribe client.
:return: Information about the vocabulary.
"""
try:
response = transcribe_client.get_vocabulary(VocabularyName=vocabulary_name)
logger.info("Got vocabulary %s.", response["VocabularyName"])
except ClientError:
logger.exception("Couldn't get vocabulary %s.", vocabulary_name)
raise
else:
return response
- SAP ABAP
-
- SDK per SAP ABAP
-
TRY.
oo_result = lo_tnb->getvocabulary( iv_vocabulary_name ).
MESSAGE 'Retrieved vocabulary details.' TYPE 'I'.
CATCH /aws1/cx_tnbbadrequestex INTO DATA(lo_bad_request_ex).
MESSAGE lo_bad_request_ex TYPE 'I'.
RAISE EXCEPTION lo_bad_request_ex.
CATCH /aws1/cx_tnbnotfoundexception INTO DATA(lo_not_found_ex).
MESSAGE lo_not_found_ex TYPE 'I'.
RAISE EXCEPTION lo_not_found_ex.
CATCH /aws1/cx_tnbinternalfailureex INTO DATA(lo_internal_ex).
MESSAGE lo_internal_ex TYPE 'I'.
RAISE EXCEPTION lo_internal_ex.
ENDTRY.