D'autres exemples de AWS SDK sont disponibles dans le référentiel AWS Doc SDK Examples GitHub .
Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Utilisation DeleteVocabulary avec un AWS SDK ou une CLI
Les exemples de code suivants illustrent comment utiliser DeleteVocabulary.
Les exemples d’actions sont des extraits de code de programmes de plus grande envergure et doivent être exécutés en contexte. Vous pouvez voir cette action en contexte dans l’exemple de code suivant :
- .NET
-
- SDK for .NET
-
/// <summary>
/// Delete an existing custom vocabulary.
/// </summary>
/// <param name="vocabularyName">Name of the vocabulary to delete.</param>
/// <returns>True if successful.</returns>
public async Task<bool> DeleteCustomVocabulary(string vocabularyName)
{
var response = await _amazonTranscribeService.DeleteVocabularyAsync(
new DeleteVocabularyRequest
{
VocabularyName = vocabularyName
});
return response.HttpStatusCode == HttpStatusCode.OK;
}
- CLI
-
- AWS CLI
-
Pour supprimer un vocabulaire personnalisé
L’exemple delete-vocabulary suivant supprime un vocabulaire personnalisé.
aws transcribe delete-vocabulary \
--vocabulary-name vocabulary-name
Cette commande ne produit aucune sortie.
Pour plus d’informations, consultez Glossaires personnalisés dans le Guide du développeur Amazon Transcribe.
- Python
-
- Kit SDK for Python (Boto3)
-
def delete_vocabulary(vocabulary_name, transcribe_client):
"""
Deletes a custom vocabulary.
:param vocabulary_name: The name of the vocabulary to delete.
:param transcribe_client: The Boto3 Transcribe client.
"""
try:
transcribe_client.delete_vocabulary(VocabularyName=vocabulary_name)
logger.info("Deleted vocabulary %s.", vocabulary_name)
except ClientError:
logger.exception("Couldn't delete vocabulary %s.", vocabulary_name)
raise
- SAP ABAP
-
- Kit SDK pour SAP ABAP
-
TRY.
lo_tnb->deletevocabulary( iv_vocabulary_name ).
MESSAGE 'Vocabulary deleted.' TYPE 'I'.
CATCH /aws1/cx_tnbbadrequestex INTO DATA(lo_bad_request_ex).
MESSAGE lo_bad_request_ex TYPE 'I'.
CATCH /aws1/cx_tnblimitexceededex INTO DATA(lo_limit_ex).
MESSAGE lo_limit_ex TYPE 'I'.
RAISE EXCEPTION lo_limit_ex.
CATCH /aws1/cx_tnbnotfoundexception INTO DATA(lo_not_found_ex).
MESSAGE lo_not_found_ex TYPE 'I'.
CATCH /aws1/cx_tnbinternalfailureex INTO DATA(lo_internal_ex).
MESSAGE lo_internal_ex TYPE 'I'.
RAISE EXCEPTION lo_internal_ex.
ENDTRY.