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.
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.
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
1. p, "হতে", adj needs the word হতে 2. p, noun, v.0 pronoun + noun + non-finite verb revPer_1 কি 2 নিয়ে চিন্তিত? …and more, used in rotation 3. p, noun/p pronoun + noun or pronoun 4. - matches anything, the fallback The datasets hold the language knowledge the rules depend on:
| Dataset | What it maps | Example |
|---|---|---|
| POS tags | word → part of speech | আমার → p.1 (first-person pronoun) |
| Suffix tags | ending → suffix class | করিমের → er |
| Person map | ending or pronoun → its other-person form | বলবো → বলবেন |
| PosNeg | word → positive, negative or neutral | সুখ → p, খারাপ → n |
| Sentence dividers | words 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.
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.
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”.
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.
4. Drop the noise
Anything tagged ign is removed. এখন, “now”, changes nothing about what TUNI should ask next, so it goes.
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.
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.
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 · 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.
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.
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:
revPerflips the person of one word, using the person maprev_allflips every person form in a phraseaddSuff[]adds or replaces a suffixgotoborrows replies from a similar keyword
| [1] | p | আমি |
| [2] | noun | সিজিপিএ |
| [3] | v.0 | বাড়াতে |
| [foc] | focus | চাই |
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.
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