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
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.2.1.tar.gz.
File metadata
- Download URL: nusantara_nlp-0.2.1.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d4bee700e10375f0d2485fd73e16623820a7356af9d5ed09f7c50362c7ae74c
|
|
| MD5 |
b56c54110f0781a0b2c1ec345e505064
|
|
| BLAKE2b-256 |
676848a6a4499bbe114d8764fa2eefa7081669e60075d1fe1c20d11edafc45c1
|
Provenance
The following attestation bundles were made for nusantara_nlp-0.2.1.tar.gz:
Publisher:
publish.yml on aziez/nusantara-nlp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nusantara_nlp-0.2.1.tar.gz -
Subject digest:
1d4bee700e10375f0d2485fd73e16623820a7356af9d5ed09f7c50362c7ae74c - Sigstore transparency entry: 1548749896
- Sigstore integration time:
-
Permalink:
aziez/nusantara-nlp@9dede841aea369d8aa6d14c1a002a3c7cf85d9ba -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/aziez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9dede841aea369d8aa6d14c1a002a3c7cf85d9ba -
Trigger Event:
push
-
Statement type:
File details
Details for the file nusantara_nlp-0.2.1-py3-none-any.whl.
File metadata
- Download URL: nusantara_nlp-0.2.1-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0b8ccbcb15eafd3bae0c3beb1a8d8904f30f3ac853b0ceb45c1f5660c4f9214
|
|
| MD5 |
b803c8269654eb27b3f768be26a35f06
|
|
| BLAKE2b-256 |
af1863916433011bb77de6ce12e2963fc1bad3a04385abd17bf12dd9331da6ef
|
Provenance
The following attestation bundles were made for nusantara_nlp-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on aziez/nusantara-nlp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nusantara_nlp-0.2.1-py3-none-any.whl -
Subject digest:
a0b8ccbcb15eafd3bae0c3beb1a8d8904f30f3ac853b0ceb45c1f5660c4f9214 - Sigstore transparency entry: 1548749915
- Sigstore integration time:
-
Permalink:
aziez/nusantara-nlp@9dede841aea369d8aa6d14c1a002a3c7cf85d9ba -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/aziez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9dede841aea369d8aa6d14c1a002a3c7cf85d9ba -
Trigger Event:
push
-
Statement type: