Usage Guide¶
This guide describes how to use Nepali Unicoder through its Command Line Interface (CLI) and Python API.
Installation¶
Python API¶
The primary interface is the Converter class.
Roman to Unicode Mode (Default)¶
from nepali_unicoder.convert import Converter
# Initialize converter
converter = Converter()
# Convert phonetic Roman text
print(converter.convert("namaste"))
# Output: नमस्ते
Preeti to Unicode Mode¶
# Initialize converter in Preeti mode
preeti_converter = Converter(mode="preeti")
# Convert Preeti characters
print(preeti_converter.convert("s{sf"))
# Output: र्कर्का
Custom Words¶
Pass your own whole-word mappings with word_map. They take priority over the
bundled ones, a capitalized variant is added automatically (sanjeev also
matches Sanjeev), and they only match whole words (sanjeevko is not affected).
converter = Converter(word_map={"sanjeev": "सञ्जीव", "github": "गिटहब"})
print(converter.convert("Sanjeev github ma chha"))
# Output: सञ्जीव गिटहब म छ
Keys must be single words of ASCII letters. word_map is only available in
Roman mode.
Handling Mixed English Content¶
You can wrap English words or any text you want to preserve in curly braces {}.
English Preservation
In Preeti mode, the curly braces { and } are treated as normal characters because they are part of the Preeti font mapping.
Command Line Interface¶
You can run the package directly from your shell.
Basic Usage¶
Preeti Conversion¶
Use the --preeti flag for Preeti font text.