Skip to content

Commit

Permalink
docs: update classification sample to use v2 model (#700)
Browse files Browse the repository at this point in the history
Fixes #699
  • Loading branch information
wizeng23 authored Sep 26, 2022
1 parent b06762c commit 507799a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cloud-language/snippets/analyze.v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,17 @@ async function classifyTextOfText(text) {
type: 'PLAIN_TEXT',
};

const classificationModelOptions = {
v2Model: {
contentCategoriesVersion: 'V2',
},
};

// Classifies text in the document
const [classification] = await client.classifyText({document});
const [classification] = await client.classifyText({
document,
classificationModelOptions,
});
console.log('Categories:');
classification.categories.forEach(category => {
console.log(`Name: ${category.name}, Confidence: ${category.confidence}`);
Expand Down

0 comments on commit 507799a

Please sign in to comment.