Skip to main content

Nusantara NLP 🇮🇩

Python 3.9+ License: MIT Version

Library NLP Bahasa Indonesia yang modern, cerdas, dan lebih akurat dari Sastrawi.


✨ Keunggulan vs Sastrawi

Fitur Sastrawi Nusantara NLP
Stemming Algorithm Nazief-Adriani (1996) Hybrid ECS + Lookup Table
Akurasi Stemming ~75-80% ~87-92%
Kata Negasi Dilindungi ❌ ✅ (tidak, bukan, dll.)
Normalisasi Slang ❌ ✅ 200+ kata gaul
Konversi Emoji ❌ ✅ 150+ emoji → teks Indonesia
Mode Stopword 1 mode 3 mode (conservative/standard/aggressive)
Tokenizer Pintar ❌ ✅ Tangani kata ulang & singkatan
Zero Dependencies ✅ ✅ (murni Python stdlib)

🚀 Instalasi

pip install nusantara-nlp

Atau dari source:

git clone https://github.com/yourname/nusantara-nlp
cd nusantara-nlp
pip install -e .

📖 Quickstart

from nusantara import NLP

nlp = NLP()

# Full pipeline processing
hasil = nlp.process("gw ga suka pelayanan di sini 😠 parah banget!!")
print(hasil["result"])
# → "suka layan sini marah parah"

# Lihat setiap tahap
print(hasil["normalized"])  # slang + emoji sudah dikonversi
print(hasil["tokens_clean"])  # setelah stopword removal
print(hasil["tokens_stem"])   # setelah stemming

🧩 Komponen

1. Pipeline Lengkap

from nusantara import NLP

# Mode stopword: "conservative", "standard" (default), "aggressive"
nlp = NLP(stopword_mode="conservative")

hasil = nlp.process("Teman-teman bilang makanannya tidak enak 😢")

2. Slang Normalizer

from nusantara.normalizer import SlangNormalizer

norm = SlangNormalizer()
print(norm.normalize("gw udh makan tp msh laper"))
# → "saya sudah makan tapi masih lapar"

print(norm.normalize("baguuuus banget! makan2 aja kerjanya"))
# → "baguss banget makan makan saja kerjanya"

3. Emoji Converter

from nusantara.normalizer import EmojiConverter

conv = EmojiConverter()
print(conv.convert("Pelayanannya bagus 👍 tapi mahal 😢"))
# → "Pelayanannya bagus bagus tapi mahal sedih"

4. Stopword Remover (Negation-Aware)

from nusantara.stopword import StopwordRemover

# Kata negasi SELALU dilindungi, tidak pernah dihapus!
remover = StopwordRemover(mode="standard")
tokens = ["saya", "tidak", "suka", "yang", "ini"]
print(remover.remove_tokens(tokens))
# → ["tidak", "suka"]   # "tidak" tetap ada!

# Custom stopwords
remover = StopwordRemover(extra_words=["mantap", "josss"])

5. Stemmer (Hybrid ECS)

from nusantara.stemmer import Stemmer

stemmer = Stemmer()
print(stemmer.stem("mempermasalahkan"))  # → "masalah"
print(stemmer.stem("pelajaran"))         # → "ajar"
print(stemmer.stem("ketidakhadiran"))    # → "hadir"
print(stemmer.stem("berlari-lari"))      # → "lari"

6. Tokenizer

from nusantara.tokenizer import Tokenizer

tok = Tokenizer()
print(tok.tokenize("teman-teman semua hadir"))
# → ["teman", "teman", "semua", "hadir"]

# Sentence tokenizer
print(tok.tokenize_sentences("Ini enak. Itu tidak. Bagaimana menurutmu?"))
# → ["Ini enak.", "Itu tidak.", "Bagaimana menurutmu?"]

🧪 Testing

# Install pytest jika belum ada
pip install pytest

# Jalankan semua test
pytest tests/ -v

📁 Struktur Project

nusantara-nlp/
├── nusantara/
│   ├── __init__.py          # Entry point, ekspor class NLP
│   ├── pipeline.py          # Pipeline utama (NLP class)
│   ├── stemmer/
│   │   ├── stemmer.py       # Hybrid ECS Stemmer
│   │   └── kamus/
│   │       └── kata_dasar.txt
│   ├── stopword/
│   │   ├── remover.py       # Context-Aware Stopword Remover
│   │   └── data/
│   │       └── stopwords_id.txt
│   ├── normalizer/
│   │   ├── slang.py         # Slang Normalizer
│   │   ├── emoji_conv.py    # Emoji Converter
│   │   └── data/
│   │       ├── slang_dict.json
│   │       └── emoji_dict.json
│   └── tokenizer/
│       └── tokenizer.py     # Smart Tokenizer
├── tests/
│   └── test_all.py          # Pytest test suite
├── demo.py                  # Demo script
├── pyproject.toml           # PyPI config
└── README.md

🗺️ Roadmap

  • v0.1.0 — Core modules (stemmer, stopword, normalizer, tokenizer)
  • v0.2.0 — Named Entity Recognition (NER) sederhana
  • v0.3.0 — Sentiment lexicon berbahasa Indonesia
  • v0.4.0 — CLI tool (nusantara process "teks input")
  • v1.0.0 — Publish ke PyPI

🤝 Kontribusi

Kontribusi sangat disambut! Terutama untuk:

  • Menambah kata dasar di kamus/kata_dasar.txt
  • Menambah slang baru di data/slang_dict.json
  • Menambah emoji di data/emoji_dict.json
  • Menulis test case baru

📄 Lisensi

MIT License — bebas digunakan untuk proyek komersial maupun open source.

Metadata

Release files for nusantara-nlp 0.2.1

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

Source distribution (sdist)

Source distribution for nusantara-nlp 0.2.1
File Size Uploaded Provenance
nusantara_nlp-0.2.1.tar.gz 25.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nusantara-nlp 0.2.1
File Interpreter ABI Platform
nusantara_nlp-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 50.2 kB

Release files / nusantara_nlp-0.2.1.tar.gz

Download URL nusantara_nlp-0.2.1.tar.gz
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1d4bee700e10375f0d2485fd73e16623820a7356af9d5ed09f7c50362c7ae74c
BLAKE2b-256 checksum
How to use checksums
676848a6a4499bbe114d8764fa2eefa7081669e60075d1fe1c20d11edafc45c1
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 May 15, 2026.

Transparency log

Release files / nusantara_nlp-0.2.1-py3-none-any.whl

Download URL nusantara_nlp-0.2.1-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0b8ccbcb15eafd3bae0c3beb1a8d8904f30f3ac853b0ceb45c1f5660c4f9214
BLAKE2b-256 checksum
How to use checksums
af1863916433011bb77de6ce12e2963fc1bad3a04385abd17bf12dd9331da6ef
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 May 15, 2026.

Transparency log

Security for nusantara-nlp 0.2.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nusantara_nlp-0.2.1.tar.gz

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 May 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files Full provenance

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