CSI4001 · Natural Language Processing

Bharath

Class portfolio

Viterbi, edit distance, morphotactics and metaphor, worked through in Tamil, Malayalam, Hindi and English.

See the activities About me
Submitted to Prof. Dr. Sharmila Banu · VIT Vellore
Class activities

Activities

Seven entries: five class activities from CSI4001 and two notebooks from my GitHub. Where there is a working version, it is in the demos below.

  1. 1

    Introductory class

    Which languages I speak, answered in the first class.

  2. 2

    Edit distance

    The fewest insertions, deletions and substitutions that turn one string into another.

    In classTry the demo
  3. 3

    Viterbi

    Finding the most likely tag sequence for killer, crazy, clown, problem.

    In classTry the demo
  4. 4

    Morphotactics takeaway

    The order in which morphemes may combine into a word, shown with Tamil.

    In classTry the demo
  5. 5

    Metaphor activity

    Reading “His mind is a computer” as a metaphor, in four languages.

  6. 6

    Inaugural addresses

    Word clouds, counts and a comparison of five presidents, with NLTK.

    Notebook · 31 Jul 2026Read the notebook
  7. 7

    Name classifier and bag of words

    Naive Bayes on the last letter of a name, and cosine similarity between sentences.

    Notebook · 21 Aug 2026Read the notebook
Working versions

Demos

Small, runnable versions of the ideas above. Change the inputs and watch the result update.

Introductory class

Which languages do I speak?

Asked in the first class whether I am multilingual, I named four languages.

  • TAதமிழ்
  • MLമലയാളം
  • ENEnglish
  • HIहिन्दी
Edit distance · dynamic programming

Turning one word into another

Each cell holds the fewest edits between a prefix of the first word and a prefix of the second. Insert, delete and substitute each cost 1. The highlighted cells trace one cheapest route back from the bottom right.

Handwritten edit distance working
My handwritten working.Photo of my handwritten work goes here: img/edit-distance.jpeg
Viterbi · tagging

Tagging killer, crazy, clown, problem

The hidden states are the tags A (adjective) and N (noun); the words are what we see. Each column keeps, for each tag, the best score of any path that ends there.

Start: A 0.25, N 0.75A→N 1N→A 0.5, N→N 0.5 A emits crazy 1N emits clown 0.4, killer 0.3, problem 0.3
Handwritten Viterbi working
My handwritten working.Photo of my handwritten work goes here: img/viterbi.jpeg
Morphotactics · Tamil nouns

Building வீடு into a word

A Tamil noun stem can take a plural suffix, then a case suffix, in that order only. Choose the pieces, then try swapping the order.

Case
Handwritten morphotactics takeaway
My handwritten working.Photo of my handwritten work goes here: img/morphotactics.jpeg
Translation and metaphor

“His mind is a computer”

The same sentence in the four languages of this portfolio, and what the metaphor carries over.

  • ENHis mind is a computer.
  • TAஅவனுடைய மனம் ஒரு கணினி.
  • MLഅവന്റെ മനസ്സ് ഒരു കമ്പ്യൂട്ടറാണ്.
  • HIउसका मन एक कंप्यूटर है।
Mind (target) from computer (source)
  • Remembering←retrieving stored data
  • Thinking←processing
  • Learning←writing new information to memory
  • Left out·feeling, intuition, forgetting by accident
Notebook · 31 Jul 2026 · NLTK

Inaugural addresses

Stop words and punctuation are removed first. In Obama’s 2009 address the most frequent word is “us” (23 times), then “nation” (12), “new” (11) and “america” (10).

Raw counts. The speeches differ in length, so read the bars as counts and not rates.

Share of long words by address

A long word has 10 or more letters. The share is out of all words left after removing stop words. Adams in 1825 is highest.

GitHub activity · 31 Jul 2026

Inaugural addresses notebook

The full notebook, scroll through it below.

This browser cannot show the PDF here. Open it.

Notebook · 21 Aug 2026 · scikit-learn

Bag of words

The vocabulary is learned from two sentences: “Tessaract is good optical character recognition engine” and “optical character recognition is significant”. Any new sentence becomes a row of 1s and 0s over that vocabulary, and cosine similarity compares two rows.

Words outside the vocabulary are ignored, and one-letter words are dropped, as in the notebook.

Notebook · 21 Aug 2026 · NLTK Naive Bayes

Guessing gender from a name

The only feature is the last letter of the name. The classifier learned from NLTK’s list of 7,944 male and female names, then labelled two new names.

Davidends in d · male
Obamaends in a · female
GitHub activity · 21 Aug 2026

Name classifier and bag of words notebook

The full notebook, scroll through it below.

This browser cannot show the PDF here. Open it.

Project

Context-Aware Cyberbullying Detection in Chats

Using previous and current messages to understand potentially harmful language.

1Title

Context-Aware Cyberbullying Detection in Chats: using previous and current messages to understand potentially harmful language.

Team: Hiba Fathima T K (23MID0057), Bharath Palanisamy Mettukadai (23MID0014), Asad Irfan K (23MID0442).

2Motivation

Online chatting is a big part of everyday communication. Cyberbullying through messages can hurt mental well-being and make online spaces unsafe. Detecting it automatically is hard, because the meaning of a message depends on the conversation around it. We use natural language processing on both the previous and the current message, so the system reads a message in its context. The goal is to help human moderators find potentially harmful conversations, not to replace their judgement.

3Existing gap

Traditional detection often looks only at the words in one message, without the conversation around it. A system that checks each message alone can misread the meaning and predict wrongly.

  • “I’m damn tired today.” contains “damn”, but that does not make it cyberbullying.
  • “You are useless.” may be abusive, depending on what came before it.

4Architecture

Previous + current message→Language check→Translate (Tamil, Malayalam)→Clean text→TF-IDF→Baseline model+Context-aware model→Compare SAFE / ABUSIVE

A Flask web app serves one page, /, and one prediction route, /predict, which takes the two messages as JSON. The four trained files (two TF-IDF vectorizers and two classifiers) are loaded once when the app starts. The baseline model sees only the current message. The context-aware model sees the previous and current message joined into one text. The page shows both predictions side by side.

5Complete tech stack

Layer Tool
Language Python
Data handling Pandas, NumPy
Features and models Scikit-learn: TfidfVectorizer and LogisticRegression
Web app Flask
Translation deep-translator (Tamil and Malayalam to English)
Interface HTML, CSS and JavaScript
Storage of trained models Pickle files (.pkl)

6Datasets used

Contextual Abuse Dataset (CAD), from Vidgen, Nguyen, Margetts, Rossini and Tromble (NAACL 2021). We used the file CAD_context_aware.csv: 27,494 Reddit entries, each with the message text and an annotation of the kind of abuse, labelled in the context of its conversation thread.

Original label Entries Our class
Neutral 21,935 SAFE
CounterSpeech 220 SAFE
IdentityDirectedAbuse 2,729 ABUSIVE
AffiliationDirectedAbuse 1,349 ABUSIVE
PersonDirectedAbuse 1,112 ABUSIVE
Slur 149 ABUSIVE

This gives 22,155 SAFE messages (80.6%) and 5,339 ABUSIVE messages (19.4%). Because abusive messages are about one in five, both classifiers use balanced class weights.

7Prompts used for the construction of the website

Not applicable.

8NLP pipeline

  1. Language handling. Tamil and Malayalam text is detected by its Unicode range and translated to English. English text passes straight through.
  2. Text cleaning. Lowercase the text, remove links, replace every character that is not a letter, digit or space with a space, and collapse repeated spaces.
  3. Data splitting. The data was divided into a training set and a testing set.
  4. Features. TF-IDF with up to 10,000 features, single words and word pairs, English stop words removed, and L2 normalisation.
  5. Baseline model. Logistic regression on the current message only.
  6. Context-aware model. The same classifier on the previous message and the current message joined into one text.
  7. Prediction. Each model returns the probability that the message is abusive. A probability of 0.5 or more is labelled ABUSIVE, and anything lower SAFE.
  8. Comparison. The page shows both labels, and a short note when context changed the result.

Both classifiers are logistic regression with balanced class weights, C = 1.0, L2 penalty, the lbfgs solver and up to 1,000 iterations.

Metric Baseline Context-aware
Accuracy 77.60% 78.82%
Abusive precision 44.97% 47.24%
Abusive recall 51.45% 46.47%
Abusive F1-score 47.99% 46.85%

Context raised accuracy and precision a little, while recall and F1-score went down. So adding context does not improve every metric.

9Users, inputs and output

Users. Moderators on social media platforms, schools and universities reviewing student chat reports, community moderators, and researchers studying how context affects abuse detection.

Inputs. Two text boxes: the previous message (optional) and the current message (required). Text can be English, Tamil or Malayalam. A message is plain text of any length, typed in or picked from the example chips.

Output. For each model: a verdict, Safe or Abusive, a probability bar, and a risk score between 0 and 1. When both messages are given, one line says whether context changed the verdict. The last six analyses stay listed on the page.

The system supports human reviewers. It should not automatically punish users or make final judgements about their intentions.

10References

  1. Vidgen, B., Nguyen, D., Margetts, H., Rossini, P., Tromble, R. (2021). Introducing CAD: the Contextual Abuse Dataset. Proceedings of NAACL 2021. aclweb.org/anthology/2021.naacl-main.182
  2. CAD dataset and code. doi.org/10.5281/zenodo.4881008, github.com/dongpng/cad_naacl2021
  3. Pedregosa, F. et al. (2011). Scikit-learn: Machine Learning in Python. Journal of Machine Learning Research, 12, 2825–2830.
  4. Flask documentation. flask.palletsprojects.com
  5. deep-translator. pypi.org/project/deep-translator
Project PPT

Project presentation

The slides, scroll through them below.

This browser cannot show the PDF here. Open it.

Project demo video: link to be added.
About

About

I am Bharath Palanisamy Mettukadai (23MID0014), an Integrated M.Tech student at VIT Vellore.

I speak Tamil, Malayalam, English and Hindi, which is why this portfolio moves between all four.

Contact

Contact

Submitted to Prof. Dr. Sharmila Banu for CSI4001, Natural Language Processing and Computational Linguistics.