UNPKG

word-frequency-counter

Version:
24 lines (23 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getUniqueSentenceComponents = exports.getSentenceComponents = void 0; const protection_1 = require("../protection/protection"); const uuid_1 = require("@henrypenton/uuid"); const punctuation_1 = require("../utils/punctuation/punctuation"); const getSentenceComponents = (text, config) => { const { protectionList } = config; const protection = new protection_1.Protection(protectionList, () => (0, uuid_1.generateNewId)(false)); let content = text; content = protection.addWordProtection(content); const sentenceComponents = (0, punctuation_1.punctuationRemover)(content, config).split(" "); const unprotectedSentenceComponents = []; for (const sentenceComponent of sentenceComponents) { unprotectedSentenceComponents.push(protection.removeWordProtection(sentenceComponent)); } return unprotectedSentenceComponents.filter((component) => component !== ""); }; exports.getSentenceComponents = getSentenceComponents; const getUniqueSentenceComponents = (text, config) => { return new Set((0, exports.getSentenceComponents)(text, config)); }; exports.getUniqueSentenceComponents = getUniqueSentenceComponents;