word-frequency-counter
Version:
21 lines (20 loc) • 806 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.punctuationRemover = void 0;
const uuid_1 = require("@henrypenton/uuid");
const protection_1 = require("../../protection/protection");
const removePunctuation = (text) => text
.toLowerCase()
.replace(/\//g, " ")
.replace(/[\r\n]/gm, " ")
.replace(/[^\w\s]/g, "");
const punctuationRemover = (text, config) => {
let content = text;
const { protectionList } = config;
const protection = new protection_1.Protection(protectionList, () => (0, uuid_1.generateNewId)(false));
content = protection.addWordProtection(content);
content = removePunctuation(content);
content = protection.removeWordProtection(content);
return content;
};
exports.punctuationRemover = punctuationRemover;