Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 2b57f20

Browse files
authored
Merge branch 'master' into munozemilio/updatehack
2 parents 9b8e086 + c068d8d commit 2b57f20

File tree

24 files changed

+641
-66
lines changed

24 files changed

+641
-66
lines changed

packages/chatdown/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ EXAMPLES
4242
$ bf chatdown --in=./path/to/file/sample.chat --out=./
4343
$ bf chatdown -i ./path/to/file/*.sample.chat -o ./
4444
$ bf chatdown -i=./path/to/file/*.sample.chat -o=./
45+
$ bf chatdown --in ./path/to/directory
46+
$ bf chatdown --in ./path/to/directory/*
4547
$ (echo user=Joe && [ConversationUpdate=MembersAdded=Joe]) | bf chatdown --static
4648
```
4749

packages/chatdown/src/commands/chatdown.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export default class Chatdown extends Command {
4141

4242
if (inputIsDirectory) {
4343
let inputDir = flags.in ? flags.in.trim() : ''
44-
4544
const len = await this.processFiles(inputDir, outputDir)
4645
if (len === 0) {
4746
throw new CLIError('No chat files found at: ' + flags.in)
@@ -93,14 +92,36 @@ export default class Chatdown extends Command {
9392
}
9493
}
9594

95+
private getFiles(directoryPath: any) {
96+
return new Promise((resolve, reject) => {
97+
let fileList: any = []
98+
fs.readdir(directoryPath, (err: any, files: any) => {
99+
if (err) {
100+
reject('Error scanning directory' + err)
101+
}
102+
fileList = files.map((file: any) => path.join(directoryPath, file))
103+
resolve(fileList)
104+
})
105+
})
106+
}
107+
96108
private getFileName(file: any) {
97109
let fileName = path.basename(file, path.extname(file))
98110
return fileName
99111
}
100112

101113
private async processFiles(inputDir: any, outputDir: any) {
102114
return new Promise(async (resolve, reject) => {
103-
let files = glob.sync(inputDir, {ignore: ['**/node_modules/**']})
115+
let files: any = []
116+
if (inputDir.indexOf('*') > -1) {
117+
files = glob.sync(inputDir, {ignore: ['**/node_modules/**']})
118+
} else {
119+
try {
120+
files = await this.getFiles(inputDir)
121+
} catch (err) {
122+
reject(new CLIError(`Failed to scan directory ${err}`))
123+
}
124+
}
104125
/* tslint:disable:prefer-for-of */
105126
for (let i = 0; i < files.length; i++) {
106127
try {

packages/chatdown/test/commands/chatdown.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ describe('chatdown', () => {
4444
});
4545

4646
it('should read from file when chat file is passed as an argument', done => {
47-
cp.exec(`node ./bin/run chatdown --in ./test/utils/cli.sample.chat`, (error, stdout) => {
47+
cp.exec(`node ./bin/run chatdown --in "./test/utils/cli.sample.chat"`, (error, stdout) => {
4848
assert.doesNotThrow(() => JSON.parse(stdout));
4949
done();
5050
});
5151
});
5252

5353
it('should process all files when a glob is passed in with the -i argument, and the -o is passed in for the output directory', done => {
54-
cp.exec(`node ./bin/run chatdown -i ./test/utils/*.sample.chat -o ./`, (error, stdout, stderr) => {
54+
cp.exec(`node ./bin/run chatdown -i "./test/utils/*.sample.chat" -o ./`, (error, stdout, stderr) => {
5555
assert(stdout.includes('Successfully wrote'));
5656
done();
5757
});
5858
});
5959

6060
it('should process all files when a glob is passed in with the -i argument', done => {
61-
cp.exec(`node ./bin/run chatdown -i ./test/utils/*.sample.chat`, (error, stdout, stderr) => {
61+
cp.exec(`node ./bin/run chatdown -i "./test/utils/*.sample.chat"`, (error, stdout, stderr) => {
6262
assert(stdout.includes('Successfully wrote'));
6363
done();
6464
});
@@ -79,7 +79,7 @@ describe('chatdown', () => {
7979
});
8080

8181
it('throw error if invalid path in argument', done => {
82-
cp.exec(`node ./bin/run chatdown --in aaaaa`, (error, stdout, stderr) => {
82+
cp.exec(`node ./bin/run chatdown --in 'aaaaa'`, (error, stdout, stderr) => {
8383
assert(stderr.includes('no such file or directory') || stderr.includes('error'));
8484
done();
8585
});

packages/lu/docs/lu-file-format.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ The following LUIS prebuilt entity types are supported -
133133
- ordinalV2
134134
- percentage
135135
- personName
136-
- phoneNumber
136+
- phonenumber
137137
- temperature
138138
- url
139139
- datetime

packages/lu/src/commands/luis/convert.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ export default class LuisConvert extends Command {
5050
// Add headers to Luis Json
5151
if (isLu) {
5252
result.luis_schema_version = flags.schemaversion || result.luis_schema_version || '3.2.0'
53-
result.versionId = flags.versionId || result.versionId || '0.1'
53+
result.versionId = flags.versionid || result.versionId || '0.1'
5454
result.name = flags.name || result.name || ''
55-
result.desc = flags.desc || result.desc || ''
55+
result.desc = flags.description || result.desc || ''
5656
result.culture = flags.culture || result.culture || 'en-us'
5757
result.culture = result.culture.toLowerCase()
5858
result = JSON.stringify(result, null, 2)

packages/lu/src/parser/converters/luistoluconverter.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,13 @@ module.exports = {
126126
}
127127

128128
if(LUISJSON.model_features && LUISJSON.model_features.length >= 0) {
129-
fileContent += '> # Phrase list definitions' + NEWLINE + NEWLINE;
130-
LUISJSON.model_features.forEach(function(entity) {
131-
fileContent += `@ phraselist ${entity.name}${(entity.mode ? `(interchangeable)` : ``)}`;
132-
if (entity.words && entity.words !== '') {
133-
fileContent += ` = ${NEWLINE}\t- ${entity.words}`;
134-
}
135-
fileContent += NEWLINE + NEWLINE;
136-
});
137-
fileContent += NEWLINE;
129+
fileContent += handlePhraseLists(LUISJSON.model_features);
138130
}
131+
132+
if(LUISJSON.phraselists && LUISJSON.phraselists.length >= 0) {
133+
fileContent += handlePhraseLists(LUISJSON.phraselists);
134+
}
135+
139136
if(LUISJSON.closedLists && LUISJSON.closedLists.length >= 0){
140137
fileContent += '> # List entities' + NEWLINE + NEWLINE;
141138
LUISJSON.closedLists.forEach(function(ListItem) {
@@ -188,6 +185,24 @@ module.exports = {
188185
return fileContent;
189186
}
190187
}
188+
189+
/**
190+
* Helper to handle phrase lists both in the new and old property.
191+
* @param {Object[]} collection
192+
*/
193+
const handlePhraseLists = function(collection) {
194+
let fileContent = '> # Phrase list definitions' + NEWLINE + NEWLINE;
195+
collection.forEach(function(entity) {
196+
fileContent += `@ phraselist ${entity.name}${(entity.mode ? `(interchangeable)` : ``)}`;
197+
if (entity.words && entity.words !== '') {
198+
fileContent += ` = ${NEWLINE}\t- ${entity.words}`;
199+
}
200+
fileContent += NEWLINE + NEWLINE;
201+
});
202+
fileContent += NEWLINE;
203+
204+
return fileContent;
205+
}
191206
/**
192207
* Helper to add application inforamtion metadata
193208
* @param {Object} LUISJSON
@@ -234,7 +249,7 @@ const addNDepthChildDefinitions = function(childCollection, tabStop, fileContent
234249
myFileContent += addRolesAndFeatures(child);
235250
myFileContent += NEWLINE;
236251
if (child.children && child.children.length !== 0) {
237-
myFileContent += addNDepthChildDefinitions(child.children, ++tabStop, myFileContent);
252+
myFileContent += addNDepthChildDefinitions(child.children, tabStop + 1, myFileContent);
238253
}
239254
});
240255
return myFileContent;

packages/lu/src/parser/converters/lutoluisconverter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ const checkAndUpdateVersion = function(finalLUISJSON) {
266266
(finalLUISJSON.intents || []).find(i => i.features) ||
267267
(finalLUISJSON.composites || []).find(i => i.features);
268268
if (v5DefFound) {
269-
finalLUISJSON.luis_schema_version = "5.0.0";
269+
finalLUISJSON.luis_schema_version = "6.0.0";
270270
if (finalLUISJSON.model_features && finalLUISJSON.model_features.length !== 0) {
271271
finalLUISJSON.phraselists = [];
272272
finalLUISJSON.model_features.forEach(item => finalLUISJSON.phraselists.push(Object.assign({}, item)));

packages/lu/src/parser/lufile/classes/filesToParse.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,4 @@ class FileToParse {
1616
}
1717
}
1818

19-
FileToParse.stringArrayToFileToParseList = function(obj) {
20-
if(Array.isArray(obj)) return obj.map(item => new FileToParse(item));
21-
}
22-
2319
module.exports = FileToParse;

packages/lu/src/parser/lufile/classes/hclasses.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,21 @@ const readerObj = {
132132
}
133133
},
134134
featureToModel: class {
135-
constructor(name) {
135+
constructor(name, featureType) {
136136
this.featureName = name ? name : '';
137+
this.featureType = featureType ? featureType : '';
137138
}
138139
},
139140
modelToFeature: class {
140-
constructor(name) {
141+
constructor(name, featureType) {
141142
this.modelName = name ? name : '';
143+
this.modelType = featureType ? featureType : '';
142144
}
143145
},
144146
childEntity: class {
145147
constructor(name, instanceOf, context, children, features) {
146148
this.name = name ? name : '';
147-
this.instanceOf = instanceOf ? instanceOf : '';
149+
this.instanceOf = instanceOf ? instanceOf : null;
148150
this.children = children ? children : [];
149151
this.features = features ? features : '';
150152
this.context = context ? context : '';

packages/lu/src/parser/lufile/enums/luisbuiltintypes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
"ordinalV2",
1717
"percentage",
1818
"personName",
19-
"phoneNumber",
19+
"phonenumber",
2020
"temperature",
2121
"url",
2222
"datetime"
@@ -114,7 +114,7 @@ module.exports = {
114114
"ordinalV2": null,
115115
"percentage": null,
116116
"personName": null,
117-
"phoneNumber": null,
117+
"phonenumber": null,
118118
"temperature": null,
119119
"url": null,
120120
"datetime": null

0 commit comments

Comments
 (0)