Library NLP Bahasa Indonesia modern โ Stemming, Stopword, Slang, Emoji, Tokenizer
Project description
Nusantara NLP ๐ฎ๐ฉ
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nusantara_nlp-0.1.0.tar.gz
(21.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nusantara_nlp-0.1.0.tar.gz.
File metadata
- Download URL: nusantara_nlp-0.1.0.tar.gz
- Upload date:
- Size: 21.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
add918d10ce8b7f23260fc275fe10e0c8f945db54727366a20f7255240a0f659
|
|
| MD5 |
e9851630f54d6adcb708e7b78b20f1c5
|
|
| BLAKE2b-256 |
6311302f506c256330b9a17f48ef51b65b91d1a425f1f3e80f22d5ec878c189e
|
File details
Details for the file nusantara_nlp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nusantara_nlp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc456defd7611734ccf17d0df7dd9fcdb021ba561acf9d151e173d25d5b1a60f
|
|
| MD5 |
169d3417ba69151da28af969ed8c333f
|
|
| BLAKE2b-256 |
909c25a9b4c5bae303947dbf5a79ad5ea78c687164d732539ae833eb1532c525
|