Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@telefonica/language-model-converter

Package Overview
Dependencies
Maintainers
8
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@telefonica/language-model-converter - npm Package Compare versions

Comparing version 1.0.3 to 2.0.0

22

lib/index.js
"use strict";
const commander = require('commander');
const glob = require('glob');
const parser_1 = require('./parser');
const cli = commander.option('-p, --path <path>', 'Path to the folder containing language models')
.option('-c, --culture <culture>', 'Culture code (ex. "en-us")')
.parse(process.argv);
const cli = commander
.description('Convert language files defined to LUIS format')
.usage('[options] <files>')
.option('-c, --culture <culture>', 'Culture code this files belongs to (ex. "en-us")');
commander.on('--help', function () {
console.log(` Examples:
Convert all files in 'models' and its subfolders, starting with 'en',
setting the locale to en-us
$ language-model-converter ./models/**/en*.yaml -c en-us
`);
});
commander.parse(process.argv);
cli.files = cli.args
.map(pattern => glob.sync(pattern))
.reduce((a, b) => a.concat(b), []);
let parser = new parser_1.LanguageModelParser();
let luisModel = parser.parse(cli.path, cli.culture);
let luisModel = parser.parse(cli.files, cli.culture);
console.log(JSON.stringify(luisModel, null, 2));
//# sourceMappingURL=index.js.map

2

lib/parser.d.ts
import { Luis } from './luis-model';
export declare class LanguageModelParser {
private doc;
parse(folder: string, culture: string): Luis.Model;
parse(files: string[], culture: string): Luis.Model;
private expandVariables(sentence);

@@ -6,0 +6,0 @@ private extractEntities(sentence);

"use strict";
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');

@@ -9,9 +8,6 @@ class LanguageModelParser {

}
parse(folder, culture) {
parse(files, culture) {
try {
let files = fs.readdirSync(folder)
.filter(file => !fs.statSync(path.join(folder, file)).isDirectory())
.filter(file => file.startsWith(culture) && file.endsWith('.yaml'));
files.forEach(file => {
let yamlFileContents = fs.readFileSync(path.join(folder, file), 'utf8');
let yamlFileContents = fs.readFileSync(file, 'utf8');
Object.assign(this.doc, yaml.safeLoad(yamlFileContents));

@@ -18,0 +14,0 @@ });

@@ -7,3 +7,3 @@ "use strict";

let parser = new parser_1.LanguageModelParser();
let luisModel = parser.parse('./test/fixtures', 'en-basic');
let luisModel = parser.parse(['./test/fixtures/en-basic.yaml'], 'en-basic');
let expectedIntents = [

@@ -68,3 +68,3 @@ {

let parser = new parser_1.LanguageModelParser();
let luisModel = parser.parse('./test/fixtures', 'en-basic');
let luisModel = parser.parse(['./test/fixtures/en-basic.yaml'], 'en-basic');
chai_1.expect(luisModel.luis_schema_version).to.not.be.empty;

@@ -77,3 +77,3 @@ chai_1.expect(luisModel.name).to.not.be.empty;

let parser = new parser_1.LanguageModelParser();
let luisModel = parser.parse('./test/fixtures', 'en-cornercases');
let luisModel = parser.parse(['./test/fixtures/en-cornercases.yaml'], 'en-cornercases');
let expectedUtterances = [

@@ -107,3 +107,3 @@ {

let parser = new parser_1.LanguageModelParser();
let luisModel = parser.parse('./test/fixtures', 'en-variables');
let luisModel = parser.parse(['./test/fixtures/en-variables.yaml'], 'en-variables');
let expectedUtterances = [

@@ -110,0 +110,0 @@ {

{
"name": "@telefonica/language-model-converter",
"version": "1.0.3",
"version": "2.0.0",
"description": "Language model converter for yot-bot",

@@ -32,2 +32,3 @@ "license": "UNLICENSED",

"commander": "^2.9.0",
"glob": "^7.1.0",
"js-yaml": "^3.6.1"

@@ -38,2 +39,3 @@ },

"@types/commander": "^2.3.30",
"@types/glob": "^5.0.30",
"@types/js-yaml": "^3.5.28",

@@ -40,0 +42,0 @@ "@types/mocha": "^2.2.32",

@@ -8,8 +8,21 @@ # language-model-converter

```sh
npm install @telefonica/language-model-converter
npm install -g @telefonica/language-model-converter
language-model-converter --help
language-model-converter -p ../language-model -c en-us
language-model-converter -p ../language-model -c es-es
Usage: language-model-converter [options] <files>
Convert language files defined to LUIS format
Options:
-h, --help output usage information
-c, --culture <culture> Culture code this files belongs to (ex. "en-us")
Examples:
Convert all files in 'models' and its subfolders, starting with 'en',
setting the locale to en-us
$ language-model-converter ./models/**/en*.yaml -c en-us
```
Notice that you can use [luis-cli](../luis-cli) to import or update the generated LUIS models.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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