UNPKG

@bntk/pos

Version:

Build applications with Bengali natural language processing tools.

50 lines (49 loc) 1.28 kB
// packages/core/pos/src/index.ts console.log("@bntk/pos"); var UniversalPOSTag; ((UniversalPOSTag2) => { UniversalPOSTag2["ADJ"] = "ADJ"; UniversalPOSTag2["ADP"] = "ADP"; UniversalPOSTag2["ADV"] = "ADV"; UniversalPOSTag2["AUX"] = "AUX"; UniversalPOSTag2["CCONJ"] = "CCONJ"; UniversalPOSTag2["DET"] = "DET"; UniversalPOSTag2["INTJ"] = "INTJ"; UniversalPOSTag2["NOUN"] = "NOUN"; UniversalPOSTag2["NUM"] = "NUM"; UniversalPOSTag2["PART"] = "PART"; UniversalPOSTag2["PRON"] = "PRON"; UniversalPOSTag2["PROPN"] = "PROPN"; UniversalPOSTag2["PUNCT"] = "PUNCT"; UniversalPOSTag2["SCONJ"] = "SCONJ"; UniversalPOSTag2["SYM"] = "SYM"; UniversalPOSTag2["VERB"] = "VERB"; UniversalPOSTag2["X"] = "X"; })(UniversalPOSTag ||= {}); function tagWord(word) { return { word, tag: "NOUN" /* NOUN */ }; } function tagWords(words) { return words.map((word) => tagWord(word)); } function tagText(text) { const words = text.split(/\s+/); return tagWords(words); } function getPOSTagFrequencies(taggedWords) { const frequencies = new Map; for (const { tag } of taggedWords) { frequencies.set(tag, (frequencies.get(tag) || 0) + 1); } return frequencies; } export { tagWords, tagWord, tagText, getPOSTagFrequencies, UniversalPOSTag };