Getting Started
𧰠Learn about individual Toolkitsâ
Here's a quick start guide to help you get started with the Bangla Toolkit (BNTK).
Installationâ
Install the required packages for Bengali natural language processing:
- npm
- Bun
- Yarn
- pnpm
npm install @bntk/tokenization @bntk/stemming @bntk/pos @bntk/ner @bntk/transliteration
bun add @bntk/tokenization @bntk/stemming @bntk/pos @bntk/ner @bntk/transliteration
yarn add @bntk/tokenization @bntk/stemming @bntk/pos @bntk/ner @bntk/transliteration
pnpm add @bntk/tokenization @bntk/stemming @bntk/pos @bntk/ner @bntk/transliteration
Example Usageâ
import * as ner from "@bntk/ner";
import * as pos from "@bntk/pos";
import * as stemming from "@bntk/stemming";
import * as tokenization from "@bntk/tokenization";
import * as transliteration from "@bntk/transliteration";
const contents = `āĻāĻŽāĻŋ āĻŦāĻžāĻāĻ˛āĻž āĻ˛ā§āĻāĻžāĻ° āĻāĻ¨ā§āĻ¯ āĻā§āĻ˛āĻŋāĻāĻ āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻāĻ°āĻāĻŋāĨ¤ āĻāĻŽāĻžāĻ° āĻŦāĻ¨ā§āĻ§ā§ āĻ°āĻšāĻŋāĻŽ āĻĸāĻžāĻāĻžāĻ¯āĻŧ āĻĨāĻžāĻā§āĻ¨āĨ¤`;
// ==== Tokenization ====
const sentences = tokenization.tokenizeSentences(contents);
console.log(sentences);
// ['āĻāĻŽāĻŋ āĻŦāĻžāĻāĻ˛āĻž āĻ˛ā§āĻāĻžāĻ° āĻāĻ¨ā§āĻ¯ āĻā§āĻ˛āĻŋāĻāĻ āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻāĻ°āĻāĻŋ', 'āĻāĻŽāĻžāĻ° āĻŦāĻ¨ā§āĻ§ā§ āĻ°āĻšāĻŋāĻŽ āĻĸāĻžāĻāĻžāĻ¯āĻŧ āĻĨāĻžāĻā§āĻ¨']
const words = tokenization.tokenizeWords(sentences[0]);
console.log(words);
// ['āĻāĻŽāĻŋ', 'āĻŦāĻžāĻāĻ˛āĻž', 'āĻ˛ā§āĻāĻžāĻ°', 'āĻāĻ¨ā§āĻ¯', 'āĻā§āĻ˛āĻŋāĻāĻ', 'āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ°', 'āĻāĻ°āĻāĻŋ']
// ==== Stemming ====
const stemmedWords = stemming.stemWords(words);
console.log(stemmedWords);
// ['āĻāĻŽāĻŋ', 'āĻŦāĻžāĻāĻ˛āĻž', 'āĻ˛ā§āĻāĻžāĻ°', 'āĻāĻ¨ā§āĻ¯', 'āĻā§āĻ˛āĻŋāĻāĻ', 'āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ°', 'āĻāĻ°āĻāĻŋ']
// ==== POS ====
const taggedWords = pos.tagWords(stemmedWords);
console.log(taggedWords);
// ['āĻāĻŽāĻŋ/PRON', 'āĻŦāĻžāĻāĻ˛āĻž/NOUN', 'āĻ˛ā§āĻāĻžāĻ°/NOUN', 'āĻāĻ¨ā§āĻ¯/ADP', 'āĻā§āĻ˛āĻŋāĻāĻ/NOUN', 'āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ°/VERB', 'āĻāĻ°āĻāĻŋ/VERB']
// ==== NER ====
const entities = ner.extractEntities(sentences[1]);
console.log(entities);
// [{type: 'PRONOUN', value: 'āĻāĻŽāĻžāĻ°', start: 0, end: 4}, {...}]
// ==== Transliteration ====
const transliterated = transliteration.transliterate("amar name apon.");
console.log(transliterated);
// 'āĻāĻŽāĻžāĻ° āĻ¨āĻžāĻŽ āĻāĻĒāĻ¨āĨ¤'