DEV Community

Harsh Verma
Harsh Verma

Posted on

I built my mom a Hindi spelling fixer that runs on my laptop

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend

What I Built

My mom teaches Hindi. She writes her reports, notices and other work in Word, and she types all of it with Gboard's Hindi handwriting and voice input. She does that easily, but later faces problem in correcting mistakes which voice and handwriting input got wrong.

बच्चों turns into बच्चो. पढ़ाया turns into पढाया. है turns into हे. She then fixes each one by hand, in a Word file she finds it hard to edit.

So I built her a small page that runs on my laptop. She uploads a .docx, and she gets back a fixed copy plus a list of every line that changed. Her original file is never touched.

Demo

Video: https://drive.google.com/drive/folders/1gQ7pM90d3quHsdf98rLGVd4XD-wU_3QE
GitHub Repository: https://github.com/harshverma27/Hindi-Doc-Fixer

Before After
आज कक्षा में 'ईदगाह' पाठ पढाया गया। बच्चो ने बहुत ध्यान से सुना। आज कक्षा में 'ईदगाह' पाठ पढ़ाया गया। बच्चों ने बहुत ध्यान से सुना।
पाठ के कठिन शब्दो का अर्थ बोर्ड पर लिखवाया गया। पाठ के कठिन शब्दों का अर्थ बोर्ड पर लिखवाया गया।
कुछ बच्चो को ... कठिनाई हे। कुछ बच्चों को ... कठिनाई है।

I showed it to her. She said it's good, and that she'll still read through the fixed file out of habit, but it definitely helped. I'll take that. A teacher checking the work is the right outcome.

Code

GitHub logo harshverma27 / Hindi-Doc-Fixer

Challenge 1 of 5 in our Hacktoberfest DEV Challenges.

Hindi doc fixer

My mom teaches Hindi. She types her Word files with Gboard's Hindi handwriting and voice input, and the text comes out with small spelling and matra mistakes. Fixing them by hand takes her a long time.

This is a small page on my laptop. She uploads a .docx and gets back a fixed copy. Her original file is not touched.

It runs Gemma 3 1B through Ollama on the laptop, so her files never leave it.

Demo video: https://drive.google.com/drive/folders/1gQ7pM90d3quHsdf98rLGVd4XD-wU_3QE

What it fixes

Only spelling-type mistakes:

  • short or long matra (ि/ी, ु/ू)
  • े/ै and ो/ौ
  • missing or extra ं and ँ
  • nukta (ढ/ढ़)
  • ये/ए (लिये to लिए)

If the model changes a word into a different word, drops a word, or touches punctuation, that change is thrown away and her text stays as it was. Spacing, headings and English lines are left alone.

Keeping a line as it

…

How I Built It

The whole thing is one Python file of about 120 lines:

  • Gemma 3 1B running locally through Ollama does the fixing.
  • python-docx reads the Word file paragraph by paragraph and writes the fixed copy.
  • Gradio gives her an upload button and a download button.

The fun part was not getting the model to fix things. It was stopping it from fixing things it shouldn't :)

A 1B model is small, and on Hindi it showed. The first run swapped है for हूँ, which changed the sentence. It replaced बच्चो with छात्रों, a different word. It dropped "1." from numbered questions, squashed her spacing, removed quotes and added commas. On a test paper it even "fixed" a sentence that was wrong on purpose, because the question asked students to correct it.

So I stopped trusting the model's output as a whole and started checking it word by word. The rule I ended up with is simple. A change is accepted only if the old word and the new word are the same once you ignore the things voice typing gets wrong:

  • short or long matra (ि/ी, ु/ू)
  • े/ै and ो/ौ
  • ं and ँ
  • nukta (ढ/ढ़)
  • ये/ए

If the model changes a consonant, adds or drops a word, or touches punctuation, that change is thrown away and her text stays. The fixed words are put back in place, so spacing and layout don't move.

This blocks good edits sometimes. It won't turn लिखिये into लिखें, because that's style, not spelling. It misses some real mistakes too. For a teacher's document, missing a typo is much better than changing entirely.

For the sentences that are wrong on purpose, she starts the line with #. The app skips that line and removes the # in the fixed copy.

Why Does Open Innovation Matter?

Her files are about her students. Names, attendance, who is struggling with what. I didn't want any of that going to someone else's server, and with an open model on the laptop it doesn't. It also works without internet and costs nothing to run, which matters for a tool she'll use every day.

Being open also changed how I built it. I could run the model as many times as I wanted, see exactly what it did to each sentence, and build the guard around its actual mistakes. And since it's just Ollama, swapping in a bigger Gemma later is a one-line change.

Prize Categories

Best Use of Gemma

Top comments (0)