This repository has been archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Missing acute in french in self harm2084 #2182
Closed
Closed
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9ce6b63
Fix french sentence mismatch between tile and report content in PR2084
dengcn 15de80a
Fix to Missing accute Missing acute accent in self harm word section …
dengcn 6db4c08
Clean some code warning
dengcn 85daaf9
Merge branch 'master' into missingAcuteInFrenchInSelfHarm2084
DianeLiu2019 1e979bc
Merge branch 'master' into missingAcuteInFrenchInSelfHarm2084
DianeLiu2019 da064ce
Merge branch 'master' into missingAcuteInFrenchInSelfHarm2084
DianeLiu2019 9656309
Merge branch 'master' into missingAcuteInFrenchInSelfHarm2084
dengcn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,8 @@ const { getLogger } = require('./winstonLogger') | |
const logger = getLogger(__filename) | ||
|
||
const selfHarmString = process.env.SELF_HARM_WORDS || 'agilé, lean, mvp, scrum' | ||
const selfHarmWords = selfHarmString | ||
.split(',') | ||
.map((w) => unidecode(w.trim().toLowerCase())) | ||
const selfHarmWords = selfHarmString.split(',') | ||
|
||
logger.info(`Self harm word list: ${selfHarmWords}`) | ||
|
||
//Scan form data for self harm key words. | ||
|
@@ -47,24 +46,36 @@ const selfHarmWordsScan = (data) => { | |
//Scan String for key words. Tokenize and stem to identify root words. | ||
const scanString = (str) => { | ||
try { | ||
let modifiedStr = unidecode(str.toLowerCase()) | ||
let modifiedStr = str | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why declare a variable that has the same value as the param? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the original copy of data, since modifiedStr will be heavily changed or regrouped in the following code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can consolidate these 2 variables, any others? |
||
|
||
modifiedStr = modifiedStr | ||
.replace(/\r?\n|\r/g, ' ') //Remove newline characters | ||
.replace(/[^\w\s']|_/g, ' ') //Remove special characters | ||
.replace(/\s+/g, ' ') //Remove any extra sapaces | ||
|
||
//Attempt to get root for words in String. | ||
const formTokens = modifiedStr.tokenizeAndStem() | ||
modifiedStr = modifiedStr + ', ' + formTokens.toString() | ||
|
||
let wordsUsed = '' | ||
let wordsUsedArray = [] | ||
let key_name_nl | ||
normalizedModifiedStr = modifiedStr | ||
.toLowerCase() | ||
.normalize('NFD') | ||
.replace(/[\u0300-\u036f]/g, '') | ||
for (var key_nl in selfHarmWords) { | ||
key_name_nl = selfHarmWords[key_nl] | ||
.normalize('NFD') | ||
.replace(/[\u0300-\u036f]/g, '') | ||
.toLowerCase() | ||
if (normalizedModifiedStr.includes(key_name_nl) && key_name_nl !== '') { | ||
if (selfHarmWords[key_nl] !== '') { | ||
wordsUsedArray.push(selfHarmWords[key_nl].toLowerCase()) | ||
} | ||
} | ||
} | ||
|
||
//Create one String with both original and stemmed words. | ||
modifiedStr = modifiedStr + ' ' + formTokens.toString().replace(/,/g, ' ') | ||
|
||
//Compare text to the list of key words. | ||
const wordsUsed = selfHarmWords.filter((w) => { | ||
const regEx = new RegExp('\\b' + w + '\\b') | ||
return regEx.test(modifiedStr) | ||
}) | ||
wordsUsed = wordsUsedArray.toString() | ||
|
||
return wordsUsed | ||
} catch (err) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Where did this translation come from?
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.
Coming from Harm Word in title already defined and used, and PR raiser wish this the same as title