Work

TUNI

A Bangla chatbot that talks like a psychologist, built from hand-written rules years before ChatGPT. How it works, one sentence at a time.

Role
Second author, KUET
Stack
Bangla NLP, POS tagging, Suffix analysis, Sentiment analysis, Rule-based dialogue
Year
2020
Status
Published, Springer Nature 2021
Links
SpringerResearchGate

Before ChatGPT, if you wanted a computer to hold a conversation in Bangla, there was no model to ask. You wrote the language down yourself, rule by rule. TUNI was our attempt at that at KUET: a conversational agent that plays a psychologist, listens to what you type in Bangla, and keeps the conversation going by asking you about it.

you আমি এখন পড়ালেখা করছি কারণ আমি সিজিপিএ বাড়াতে চাই “I am studying now because I want to raise my CGPA.”
TUNI আপনি কি সিজিপিএ নিয়ে চিন্তিত? “Are you worried about your CGPA?”
The example the paper follows from start to finish. Every figure below is this one sentence at a different stage.

That reply looks simple. To produce it, TUNI had to split the sentence in two, decide which half mattered, find the one word carrying the meaning, pick a rule that fits the grammar, pull out the right pieces, and then flip I into a polite you without breaking the verb. This page walks through how, using the paper’s own example.

Why Bangla is the hard part

TUNI is a descendant of ELIZA, the 1966 program by Joseph Weizenbaum that also played a therapist. ELIZA’s trick was simple: look for a keyword, cut the sentence around it with a pattern, and paste the pieces into a canned reply, swapping I for you on the way.

That trick barely survives the trip to Bangla. In English the verb hardly changes with the person: I go, you go. In Bangla the ending of the verb changes with the person, and the second person alone has three levels of formality. Pronouns change with them. So turning I into you is not a word swap. It is a rewrite of every word that agrees with the speaker.

One verb, four persons
যাচ্ছি I am going first person
যাচ্ছেন you / he is going formal
যাচ্ছো you are going familiar
যাচ্ছিস you are going intimate
TUNI’s person map, a few rows
শুনিনি → শুনেননি
জানতাম → জানতেন
বলবো → বলবেন
চল → চলেন
আমাকে → তোমাকে
Left: the same verb in four persons. Right: a few rows of TUNI's person-mapping dataset, which rewrites endings and pronouns when the reply needs a different speaker.

So plain keyword matching was not enough. The approach we took was ELIZA’s shape, pattern matching with keywords, rebuilt on top of Bangla part-of-speech tags, suffix tags, a person map and a very small sentiment check.

What TUNI knows

Everything TUNI knows lives in plain data files, so changing its behaviour means editing data, not code. There is one corpus and five datasets.

The corpus holds the conversation rules. Each entry has four parts:

  • a keyword: a Bangla word, or a POS tag, that can anchor a sentence
  • a precedence: a number we set by hand for how important that keyword is in a sentence
  • decomposition rules: patterns that must be present in the sentence, written as POS tags, exact words, sentiment tags, or a mix
  • reassembly rules: reply templates for each decomposition rule, with numbered slots for the pieces the pattern pulled out
Keyword চাই precedence 4
Decomposition rules, tried in order
1. p, "হতে", adj needs the word হতে
2. p, noun, v.0 pronoun + noun + non-finite verb
Reassembly rules revPer_1 কি 2 নিয়ে চিন্তিত? …and more, used in rotation
3. p, noun/p pronoun + noun or pronoun
4. - matches anything, the fallback
One real corpus entry, for the keyword চাই (“want”). Four decomposition rules are tried in order; the second one owns the reply template used in our example.

The datasets hold the language knowledge the rules depend on:

DatasetWhat it mapsExample
POS tagsword → part of speechআমার → p.1 (first-person pronoun)
Suffix tagsending → suffix classকরিমের → er
Person mapending or pronoun → its other-person formবলবো → বলবেন
PosNegword → positive, negative or neutralসুখ → p, খারাপ → n
Sentence dividerswords that join clausesকারণ, তবুও, যখন, তাহলে, comma, ।

The POS set is small on purpose. To see the shape of a sentence you mostly need nouns, pronouns, verbs and adjectives, plus which person a pronoun or verb is in. A special ign tag marks words that carry no meaning for the reply.

Following one sentence

Here is the whole pipeline. The first four steps clean the sentence up; the last four work out what it means and answer it. Click a step to jump to it.

Bangla text in ↓
Looked up along the way: CorpusPOS tagsSuffix tagsPerson mapPosNegSentence dividers
↓ Bangla reply out
TUNI's pipeline, from the flowchart in the paper.

1. Clean and tokenize

Extra spaces are collapsed, the ends are trimmed, and a space goes in front of every punctuation mark. After that, Bangla tokenization is the easy part: words are separated by spaces, so splitting on spaces gives the token list.

Token list
আমি
এখন
পড়ালেখা
করছি
কারণ
আমি
সিজিপিএ
বাড়াতে
চাই

2. Split into sub-sentences

A reply can only be about one thing, so TUNI only allows one focus per sentence. Compound sentences are cut at any word or mark from the sentence-divider dataset. Here that word is কারণ, “because”.

Cut at কারণ
আমি
এখন
পড়ালেখা
করছি
আমি
সিজিপিএ
বাড়াতে
চাই

3. Tag every word

Each token gets its POS tag from the dataset. Nouns, pronouns and verbs also get a suffix tag, which later tells TUNI how to find the stem and how to change the ending. The format is pos.person.suffix.

আমি p.1.null
এখন ign
পড়ালেখা noun.null
করছি v.1
আমি p.1.null
সিজিপিএ noun.null
বাড়াতে v.0
চাই v.1
p.1 is a first-person pronoun, v.1 a first-person verb, v.0 a non-finite verb. null means no suffix.

4. Drop the noise

Anything tagged ign is removed. এখন, “now”, changes nothing about what TUNI should ask next, so it goes.

আমি p.1
এখন ign
পড়ালেখা noun
করছি v.1
আমি p.1
সিজিপিএ noun
বাড়াতে v.0
চাই v.1

5. Find the focus

The focus is the single word that carries the sentence. Every token gets a precedence score from the corpus. A token in an inflected form often won’t be in the corpus as written, so the lookup falls back step by step: the word, then its stem, then its POS tag, then −1.

1 Is the word itself a keyword? → yes: use its precedence
2 Is its stem a keyword? → yes: use the stem’s precedence
3 Is its POS tag a keyword? → yes: use the tag’s precedence
4 None of the above → precedence −1
The keyword search, in the order the paper describes it.

The highest score wins, and only the sub-sentence holding it moves on. Here চাই, “want”, scores 4 and beats everything in the first half, so the reply will be about the wanting, not the studying.

আমি 1
পড়ালেখা 2
করছি 3
আমি 1
সিজিপিএ -1
বাড়াতে -1
চাই 4
Precedence values from the paper. চাই wins with 4; its sub-sentence becomes the new token list.

6. Match a rule

Now TUNI walks the decomposition rules under the focus keyword, top to bottom, and takes the first one whose conditions all appear in the token list. Extra tokens are fine; missing ones are not. Order matters: rule 3 would also match, but rule 2 is reached first.

1. p, "হতে", adj no হতে in the sentence no
2. p, noun, v.0 আমি, সিজিপিএ, বাড়াতে match
3. p, noun/p would match, but too late ·
4. - the fallback ·
Token list আমি p.1 সিজিপিএ noun বাড়াতে v.0 চাই v.1 · focus
Rules for চাই checked against the sub-sentence. The last rule, -, matches anything, so every keyword always has an answer.

Some rules also ask about mood. For those, TUNI looks up each word in the PosNeg dataset, scores positive words +1 and negative words −1, and multiplies. The result decides whether TUNI opens with something like বাহ! (“wow!”) or আমি দুঃখিত (“I’m sorry”). Multiplying instead of adding means two negatives cancel out, so “less sadness” reads as good news. Our example has no mood condition, so this step is skipped.

সুখ+1 = +1 positive
খারাপ−1 = −1 negative
দুঃখ−1×কম−1 = +1 positive
The basic sentiment check. Words not in the PosNeg dataset are ignored; no scored words means neutral.

7. Parse

The matched rule now acts as a cutter. Each condition grabs the token that satisfied it and stores it in a numbered dictionary, together with the focus. This is the information the reply is built from.

আমি [1] p
সিজিপিএ [2] noun
বাড়াতে [3] v.0
চাই focus
Rule p, noun, v.0 lifts three tokens out of the sentence.

8. Reassemble

The last step has three parts.

Pick a template. Each decomposition rule has several reassembly rules, and TUNI rotates through them, keeping a counter per rule. Say the same thing twice and you get a different question back, which is a big part of why it feels less like a machine.

Fill the slots. Numbers in the template are replaced with the parsed tokens. foc would insert the focus word.

Run the functions. Templates can call small functions on a slot before it is printed:

  • revPer flips the person of one word, using the person map
  • rev_all flips every person form in a phrase
  • addSuff[] adds or replaces a suffix
  • goto borrows replies from a similar keyword
Parsed dictionary
[1]pআমি
[2]nounসিজিপিএ
[3]v.0বাড়াতে
[foc]focusচাই
Rule
revPer_1 কি 2 নিয়ে চিন্তিত?
Place tokens
revPer_আমি কি সিজিপিএ নিয়ে চিন্তিত?
Run revPer: আমি → আপনি
আপনি কি সিজিপিএ নিয়ে চিন্তিত?
“Are you worried about your CGPA?”
From template to reply. revPer turns the speaker's আমি (“I”) into the polite আপনি (“you”).

And that is the reply from the top of the page. Nothing in it was generated. Every word is either the user’s own, rewritten for person, or part of a template we wrote.

Side by side with ELIZA

With almost no Bangla conversational agents to compare against, the paper puts TUNI next to ELIZA, the system it descends from, on the same six situations. Here are four. ELIZA’s replies are in English; TUNI’s are translated below each one.

ELIZA I can’t sleep from few days. Perhaps you can sleep from few days
TUNI আমি কিছুদিন থেকে ঘুমাতে পারছি না কেন আপনি ঘুমাতে পারছেন না? “Why can’t you sleep?”
ELIZA an accident has happened with me. What does that suggest to you?
TUNI আমার সাথে একটি দুর্ঘটনা ঘটেছে কি দুর্ঘটনা ঘটেছে আমি কি জানতে পারি? “May I know what accident happened?”
ELIZA my cousin died in front of me. Your cousin died in front of you?
TUNI আমার চাচাতো ভাই আমার সামনে মারা গেছে আমি দুঃখিত, আপনার চাচাতো ভাই কি আপনার খুব কাছের ছিল? “I’m sorry. Was your cousin very close to you?”
ELIZA he wants to buy a car I’m not sure I understand you fully.
TUNI সে গাড়ি কিনতে চায় কি হবে যদি সে গাড়ি কিনতে না পারে? “What if he can’t buy it?”
Inputs and replies from the comparison table in the paper. Translations of TUNI's replies are mine.

The first row is the clearest. ELIZA swaps the words and gets the meaning backwards. TUNI keeps the negation, moves the verb into the polite second person (পারছি → পারছেন), and asks why. The cousin row is what the expressions are for: ELIZA repeats the sentence back, TUNI opens with আমি দুঃখিত, “I’m sorry”, and asks about the person. In our tests TUNI’s replies were grammatically correct most of the time, which for Bangla was the hard part.

Looking back from the LLM era

Writing this in 2026, the striking thing is how much of what a language model now does silently we had to make explicit. Our tags, suffix classes, person map and precedence numbers are a hand-made version of what a model learns on its own from text. What TUNI could do, it did predictably: every reply traces back to one rule you can point at and edit. What it could not do was anything we had not written down. As the paper’s conclusion puts it, its quality was only ever as good as its tags and rules.

That trade-off has not gone away. When I build conversational agents now, including a real-time voice ordering agent in production, the model handles the language, and the work moves to the same questions TUNI forced on us: what is the user actually asking, what should the reply be about, and what must never come out wrong.


Paper. Md. Tareq Rahman Joy, Md. Nasib Shahriar Akash, K. M. Azharul Hasan. “An Intelligent Bangla Conversational Agent: TUNI.” In Proceedings of International Joint Conference on Advances in Computational Intelligence (IJCACI 2020), Algorithms for Intelligent Systems, Springer, Singapore, 2021, pp. 417–430. doi:10.1007/978-981-16-0586-4_34