Convert Nepali text to roman English
Package to convert Nepali text to romanized English.
Many a time, while working with data, either from government sector or from private sector, we encounter Nepali names of VDCs, municipalities, local level units, districts and places. While merging such data with another datasheet consisting names of units in English, we need to romanize the Nepali names to English before using some text similarity algorithms to do string matching.
This package helps in romanizing Nepali names using rudimentary script. It is worth mentioning that romanization of Nepali text used in our daily life is inconsistent. For example, the popular romanization of "नेपाल" is "Nepal". It might seem as the correct romanization but if we have to distinguish between "नेपाल" and "नेपल", we can't do that with this romanization scheme. So, this package uses unique and standard romanization scheme such that no two Nepali words have same romanization.
nepali-roman package is available for
Python 3 and can be installed using
First make sure
pip is installed.
Then, the package can be installed using this command.
pip install nepali-roman
nepali_roman module using the following command.
import nepali_roman as nr
nepali_roman module has three functions:
This function checks if the text is in Devanagari format.
Detail description: In the text, it ignores all the punctuations, white spaces and other non-alphanumeric characters and then counts the number of devanagari characters. If the number of devanagari characters is more than or equal to 50% of the stripped text, the function deems the text devanagari, otherwise not.
>>> import nepali_roman as nr >>> nr.is_devanagari("नगरपालिका") True >>> nr.romanize_text("surajपालिक") False >>> nr.romanize_text("suraj") False
This function can be used to romanize the Nepali text to English.
>>> import nepali_roman as nr >>> nr.romanize_text("नगरपालिका") nagarapaalikaa
This function takes Nepali text file as an input and saves the romanized text in specified output file.
>>> nr.romanize(input_file_path, output_file_path)
>>> import nepali_roman as nr >>> nr.romanize('nepali.txt', 'romanized_english.txt') # this takes Nepali text file nepali.txt and stores romanized English in the file romanized_english.txt
The package is licenced with The MIT License (MIT) about which details can be found in the LICENSE file. As the package is open sourced and requires many improvements and extensions, any contributions are welcome. Any other feedback of any sort are highly welcome.
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size nepali_roman-0.45.1.1.tar.gz (4.9 kB)||File type Source||Python version None||Upload date||Hashes View|