| 34 | const client = new AutoMlClient(); |
| 35 | |
| 36 | async function createDataset() { |
| 37 | // Construct request |
| 38 | const request = { |
| 39 | parent: client.locationPath(projectId, location), |
| 40 | dataset: { |
| 41 | displayName: displayName, |
| 42 | translationDatasetMetadata: { |
| 43 | sourceLanguageCode: 'en', |
| 44 | targetLanguageCode: 'ja', |
| 45 | }, |
| 46 | }, |
| 47 | }; |
| 48 | |
| 49 | // Create dataset |
| 50 | const [operation] = await client.createDataset(request); |
| 51 | |
| 52 | // Wait for operation to complete. |
| 53 | const [response] = await operation.promise(); |
| 54 | |
| 55 | console.log(`Dataset name: ${response.name}`); |
| 56 | console.log(` |
| 57 | Dataset id: ${ |
| 58 | response.name |
| 59 | .split('/') |
| 60 | [response.name.split('/').length - 1].split('\n')[0] |
| 61 | }`); |
| 62 | } |
| 63 | |
| 64 | createDataset(); |
| 65 | // [END automl_translate_create_dataset] |