Created
November 18, 2021 16:25
-
-
Save Hkazanci93/5368a670843160ebe7e812eb0ff267f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GCP requires 20 words | |
// we pad with prepositions if between 10-19 words for max coverage | |
if (len < 20) { | |
content = [...content.split(' '), ...preps.slice(0, 20 - len)].join(' '); | |
} | |
const sslCreds = getApiKeyCredentials(); | |
const client = new language.LanguageServiceClient({ sslCreds }); | |
const document = { | |
content, | |
type: 'PLAIN_TEXT', | |
}; | |
const [result] = await client.classifyText({ document: document }); | |
categories = result.categories || []; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment