Socket
Socket
Sign inDemoInstall

@telefonica/language-model-converter

Package Overview
Dependencies
Maintainers
11
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 2.4.0 to 2.4.1

31

lib/parser.js

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

let yamlFileContents = fs.readFileSync(file, 'utf8');
Object.assign(this.doc, yaml.safeLoad(yamlFileContents));
mergeDeep(this.doc, yaml.safeLoad(yamlFileContents));
});

@@ -70,3 +70,9 @@ }

let words = (value[1].words || [])
.map((word) => this.tokenize(word).join(' '))
.map((word) => {
let strword = String(word);
if (strword.indexOf(',') !== -1) {
throw new Error(`Prashe list "${name}" can not contain commas ('${strword}')`);
}
return this.tokenize(strword).join(' ');
})
.join(',');

@@ -127,3 +133,3 @@ return {

let composedEntitySeparatorPosition = entityType.indexOf('::');
if (composedEntitySeparatorPosition >= 0) {
if (composedEntitySeparatorPosition !== -1) {
entitySubtype = entityType.substring(composedEntitySeparatorPosition + '::'.length);

@@ -201,2 +207,21 @@ entityType = entityType.substring(0, composedEntitySeparatorPosition);

exports.LanguageModelParser = LanguageModelParser;
function isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item));
}
function mergeDeep(target, source) {
if (isObject(target) && isObject(source)) {
for (const key in source) {
if (isObject(source[key])) {
if (!target[key]) {
Object.assign(target, { [key]: {} });
}
mergeDeep(target[key], source[key]);
}
else {
Object.assign(target, { [key]: source[key] });
}
}
}
return target;
}
//# sourceMappingURL=parser.js.map

282

lib/parser.spec.js

@@ -78,9 +78,9 @@ "use strict";

{
'text': 'santiago went to the santiago bernabeu.',
'intent': 'my.test.intent.1',
'entities': [
text: 'santiago went to the santiago bernabeu.',
intent: 'my.test.intent.1',
entities: [
{
'entity': 'place',
'startPos': 4,
'endPos': 5
entity: 'place',
startPos: 4,
endPos: 5
}

@@ -90,9 +90,9 @@ ]

{
'text': 'i live in the 2ºc apartment in madrid.',
'intent': 'my.test.intent.1',
'entities': [
text: 'i live in the 2ºc apartment in madrid.',
intent: 'my.test.intent.1',
entities: [
{
'entity': 'location',
'startPos': 7,
'endPos': 7
entity: 'location',
startPos: 7,
endPos: 7
}

@@ -102,9 +102,9 @@ ]

{
'text': `i don't like paris`,
'intent': 'my.test.intent.1',
'entities': [
text: `i don't like paris`,
intent: 'my.test.intent.1',
entities: [
{
'entity': 'location',
'startPos': 5,
'endPos': 5
entity: 'location',
startPos: 5,
endPos: 5
}

@@ -114,9 +114,9 @@ ]

{
'text': `i've 123 friends. in paris`,
'intent': 'my.test.intent.1',
'entities': [
text: `i've 123 friends. in paris`,
intent: 'my.test.intent.1',
entities: [
{
'entity': 'location',
'startPos': 7,
'endPos': 7
entity: 'location',
startPos: 7,
endPos: 7
}

@@ -126,14 +126,14 @@ ]

{
'text': `i'd like to go to o'brian and l.a.`,
'intent': 'my.test.intent.1',
'entities': [
text: `i'd like to go to o'brian and l.a.`,
intent: 'my.test.intent.1',
entities: [
{
'entity': 'location',
'startPos': 7,
'endPos': 9
entity: 'location',
startPos: 7,
endPos: 9
},
{
'entity': 'location',
'startPos': 11,
'endPos': 14
entity: 'location',
startPos: 11,
endPos: 14
}

@@ -143,14 +143,14 @@ ]

{
'text': 'i _love_ paris and great_britain.',
'intent': 'my.test.intent.1',
'entities': [
text: 'i _love_ paris and great_britain.',
intent: 'my.test.intent.1',
entities: [
{
'entity': 'location',
'startPos': 4,
'endPos': 4
entity: 'location',
startPos: 4,
endPos: 4
},
{
'entity': 'location',
'startPos': 6,
'endPos': 8
entity: 'location',
startPos: 6,
endPos: 8
}

@@ -160,9 +160,9 @@ ]

{
'text': 'the best city in-the-world is new-york',
'intent': 'my.test.intent.1',
'entities': [
text: 'the best city in-the-world is new-york',
intent: 'my.test.intent.1',
entities: [
{
'entity': 'location',
'startPos': 9,
'endPos': 11
entity: 'location',
startPos: 9,
endPos: 11
}

@@ -172,14 +172,14 @@ ]

{
'text': 'i love open spaces , like the one in bei jing and london',
'intent': 'my.test.intent.1',
'entities': [
text: 'i love open spaces , like the one in bei jing and london',
intent: 'my.test.intent.1',
entities: [
{
'entity': 'location',
'startPos': 9,
'endPos': 10
entity: 'location',
startPos: 9,
endPos: 10
},
{
'entity': 'location',
'startPos': 12,
'endPos': 12
entity: 'location',
startPos: 12,
endPos: 12
}

@@ -189,9 +189,9 @@ ]

{
'text': `symbols everywhere! ºª\\!|"@·#$%&¬/()=?¿'¡^\`<>,;.:-_¨*+ london`,
'intent': 'my.test.intent.1',
'entities': [
text: `symbols everywhere! ºª\\!|"@·#$%&¬/()=?¿'¡^\`<>,;.:-_¨*+ london`,
intent: 'my.test.intent.1',
entities: [
{
'entity': 'location',
'startPos': 36,
'endPos': 36
entity: 'location',
startPos: 36,
endPos: 36
}

@@ -201,9 +201,9 @@ ]

{
'text': 'Çç vayÁ cÓn Úna eÑes en Éspaña no son gÜenas nÍ cigüenas en parÍs',
'intent': 'my.test.intent.1',
'entities': [
text: 'Çç vayÁ cÓn Úna eÑes en Éspaña no son gÜenas nÍ cigüenas en parÍs',
intent: 'my.test.intent.1',
entities: [
{
'entity': 'location',
'startPos': 13,
'endPos': 13
entity: 'location',
startPos: 13,
endPos: 13
}

@@ -220,9 +220,9 @@ ]

{
'text': 'çç vayá cón úna eñes en éspaña no son güenas ní cigüenas en parís',
'intent': 'my.test.intent.1',
'entities': [
text: 'çç vayá cón úna eñes en éspaña no son güenas ní cigüenas en parís',
intent: 'my.test.intent.1',
entities: [
{
'entity': 'location',
'startPos': 13,
'endPos': 13
entity: 'location',
startPos: 13,
endPos: 13
}

@@ -239,9 +239,9 @@ ]

{
'text': 'this is the country spain',
'intent': 'my.test.intent',
'entities': [
text: 'this is the country spain',
intent: 'my.test.intent',
entities: [
{
'entity': 'country',
'startPos': 4,
'endPos': 4
entity: 'country',
startPos: 4,
endPos: 4
}

@@ -251,9 +251,9 @@ ]

{
'text': 'this is the country france',
'intent': 'my.test.intent',
'entities': [
text: 'this is the country france',
intent: 'my.test.intent',
entities: [
{
'entity': 'country',
'startPos': 4,
'endPos': 4
entity: 'country',
startPos: 4,
endPos: 4
}

@@ -263,60 +263,60 @@ ]

{
'text': 'this is the country spain',
'intent': 'my.test.expansion',
'entities': []
text: 'this is the country spain',
intent: 'my.test.expansion',
entities: []
},
{
'text': 'this is the country france',
'intent': 'my.test.expansion',
'entities': []
text: 'this is the country france',
intent: 'my.test.expansion',
entities: []
},
{
'text': 'this is the color red',
'intent': 'my.test.expansion',
'entities': []
text: 'this is the color red',
intent: 'my.test.expansion',
entities: []
},
{
'text': 'this is the color blue',
'intent': 'my.test.expansion',
'entities': []
text: 'this is the color blue',
intent: 'my.test.expansion',
entities: []
},
{
'text': 'this is the red spain',
'intent': 'my.test.expansion',
'entities': []
text: 'this is the red spain',
intent: 'my.test.expansion',
entities: []
},
{
'text': 'this is the blue spain',
'intent': 'my.test.expansion',
'entities': []
text: 'this is the blue spain',
intent: 'my.test.expansion',
entities: []
},
{
'text': 'this is the red france',
'intent': 'my.test.expansion',
'entities': []
text: 'this is the red france',
intent: 'my.test.expansion',
entities: []
},
{
'text': 'this is the blue france',
'intent': 'my.test.expansion',
'entities': []
text: 'this is the blue france',
intent: 'my.test.expansion',
entities: []
},
{
'text': 'this is the spain spain',
'intent': 'my.test.expansion',
'entities': []
text: 'this is the spain spain',
intent: 'my.test.expansion',
entities: []
},
{
'text': 'this is the spain france',
'intent': 'my.test.expansion',
'entities': []
text: 'this is the spain france',
intent: 'my.test.expansion',
entities: []
},
{
'text': 'this is the france spain',
'intent': 'my.test.expansion',
'entities': []
text: 'this is the france spain',
intent: 'my.test.expansion',
entities: []
},
{
'text': 'this is the france france',
'intent': 'my.test.expansion',
'entities': []
text: 'this is the france france',
intent: 'my.test.expansion',
entities: []
}

@@ -328,7 +328,11 @@ ];

let parser = new parser_1.LanguageModelParser();
let luisModel = parser.parse(['./test/fixtures/en-features.yaml'], 'en-us');
let yamls = [
'./test/fixtures/en-features-1.yaml',
'./test/fixtures/en-features-2.yaml'
];
let luisModel = parser.parse(yamls, 'en-us');
let expectedModelFeatures = [
{
name: 'strange',
words: `hola - caracola,Hola _ caracola,I ' d like,2º floor,Que tAl`,
words: 'hola - caracola,Hola _ caracola,I \' d like,2º floor,Que tAl',
activated: true,

@@ -339,5 +343,11 @@ mode: true

name: 'numbers',
words: `123,123 123`,
words: '123,123 123',
activated: true,
mode: true
},
{
name: 'anotherlist',
words: 'Cercei,Walder Frey,Melisandre',
activated: true,
mode: true
}

@@ -351,12 +361,12 @@ ];

let expectedBingEntities = [
"age",
"datetime",
"dimension",
"encyclopedia",
"geography",
"money",
"number",
"ordinal",
"percentage",
"temperature"
'age',
'datetime',
'dimension',
'encyclopedia',
'geography',
'money',
'number',
'ordinal',
'percentage',
'temperature'
];

@@ -363,0 +373,0 @@ chai_1.expect(luisModel.bing_entities).to.eql(expectedBingEntities);

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

@@ -5,0 +5,0 @@ "license": "UNLICENSED",

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