Skip to main content

Apple NaturalLanguage framework from Python — powered by Swift & ApplePy

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pynatural-0.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pynatural-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file pynatural-0.1.0.tar.gz.

File metadata

  • Download URL: pynatural-0.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pynatural-0.1.0.tar.gz
Algorithm Hash digest
SHA256 524689a0364fc2d0e2c6895c40d338eab8a6b92076a7a49dba0cd5d19419bff4
MD5 ac3a9cf22eb612baa62680b1d0d9e514
BLAKE2b-256 f1f698b03688020cb54b7ed0fc590d81dea442c31f3beae1a447ff0d12950a49

See more details on using hashes here.

File details

Details for the file pynatural-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pynatural-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pynatural-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e804ad4e841457b372f6ad878d40d46a9edcca5bb9a807776522b3c458c3aa76
MD5 56e35096cff83b87409f46053b1634df
BLAKE2b-256 45202bc6299b57329cfe877bdda79b063828ed49e038c6b1e28c8a02d853036f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page