Skip to content

A pipeline for transliteration, spell correction, POS tagging and word sense disambiguation of Hinglish code mixed data to Hindi Devanagari script.

License

Notifications You must be signed in to change notification settings

praatibhsurana/Hinglish_Hindi_WSD

Repository files navigation

Note: This library is no longer being maintained. Please use Python >=3.6 and <=3.8.5 to ensure there are no version related issues.

GitHub stars Pypi package GitHub issues GitHub license

📌 A python package for transliteration of Hinglish code mixed data to Hindi Devanagari script, spell correction, POS tagging and word sense disambiguation of the Hindi Devanagari script.

📖 With this package, we aim to tackle the problem of word sense disambiguation by making atleast the preliminary steps a lot easier. The problem statement we decided to tackle was the translation of Hinglish code mixed data to Hindi Devanagari and then to carry out word sense disambiguation on the Hindi text. We make use of libraries such as spello, indic-transliteration, pyiwn and indic_tagger.


💡 Functionalities

hindiwsd will mainly carry out the following tasks for now:

  • Hinglish to Hindi transliteration
  • Spell correction of Hindi text
  • POS tagging of Hindi text
  • Word Sense Disambiguation of Hindi text with the help of IndoWordNet
  • Enhanced Lesk's Algorithm using custom dataset

💾 Installation

Install hindiwsd via 'pip'

pip install hindiwsd

🗒️ NOTE

  1. A small change will need to be made to iwn.py from the pyiwn library before using our package
  • There is a missing try-catch block in iwn.py that might cause our package to crash
  • Here's a quick fix, use our patched iwn.py instead. Copy it's contents and replace the original iwn.py.
  • The path to the original iwn.py would be path-to-your-env-or-python-folder/lib/site-packages/pyiwn/iwn.py

📄 CUSTOM DATASET FOR ENHANCED LESK'S ALGORITHM

The custom dataset is available here.

  • Here is a preview of what it looks like

    image

⚡Getting Started

🔤 Word Sense Disambiguation

  • The wordsense() function from the hindi_wsd.py script. It prints out the Hindi Devanagari spell corrected sentence, POS tags and disambiguated word meanings for each word in the sentence available on the IndoWordNet.
>>> from hindiwsd import hindi_wsd  
>>> print(hindi_wsd.wordsense("aaj achha din hai"))   
  • You can also directly feed in Hindi sentences to the wordsense() function.
>>> from hindiwsd import hindi_wsd  
>>> print(hindi_wsd.wordsense("आज अच्छा दिन है"))   

🏷️ POS tagging for Hindi Devanagari

  • Getting POS tags for a Hindi sentence using the POS_tagger() function from the wsd.py script. Returns a list of tuples containing word and respective tag(NOUN, ADJECTIVE, ADVERB, VERB).
>>> from hindiwsd import wsd  
>>> print(wsd.POS_tagger('आज अच्छा दिन है'))   

📚 Hinglish to Hindi transliteration with spell correction

  • Transliterating the Hinglish code mixed sentence to Hindi Devanagari using the preprocess_transliterate() function from the wsd.py script. Returns two strings. The first is the spell corrected Hinglish sentence followed by the spell corrected Hindi sentence.
>>> from hindiwsd import wsd  
>>> print(wsd.preprocess_transliterate('aaj achha din hai'))   

Citing

If you publish work that uses hindiwsd, please cite the hindiwsd paper, as follows:

@InProceedings{yusuf-surana-sharma:2022:WILDRE6,
  author    = {Yusuf, Mirza  and  Surana, Praatibh  and  sharma, Chethan},
  title     = {HindiWSD: A package for word sense disambiguation in Hinglish \& Hindi},
  booktitle      = {Proceedings of The WILDRE-6 Workshop within the 13th Language Resources and Evaluation Conference},
  month          = {June},
  year           = {2022},
  address        = {Marseille, France},
  publisher      = {European Language Resources Association},
  pages     = {18--23},
  abstract  = {A lot of commendable work has been done, especially in high resource languages such as English, Spanish, French, etc. However, work done for Indic languages such as Hindi, Tamil, Telugu, etc is relatively less due to difficulty in finding relevant datasets, and the complexity of these languages. With the advent of IndoWordnet, we can explore important tasks such as word sense disambiguation, word similarity, and cross-lingual information retrieval, and carry out effective research regarding the same. In this paper, we worked on improving word sense disambiguation for 20 of the most common ambiguous Hindi words by making use of knowledge-based methods. We also came up with “hindiwsd�, an easy-to-use framework developed in Python that acts as a pipeline for transliteration of Hinglish code-mixed text followed by spell correction, POS tagging, and word sense disambiguation of Hindi text. We also curated a dataset of these 20 most used ambiguous Hindi words. This dataset was then used to enhance a modified Lesk's algorithm and more accurately carry out word sense disambiguation. We achieved an accuracy of about 71\% using our customized Lesk’s algorithm which was an improvement to the accuracy of about 34\% using the original Lesk’s algorithm on the test set.},
  url       = {https://aclanthology.org/2022.wildre6-1.4}
}

Feel free to reach out to us for more information!