New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/bf-lu

Package Overview
Dependencies
Maintainers
2
Versions
197
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/bf-lu - npm Package Compare versions

Comparing version 4.10.0-dev.20200731.4aa848c to 4.10.0-dev.20200804.10e144c

2

package.json
{
"name": "@microsoft/bf-lu",
"version": "4.10.0-dev.20200731.4aa848c",
"version": "4.10.0-dev.20200804.10e144c",
"author": "Microsoft",

@@ -5,0 +5,0 @@ "bugs": "https://github.com/microsoft/botframework-cli/issues",

@@ -11,2 +11,91 @@

# V2 API
## Parsing LU Content
To parse LU files, you can use the LUISBuilder class, which returns a LUIS class
```js
const Luis = require('@microsoft/bf-lu').V2.Luis
const LUISBuilder = require('@microsoft/bf-lu').V2.LuisBuilder
const luContent = `# Greeting
- hi`;
const luisObject = await LUISBuilder.fromContentAsync(luContent)
// Parsed LUIS object
console.log(JSON.stringify(luisObject, 2, null));
```
## Validating parsed LU content
You can use the available validate() function to verify if the parsed LUIS object is valid. This helps catch name conflicts, invalid labelled utterances etc.
```js
const LUISBuilder = require('@microsoft/bf-lu').V2.LuisBuilder
const exception = require('@microsoft/bf-lu').V2.Exception
const luContent = `# Greeting
- hi`;
const luisObject = await LUISBuilder.fromLUAsync(luContent)
luisObject.intents[0].name = "testIntent123456789012345678901234567890123"
luisObject.validate()
```
## Generating lu content from LUIS JSON
You can generate lu content from LUIS instance using parseToLuContent() method. Here's an example code snippet.
```js
const LUISBuilder = require('@microsoft/bf-lu').V2.LuisBuilder
const exception = require('@microsoft/bf-lu').V2.Exception
const luContent = `# Greeting
- hi
$userName:first=
-vishwac`;
const log = false;
const locale = 'en-us';
async function parseContent() {
try {
const luisObject = await LUISBuilder.fromContentAsync(luContent)
luisObject.validate()
const parsedLuisBackToLu = luisObject.parseToLuContent()
} catch (error) {
if (error instanceof exception) {
// do something specific to this exception
} else {
console.log(errObj.text);
}
}
}
parseContent();
```
## Translating lu files
You can take advantage of the [Microsoft text translation API](https://docs.microsoft.com/en-us/azure/cognitive-services/translator/) to automatically machine translate .lu files to one or more than [60+ languages](https://aka.ms/translate-langs) supported by the Microsoft text translation cognitive service.
To translate lu file content, you can simply use the translate() method in the LU class. Here's a code snippet.
```js
const LU = require('@microsoft/bf-lu').V2.LU
const luContent = `# Greeting
- hi
$userName:first=
-vishwac`;
const targetLanguage = 'de';
const subscriptionKey = '<YOUR TEXT TRANSLATION KEY>';
const translateComments = true;
const translateLinkText = true;
const luInstance = new LU(luContent)
await luInstance.translate(subscriptionKey, targetLanguage, translateComments, translateLinkText)
const translatedCode = luInstance.content
```
# DEPRECATED V1 API
## Parsing lu files

@@ -154,89 +243,1 @@ To parse LU files, you can use the parseFile() method.

```
# V2 API (Preview. Download from [here](https://botbuilder.myget.org/feed/botframework-cli/package/npm/@microsoft/bf-lu))
## Parsing LU Content
To parse LU files, you can use the LUISBuilder class, which returns a LUIS class
```js
const Luis = require('@microsoft/bf-lu').V2.Luis
const LUISBuilder = require('@microsoft/bf-lu').V2.LuisBuilder
const luContent = `# Greeting
- hi`;
const luisObject = await LUISBuilder.fromContentAsync(luContent)
// Parsed LUIS object
console.log(JSON.stringify(luisObject, 2, null));
```
## Validating parsed LU content
You can use the available validate() function to verify if the parsed LUIS object is valid. This helps catch name conflicts, invalid labelled utterances etc.
```js
const LUISBuilder = require('@microsoft/bf-lu').V2.LuisBuilder
const exception = require('@microsoft/bf-lu').V2.Exception
const luContent = `# Greeting
- hi`;
const luisObject = await LUISBuilder.fromLUAsync(luContent)
luisObject.intents[0].name = "testIntent123456789012345678901234567890123"
luisObject.validate()
```
## Generating lu content from LUIS JSON
You can generate lu content from LUIS instance using parseToLuContent() method. Here's an example code snippet.
```js
const LUISBuilder = require('@microsoft/bf-lu').V2.LuisBuilder
const exception = require('@microsoft/bf-lu').V2.Exception
const luContent = `# Greeting
- hi
$userName:first=
-vishwac`;
const log = false;
const locale = 'en-us';
async function parseContent() {
try {
const luisObject = await LUISBuilder.fromContentAsync(luContent)
luisObject.validate()
const parsedLuisBackToLu = luisObject.parseToLuContent()
} catch (error) {
if (error instanceof exception) {
// do something specific to this exception
} else {
console.log(errObj.text);
}
}
}
parseContent();
```
## Translating lu files
You can take advantage of the [Microsoft text translation API](https://docs.microsoft.com/en-us/azure/cognitive-services/translator/) to automatically machine translate .lu files to one or more than [60+ languages](https://aka.ms/translate-langs) supported by the Microsoft text translation cognitive service.
To translate lu file content, you can simply use the translate() method in the LU class. Here's a code snippet.
```js
const LU = require('@microsoft/bf-lu').V2.LU
const luContent = `# Greeting
- hi
$userName:first=
-vishwac`;
const targetLanguage = 'de';
const subscriptionKey = '<YOUR TEXT TRANSLATION KEY>';
const translateComments = true;
const translateLinkText = true;
const luInstance = new LU(luContent)
await luInstance.translate(subscriptionKey, targetLanguage, translateComments, translateLinkText)
const translatedCode = luInstance.content
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc