-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: NLP module strict null checks issues #544
fix: NLP module strict null checks issues #544
Conversation
dbf80b0
to
542a02a
Compare
@@ -151,7 +151,7 @@ export default abstract class BaseNlpHelper< | |||
}) | |||
.concat({ | |||
entity: 'language', | |||
value: s.language.code, | |||
value: s.language!.code, | |||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't language supposed to be mandatory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yassinedorbozgithub @MohamedAliBouhaouala Can we open a Issue to force the user to set the language for each sample ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue created ✅ #561
…into 540-issue-nlp-module-strictnullchecks-issues
@@ -151,7 +151,7 @@ export default abstract class BaseNlpHelper< | |||
}) | |||
.concat({ | |||
entity: 'language', | |||
value: s.language.code, | |||
value: s.language!.code, | |||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yassinedorbozgithub @MohamedAliBouhaouala Can we open a Issue to force the user to set the language for each sample ?
@@ -117,11 +121,11 @@ describe('NlpSampleService', () => { | |||
|
|||
describe('findOneAndPopulate', () => { | |||
it('should return a nlp Sample with populate', async () => { | |||
const result = await nlpSampleService.findOneAndPopulate(noNlpSample.id); | |||
const result = await nlpSampleService.findOneAndPopulate(noNlpSample!.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May encounter the risk of passing 'undefined' as a queried value.
@@ -167,7 +172,7 @@ describe('NlpSampleService', () => { | |||
|
|||
describe('The deleteCascadeOne function', () => { | |||
it('should delete a nlp Sample', async () => { | |||
const result = await nlpSampleService.deleteOne(noNlpSample.id); | |||
const result = await nlpSampleService.deleteOne(noNlpSample!.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same remark as above
@@ -128,15 +128,15 @@ export class NlpValueService extends BaseService< | |||
if ('start' in e && 'end' in e) { | |||
const word = sampleText.slice(e.start, e.end); | |||
return ( | |||
word !== e.value && vMap[e.value].expressions.indexOf(word) === -1 | |||
word !== e.value && vMap[e.value].expressions?.indexOf(word) === -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may encounter the risk of indexing an undefined object
); | ||
} | ||
return false; | ||
}) | ||
.map((e) => { | ||
return this.updateOne(vMap[e.value].id, { | ||
...vMap[e.value], | ||
expressions: vMap[e.value].expressions.concat([ | ||
expressions: vMap[e.value].expressions?.concat([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may encounter the risk of concatenating undefined objects
Hi @MohamedAliBouhaouala, i have used the ! symbol as an optimistic strategy inside the .spec.ts files |
Motivation
The motivation of this PR is to resolve NLP Module null checks issues
Fixes #540
Checklist: