@@ -213,15 +213,15 @@ const resolveNewUtterancesAndPatterns = function(luisModel, allParsedContent, ne
213213 let filter = parsedUtterance . ref . endsWith ( '?' ) ? filterQuestionMarkRef : filterLuisContent
214214
215215 // find the parsed file
216- let result = filter ( allParsedContent , parsedUtterance , luisModel )
216+ let result = filter ( allParsedContent , parsedUtterance , luisModel , utterance )
217217
218218 result . utterances . forEach ( ( utr ) => newUtterancesToAdd . push ( new hClasses . uttereances ( utr , utterance . intent ) ) )
219219 result . patterns . forEach ( ( it ) => newPatternsToAdd . push ( new hClasses . pattern ( it , utterance . intent ) ) )
220220 spliceList . push ( idx )
221221 } ) ;
222222}
223223
224- const filterQuestionMarkRef = function ( allParsedContent , parsedUtterance , luisModel ) {
224+ const filterQuestionMarkRef = function ( allParsedContent , parsedUtterance , luisModel , utterance ) {
225225 let result = {
226226 utterances : [ ] ,
227227 patterns : [ ]
@@ -231,35 +231,28 @@ const filterQuestionMarkRef = function(allParsedContent, parsedUtterance, luisMo
231231 return result
232232 }
233233
234+ let parsedQnABlobs
234235 if ( parsedUtterance . luFile . endsWith ( '*' ) ) {
235- let parsedQnABlobs = ( allParsedContent . QnAContent || [ ] ) . filter ( item => item . srcFile . includes ( parsedUtterance . luFile . replace ( / \* / g, '' ) ) ) ;
236- if ( ! parsedQnABlobs ) {
237- let error = BuildDiagnostic ( {
238- message : `Unable to parse ${ utterance . text } in file: ${ luisModel . srcFile } `
239- } ) ;
240-
241- throw ( new exception ( retCode . errorCode . INVALID_INPUT , error . toString ( ) ) ) ;
242- }
236+ parsedQnABlobs = ( allParsedContent . QnAContent || [ ] ) . filter ( item => item . srcFile . includes ( parsedUtterance . luFile . replace ( / \* / g, '' ) ) ) ;
237+ } else {
238+ // look for QnA
239+ parsedQnABlobs = [ ]
240+ parsedQnABlobs . push ( ( allParsedContent . QnAContent || [ ] ) . find ( item => item . srcFile == parsedUtterance . luFile ) ) ;
241+ }
243242
244- parsedQnABlobs . forEach ( blob => blob . qnaJsonStructure . qnaList . forEach ( item => item . questions . forEach ( question => result . utterances . push ( question ) ) ) ) ;
245- return result
246- }
247- // look for QnA
248- let parsedQnABlob = ( allParsedContent . QnAContent || [ ] ) . find ( item => item . srcFile == parsedUtterance . luFile ) ;
249- if ( ! parsedQnABlob ) {
243+ if ( ! parsedQnABlobs || ! parsedQnABlobs [ 0 ] ) {
250244 let error = BuildDiagnostic ( {
251245 message : `Unable to parse ${ utterance . text } in file: ${ luisModel . srcFile } `
252246 } ) ;
253247
254248 throw ( new exception ( retCode . errorCode . INVALID_INPUT , error . toString ( ) ) ) ;
255249 }
256250
257- // get questions list from .lu file and update list
258- parsedQnABlob . qnaJsonStructure . qnaList . forEach ( item => item . questions . forEach ( question => result . utterances . push ( question ) ) ) ;
251+ parsedQnABlobs . forEach ( blob => blob . qnaJsonStructure . qnaList . forEach ( item => item . questions . forEach ( question => result . utterances . push ( question ) ) ) ) ;
259252 return result
260253}
261254
262- const filterLuisContent = function ( allParsedContent , parsedUtterance , luisModel ) {
255+ const filterLuisContent = function ( allParsedContent , parsedUtterance , luisModel , utterance ) {
263256 let parsedLUISBlob = ( allParsedContent . LUISContent || [ ] ) . find ( item => item . srcFile == parsedUtterance . luFile ) ;
264257 if ( ! parsedLUISBlob ) {
265258 let error = BuildDiagnostic ( {
0 commit comments