Created
November 12, 2021 14:53
-
-
Save yunusemre002/bb8bdf0e4a5d1739f29baa7bddec1c52 to your computer and use it in GitHub Desktop.
replace_punctuation_with_space.js
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
const punctuation = /[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\s]/g; | |
preprocessingWord = (word) => | |
word | |
.toLowerCase() // Convert all uppercase to lowercase | |
.replace(punctuation, ' ') // replace punctuation with space. | |
.replace(/ +/g, ' '); // Drop excess spaces. | |
// Example | |
let text = "BUNDAN SONRA NEFRET... SÖYLEMİ!;., SÖYLENMEYECEKTİR.,,,-." | |
console.log(preprocessingWord(text)); | |
// output: bundan sonra nefret söylemi̇ söylenmeyecekti̇r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment