Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 1.0.7 instead.

NepaliKit

Current Release Version pypi Version PyPi downloads

NepaliKit is a Python library for natural language processing tasks in the Nepali language.

Installation

You can install NepaliKit using pip:

pip install nepalikit

Alternatively, you can clone the repository and install it manually:

git clone https://github.com/prabhashj07/nepalikit.git
cd nepalikit
pip install .

Features

NepaliKit provides the following features:

  • Tokenization: Tokenize Nepali text using rule-based and SentencePiece tokenizers.
  • Preprocessing: Clean and preprocess Nepali text data, including removing HTML tags, special characters, and other cleaning tasks.
  • Stopword Management: Load and remove stopwords from Nepali text. 340+ curated Nepali stopwords with dynamic add/remove support.
  • Sentence Operations: Segment Nepali text into sentences based on punctuation marks.
  • SentencePiece Model Training: Train custom SentencePiece models for Nepali text data.
  • Utility Functions: Various utility functions for text processing and manipulation.
  • Integration with PyTorch: Utilities for integrating with PyTorch for machine learning tasks.
  • Stemming: Rule-based suffix stripping for Nepali words. Strips case markers, possessives, plurals, and verb endings.
  • Normalization: Unicode NFC normalization, ZWNJ/ZWJ stripping, control character cleanup, and whitespace normalization.
  • Script Detection: Detect whether text is Devanagari, Latin, mixed, or other.
  • Number Extraction: Parse and convert Nepali numeric expressions (Devanagari digits and number words) to integers.
  • POS Tagging: Dictionary-based part-of-speech tagger with 11 grammatical categories.
  • Spell Checking: Dictionary-based spell checking with Levenshtein edit distance for correction suggestions.
  • Transliteration: Character-level Roman to Devanagari and Devanagari to Roman conversion.

Usage

Tokenization Example

Rule-based Tokenizer

from nepalikit.tokenization import Tokenizer

text = "नमस्ते, के छ खबर? यो एउटा वाक्य हो।"
tokenizer = Tokenizer()

# Sentence tokenization
sentences = tokenizer.tokenize(text, level='sentence')
print(sentences)

# Word tokenization
words = tokenizer.tokenize(text, level='word')
print(words)

# Character tokenization
characters = tokenizer.tokenize(text, level='characters')
print(characters)

Sentence Piece Tokenizer

from nepalikit.tokenization import SentencePieceTokenizer

text = "नमस्ते, के छ खबर?"
tokenizer = SentencePieceTokenizer()
tokens = tokenizer.tokenize(text)
print(tokens)

# Detokenization
original_text = tokenizer.detokenize(tokens)
print(original_text)

Preprocessing Example

from nepalikit.preprocessing import TextProcessor

text = "<p>नमस्ते, के छ खबर?</p>"
processor = TextProcessor()
clean_text = processor.remove_html_tags(text)
clean_text = processor.remove_special_characters(clean_text)
print(clean_text)

Stopword Example

from nepalikit.manage_stopwords import load_stopwords, remove_stopword

stopwords = load_stopwords('/path/to/stopword/directory')
remove_stopword('कुनै_स्टापवर्ड')

TextProcessor Class


The TextProcessor class provides various methods for text preprocessing:

  • remove_html_tags(text): Removes HTML tags from the text.
  • remove_special_characters(text): Removes special characters, keeping only Devanagari characters and spaces.
  • remove_extra_whitespace(text): Removes extra whitespace from the text.
  • remove_stopwords(text): Removes stopwords from the text.
  • normalize_text(text): Converts the text to lowercase.
  • preprocess_text(text): Applies all preprocessing steps to the text.
  • get_word_frequency(tokens): Returns the frequency of words in a list of tokens.

URLs and Emails Removal


The urls_emails class provides methods to remove or replace URLs and email addresses in the text:

  • replace_urls_emails(text): Replaces URLs and email addresses with specified replacements.
  • remove_urls_emails(text): Removes URLs and email addresses from the text.

Sentence Operations


The sentence_operation folder contains various modules for sentence-level operations:

  • extract_sentences.py: Extracts sentences from text.
  • load_abbreviation.py: Loads abbreviations for text processing.
  • normalize_text.py: Normalizes text.
  • segment_sentences.py: Segments text into sentences.
  • sentence_stats.py: Provides statistics about sentences.

Tokenizer Classes


Rule-based Tokenizer

The Tokenizer class provides the following methods:

  • sentence_tokenize(text): Tokenizes input text into sentences based on '।' character.
  • word_tokenize(sentence, new_punctuation=None): Tokenizes input sentence into words, handling specified punctuation.
  • character_tokenize(word): Tokenizes input word into characters.
  • tokenize(text, level='word', new_punctuation=None): General tokenization method for sentence, word, or character level.
  • sentence_detokenize(sentences): Detokenizes a list of sentences back into the original text.
  • word_detokenize(words): Detokenizes a list of words back into the original sentence.
  • character_detokenize(characters): Detokenizes a list of characters back into the original word.
  • detokenize(tokens, level='word'): General detokenization method for sentence, word, or character level.

SentencePiece Tokenizer

The SentencePieceTokenizer class provides the following methods:

  • tokenize(text): Tokenizes text using the SentencePiece model.
  • detokenize(tokens): Detokenizes text using the SentencePiece model.

NepaliTextProcessor Class


The NepaliTextProcessor class in utils.py offers additional text processing capabilities:

  • merge_text(tokens): Merges a list of tokens into a single string.
  • split_text(text): Splits a text string into a list of tokens.
  • count_words(text): Counts the number of words in a text string.
  • count_words_in_paragraph(paragraph): Counts the total number of words in a paragraph.

License

This project is licensed under the MIT License.

Author

Metadata

Release files for nepalikit 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nepalikit 1.1.0
File Size Uploaded
nepalikit-1.1.0.tar.gz 320.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nepalikit 1.1.0
File Interpreter ABI Platform
nepalikit-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 644.2 kB

Release files / nepalikit-1.1.0.tar.gz

Download URL nepalikit-1.1.0.tar.gz
Size 320.3 kB
Tags Source
SHA-256 checksum
How to use checksums
060fdd00dba1621e5d6f335fd39e52afaed95c738428759c0f26335ffec420bf
BLAKE2b-256 checksum
How to use checksums
23322939e2a3ee09bab1bddbafeebe1cdd2dcbeadea7c3c9e5be2195b5d89835
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.

Transparency log

Release files / nepalikit-1.1.0-py3-none-any.whl

Download URL nepalikit-1.1.0-py3-none-any.whl
Size 323.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d4f79bb5d8d4660f8e6fad15cc362d6e9fbeda76303267acdd6a2a7fbda83a6
BLAKE2b-256 checksum
How to use checksums
71981a6b75dfa6a562933c9780b18a487f945cef0dd7a7fee961dba7bcc2bc3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

1 release file

1.0.1

3 release files

1.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page