Downloads · 30 days
38
49% of all-time downloads
Supernova11c/Supernova-Nepali-Language-Detector-V1
Supernova-Nepali-Language-Detector-V1 is a machine learning model from Supernova11c. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as other.
Downloads · 30 days
38
49% of all-time downloads
All-time downloads
77
Public
Repo size
6.5 MB
Likes
1
Public
Click a slice to open those files.
.pkl6.5 MB · 99%
From the Hugging Face model README

A lightweight deterministic language identification system developed by Supernova.
pip install supernova-lang
from supernova_lang import detect
result = detect("नेपाल सुन्दर देश हो।")
print(result.language)
print(result.confidence)
print(result.script)
This detector does not use neural networks or pretrained weights.
It uses deterministic language fingerprints, vocabulary statistics, Unicode/script analysis, and calibrated scoring.
import sys
import os
from huggingface_hub import hf_hub_download
# 1. Configuration
repo_id = "Supernova11c/Supernova-Nepali-Language-Detector-V1"
required_files = ["detector.py", "language_data.pkl", "runtime.pkl", "word_counts.pkl"]
print("Fetching model components from Hugging Face Hub...")
for filename in required_files:
if not os.path.exists(filename):
try:
hf_hub_download(repo_id=repo_id, filename=filename, local_dir=".")
print(f"✓ Downloaded: {filename}")
except Exception as e:
print(f"✗ Error fetching {filename}: {e}")
else:
print(f"✓ Found local copy of: {filename}")
# 2. Append local directory to system path for import
if '.' not in sys.path:
sys.path.append('.')
# 3. Load the engine and execute verification test
try:
import detector
test_phrase = "मलाई नेपाल धेरै मन पर्छ।"
print(f"\nTesting input: \"{test_phrase}\"")
result = detector.detect_final_language(test_phrase)
print("\n--- Verification Status: SUCCESS ---")
print(f"Detected Language: {result.get('language')}")
print(f"Confidence Score : {result.get('confidence'):.4f}")
print(f"Detected Script : {result.get('script')}")
except Exception as e:
print(f"\n--- Verification)
# 1. Install required packages silently
!pip install -q fasttext-wheel huggingface_hub numpy
import sys
import os
import numpy as np
from huggingface_hub import hf_hub_download
# 2. Download Supernova V1 Files if not already present
repo_id = "Supernova11c/Supernova-Nepali-Language-Detector-V1"
files_to_download = ["detector.py", "language_data.pkl", "runtime.pkl", "word_counts.pkl"]
print("Downloading Supernova V1 assets...")
for filename in files_to_download:
if not os.path.exists(filename):
try:
hf_hub_download(repo_id=repo_id, filename=filename, local_dir=".")
print(f"- Downloaded {filename}")
except Exception as e:
print(f"- Error downloading {filename}: {e}")
else:
print(f"- {filename} already exists locally.")
# Add current directory to path so python can import detector
if '.' not in sys.path:
sys.path.append('.')
import detector
# 3. Download fastText compact model from official Hugging Face repository
print("Downloading fastText Language ID model from Hugging Face...")
try:
ft_model_path = hf_hub_download(
repo_id="facebook/fasttext-language-identification",
filename="model.bin",
local_dir="."
)
# Rename model.bin to expected fasttext file if necessary, or load directly
import fasttext
ft_detector = fasttext.load_model(ft_model_path)
print("fastText model loaded successfully from Hugging Face Hub!")
except Exception as e:
print(f"Error downloading/loading fastText from HF Hub: {e}")
# 4. Define all 30 Adversarial Test Cases across Rounds 1, 2, and 3
all_test_cases = [
# --- ROUND 1 ---
{"id": "TC-001", "expected": "Nepali", "text": "म नेपाल जान्छु।"},
{"id": "TC-002", "expected": "Sanskrit", "text": "धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सवः"},
{"id": "TC-003", "expected": "Unknown / Multi-Language", "text": "नाम"},
{"id": "TC-004", "expected": "Mixed (Nepali + English)", "text": "Mero ghar Kathmandu ma cha, but I am currently living in Delhi."},
{"id": "TC-005", "expected": "Mixed / English with Hindi", "text": "Man, tan, and dhan are important."},
{"id": "TC-006", "expected": "Sanskrit", "text": "ॐ भूर्भुवः स्वः ळ ॲ ऱ्"},
{"id": "TC-007", "expected": "Mixed (Nepali + English)", "text": "आजको weather निकै ramro छ, right?"},
{"id": "TC-008", "expected": "Unknown", "text": "कगखघ ङचछज झञटठ डढणतथ दधनपफ"},
{"id": "TC-009", "expected": "Nepali", "text": "स्̀́पिष्ट"},
{"id": "TC-010", "expected": "Sanskrit", "text": "Satyam eva jayate nānဓtaေ satyena panthā vitato devayāna့"},
# --- ROUND 2 ---
{"id": "TC-011", "expected": "Nepali", "text": "उनीहरू घर गए।"},
{"id": "TC-012", "expected": "Sanskrit", "text": "सूर्यः पूर्वस्याम् दिशि उदेति।"},
{"id": "TC-013", "expected": "Mixed (Nepali Latin + Hindi Latin)", "text": "aaja ko din dherai ramro cha, subah se khusi lagiprachha"},
{"id": "TC-014", "expected": "Nepali", "text": "२०८३-०५-१२ : रु. ५०००/- मात्र।"},
{"id": "TC-015", "expected": "Sanskrit", "text": "अ॒ग्निमी॑ळे पु॒रोहि॑तं य॒ज्ञस्य॑ दे॒वमृ॒त्विजम्॑"},
{"id": "TC-016", "expected": "Nepali", "text": "मलाई आज बिदा दिनुहोस्।"},
{"id": "TC-017", "expected": "Mixed (Code / English + Nepali)", "text": "system.out.println(\"नमस्ते संसार!\"); // core output log"},
{"id": "TC-018", "expected": "Sanskrit", "text": "Kārpaṇyadoṣopahatasvabhāvaḥ pṛcchāmi tvāṁ dharmasammūḍhacetāḥ"},
{"id": "TC-019", "expected": "Sanskrit", "text": "प्रत्येकं वस्तुतः स्वयमेव परिवर्तनशीलम् अस्ति।"},
{"id": "TC-020", "expected": "Unknown", "text": "ािीुूृेैोौ्ंः ािीुूृ"},
# --- ROUND 3 ---
{"id": "TC-021", "expected": "Nepali", "text": "उहाँले मलाई भन्नुभयो कि उनीहरू आउनेछन्।"},
{"id": "TC-022", "expected": "Nepali / Hindi (Formal Shared)", "text": "अन्तर्राष्ट्रिय मानवाधिकार दिवसका अवसरमा आयोजित कार्यक्रम।"},
{"id": "TC-023", "expected": "Nepali Latin (Neplish)", "text": "timile k gareko bro? khana khayeu ki nai?"},
{"id": "TC-024", "expected": "Nepali Latin (Neplish)", "text": "Нaмasтe! Cаm or kеstо сha?"},
{"id": "TC-025", "expected": "Sanskrit", "text": "अ॒ग्निम् ई॑ळे पुरो॒हि॑तं यज्ञ॒स्य॑ देवं् ऋ॒त्विज॑म्।"},
{"id": "TC-026", "expected": "Nepali", "text": "रु ५,०००/- (अक्षरेपी पाँच हजार मात्र)"},
{"id": "TC-027", "expected": "Mixed (English + Hindi + Nepali Latin)", "text": "Today's मौसम is Very ramro, let's go out for a walk."},
{"id": "TC-028", "expected": "Unknown", "text": "र्कृष्टंब्झ्र्ग्द्ष्ट्र्क्स्न्म्"},
{"id": "TC-029", "expected": "Bhojpuri / Unknown (Outside target set)", "text": "हमरा के सब बात मालूम बा।"},
{"id": "TC-030", "expected": "Nepali", "text": "यो कालो कपडा धेरै मीठो छ।"}
]
# 5. Patch NumPy 2.x Compatibility
orig_array = np.array
def patched_array(object, *args, **kwargs):
if 'copy' in kwargs:
kwargs.pop('copy')
return orig_array(object, *args, **kwargs)
np.array = patched_array
# 6. Execute Evaluation and Print Unified Table
print("\n" + "=" * 105)
print(f"{'ID':<7} | {'Expected Language':<32} | {'Supernova V1 Prediction':<28} | {'fastText Prediction':<25}")
print("=" * 105)
for tc in all_test_cases:
text = tc["text"]
# Get Supernova V1 prediction
v1_pred = detector.detect_final_language(text)
v1_out = f"{v1_pred['language']} ({v1_pred['confidence']:.2f})"
# Get fastText prediction
ft_labels, ft_probs = ft_detector.predict(text.replace("\n", " "))
ft_lang = ft_labels[0].replace("__label__", "")
ft_out = f"{ft_lang} ({ft_probs[0]:.2f})"
print(f"{tc['id']:<7} | {tc['expected'][:32]:<32} | {v1_out:<28} | {ft_out:<25}")
# Restore original numpy array behavior
np.array = orig_array
print("=" * 105)
This table contains the complete results and raw outputs generated across all 30 test cases spanning Round 1, Round 2, and Round 3.
| ID | Expected Language | Supernova V1 Prediction | fastText Prediction | Outcome / Analysis |
|---|---|---|---|---|
| TC-001 | Nepali | Nepali (0.48) | hi (0.85) | Supernova V1 wins; fastText misclassifies common Nepali as Hindi. |
| TC-002 | Sanskrit | Sanskrit (0.19) | hi (0.51) | Supernova V1 wins; fastText misclassifies classical Sanskrit as Hindi. |
| TC-003 | Unknown | Unknown (0.05) | hi (0.94) | Supernova V1 wins; correctly flags ambiguity instead of over-predicting. |
| TC-004 | Mixed (NP + EN) | Nepali Latin (0.66) | en (0.89) | Supernova V1 wins; captures romanized transition. |
| TC-005 | Mixed (EN + HI) | English (0.94) | en (0.90) | Draw; both models classify sentence structure as English. |
| TC-006 | Sanskrit | Sanskrit (0.50) | sa (0.99) | Both win; correct Sanskrit classification. |
| TC-007 | Mixed (NP + EN) | Mixed (1.00) | ne (0.82) | Supernova V1 wins; flags explicit code-mixed state. |
| TC-008 | Unknown | Unknown (0.11) | hi (0.91) | Supernova V1 wins; correctly labels structural gibberish. |
| TC-009 | Nepali | Unknown (0.02) | hi (0.48) | Both struggle; broken by zero-width joiner (ZWJ) characters. |
| TC-010 | Sanskrit | Nepali Latin (1.00) | en (0.15) | Both struggle; failed to parse raw Latin script transliterated Sanskrit. |
| TC-011 | Nepali | Hindi (0.55) | hi (0.64) | Both failed; pronoun-verb agreement mismatch caused Hindi classification. |
| TC-012 | Sanskrit | Sanskrit (0.37) | sa (0.96) | Both win; parsed high-literary homograph sentence correctly. |
| TC-013 | Mixed (NP + HI Latin) | Nepali Latin (0.93) | kw (0.33) | Supernova V1 wins; fastText hallucinated Cornish (kw). |
| TC-014 | Nepali | Nepali (0.81) | hi (0.80) | Supernova V1 wins; correctly parsed Devanagari numerals and abbreviations. |
| TC-015 | Sanskrit | Sanskrit (0.39) | sa (0.58) | Both win; robust handling of combining Vedic diacritics. |
| TC-016 | Nepali | Nepali (0.42) | hi (0.88) | Supernova V1 wins; successfully handled semantic false friends. |
| TC-017 | Mixed (Code + NP) | Mixed (0.90) | mr (0.26) | Supernova V1 wins; correctly extracted string within code structure. |
| TC-018 | Sanskrit | English (0.75) | nl (0.31) | Both failed; unable to parse Sanskrit in Latin script with IAST diacritics. |
| TC-019 | Sanskrit | Sanskrit (0.46) | sa (0.75) | Both win; resolved grammatical sandhi modifications correctly. |
| TC-020 | Unknown | Nepali (0.38) | sa (0.53) | Both failed; standalone floating vowel matras forced predictions. |
| TC-021 | Nepali | Nepali (0.54) | hi (0.68) | Supernova V1 wins; correctly used verb endings ('भन्नुभयो') to bypass shared roots. |
| TC-022 | Nepali / Hindi | Nepali (0.42) | hi (0.81) | Draw; sentence elements exist identically in both dictionaries. |
| TC-023 | Nepali Latin | Nepali Latin (1.00) | qu (0.12) | Supernova V1 wins; fastText hallucinated Quechua (qu). |
| TC-024 | Nepali Latin | English (0.89) | bg (0.41) | Both failed; lookalike Cyrillic characters broke tokenization. |
| TC-025 | Sanskrit | Sanskrit (0.55) | sa (0.81) | Both win; parsed non-standard combining Vedic tone marks. |
| TC-026 | Nepali | Nepali (0.74) | hi (0.75) | Supernova V1 wins; maps accounting abbreviations successfully. |
| TC-027 | Mixed (3-Way) | Mixed (1.00) | en (0.69) | Supernova V1 wins; identified triple-language code-mix successfully. |
| TC-028 | Unknown | Sanskrit (0.14) | hi (0.39) | Both failed; dense invalid consonant chains triggered predictions. |
| TC-029 | Bhojpuri / Unknown | Hindi (0.62) | hi (0.93) | Draw; dialect syntax forced Hindi classifications on both. |
| TC-030 | Nepali | Nepali (0.59) | ne (0.47) | Both win; correctly classified interlingual false friend sentence. |
Nepali, Hindi, and Sanskrit share the Devanagari script. Very short or ambiguous text may therefore be difficult to classify.
Unknown is returned when there is insufficient evidence.
Supernova Language Detector V1 contains no neural-model weights.
Developed as part of the Supernova AI project. How to Use
Supernova Nepali Language Detector V1 is a deterministic language identification system. It does not require a neural model or GPU.
Installation
Clone or download this repository:
git clone https://huggingface.co/Supernova11c/Supernova-Nepali-Language-Detector-V1 cd Supernova-Nepali-Language-Detector-V1
Python Usage
from detector import detect_final_language
text = "नेपाल सुन्दर देश हो।"
result = detect_final_language(text)
print(result)
Example output:
{ "language": "Nepali", "confidence": 0.17, "script": "Devanagari" }
Supported Languages
Supernova V1 can identify:
Examples
from detector import detect_final_language
tests = [ "नेपाल सुन्दर देश हो।", "भारत एक विशाल देश है।", "संस्कृतं प्राचीनतमा भाषा अस्ति।", "Artificial intelligence is powerful.", "ma aaja school janchu", "म आज school जान्छु।", "xyz qqq zzz" ]
for text in tests: result = detect_final_language(text)
print(text)
print("Language:", result["language"])
print("Confidence:", result["confidence"])
print("Script:", result["script"])
print()
Output Fields
"language" — detected language or "Unknown".
"confidence" — confidence score between "0.0" and "1.0".
"script" — detected writing system:
Design
Supernova V1 is intentionally deterministic.
It does not use:
The detector uses language fingerprints, vocabulary statistics, character patterns, script analysis, and dedicated Nepali-Latin rules.
This makes the system lightweight, reproducible, and suitable for local/offline inference.
Verification
Supernova V1 passed its final standalone benchmark with 7/7 tests.
The release package was also independently imported and tested after packaging.
License
See the repository license and accompanying project files for licensing information.
Supernova text processing architecture is engineered for extreme, zero-overhead systems efficiency. Running entirely on standard CPU hardware without any GPU acceleration or heavy vector models, it delivers elite-tier throughput: