PyNatural
Apple NaturalLanguage framework from Python — powered by Swift & ApplePy.
Zero model downloads — uses Apple's built-in on-device NLP models.
macOS only — requires Swift 6.0+ toolchain
Install
pip install -e .
Usage
import pynatural
# Language detection (60+ languages)
pynatural.detect_language("Bonjour le monde") # "fr"
# Tokenization (handles CJK natively)
pynatural.tokenize("東京は美しい", "word") # ["東京", "は", "美しい"]
# POS tagging
pynatural.tag("The quick brown fox", "pos")
# ["The", "Determiner", "quick", "Adjective", ...]
# Named Entity Recognition
pynatural.tag("Tim Cook visited Apple Park", "ner")
# ["Tim", "PersonalName", "Cook", "PersonalName", ...]
# Sentiment analysis
pynatural.sentiment("This is amazing!") # ~0.8
# Word embeddings
pynatural.embedding_distance("dog", "cat", "en") # small distance
pynatural.find_similar("python", "en", 5) # {"snake": 0.3, ...}
API
| Function | Returns | Description |
|---|---|---|
detect_language(text) |
str |
ISO language code |
detect_languages(text, max_results=5) |
dict[str, float] |
Languages with confidence |
tokenize(text, unit="word") |
list[str] |
Tokenize (word/sentence/paragraph) |
tag(text, scheme="pos") |
list[str] |
POS/NER/lemma tags (alternating token/tag) |
sentiment(text) |
float |
Score from -1.0 to 1.0 |
embedding_distance(w1, w2, lang="en") |
float |
Semantic distance |
find_similar(word, lang="en", n=5) |
dict[str, float] |
Similar words with distance |
Examples
See pynatural/examples/demo.py for a full demo.
License
BSD-3-Clause © Jagtesh Chadha — see LICENSE.
Metadata
Release files for pynatural 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pynatural-0.3.0.tar.gz | 8.8 kB | Without provenance | Details for pynatural-0.3.0.tar.gz |
Release files / pynatural-0.3.0.tar.gz
| Download URL | pynatural-0.3.0.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a9bfdcb3d89672c2c8aef504e700448e19539b43b075b19d103b3b5b44f8c13
|
|
BLAKE2b-256 checksum How to use checksums |
8763fc7ddcc3ea002c162899d970c81d588b96b1d78a41d81acd45c3c7534e9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for pynatural 0.3.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.