Registry / ai-ml / pyobjc-framework-naturallanguage

pyobjc-framework-naturallanguage

JSON →
library12.2pypypiunverified

PyObjC is a bridge between Python and Objective-C, enabling Python scripts to leverage Apple's Cocoa frameworks. This particular library, `pyobjc-framework-naturallanguage` (version 12.1), provides Python wrappers for the macOS NaturalLanguage framework, allowing applications to access native natural language processing capabilities on macOS. PyObjC releases generally align with macOS SDK updates.

pip install pyobjc-framework-naturallanguage
INSTALL
IMPORT
SIG · PYOBJC-FRAMEWORK-N
P
pyobjc-framework-naturallanguage
ai-mlpythonv12.2
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NaturalLanguage
import NaturalLanguage
NLTokenizer
from NaturalLanguage import NLTokenizer
NLLanguageRecognizer
from NaturalLanguage import NLLanguageRecognizer
NLTokenUnit
from NaturalLanguage import NLTokenUnit

This quickstart demonstrates basic text tokenization and language recognition using the NaturalLanguage framework. It first tokenizes a sentence into individual words and then identifies the dominant language of the text.

import NaturalLanguage from Foundation import NSMakeRange text_to_analyze = "The quick brown fox jumps over the lazy dog. This is a second sentence." # --- Tokenization Example --- # Create an NLTokenizer instance for word units tokenizer = NaturalLanguage.NLTokenizer.alloc().initWithUnit_(NaturalLanguage.NLTokenUnitWord) # Set the string to be tokenized tokenizer.setString_(text_to_analyze) tokens = [] # Enumerate tokens using a Python callable as the Objective-C block def token_block_handler(token_range, flags): start = token_range.location length = token_range.length token_text = text_to_analyze[start : start + length] tokens.append(token_text) return True # Return True to continue enumeration tokenizer.enumerateTokensInRange_usingBlock_( NSMakeRange(0, len(text_to_analyze)), token_block_handler ) print(f"Original text: '{text_to_analyze}'") print(f"Tokens (words): {tokens}") # --- Language Recognition Example --- lang_recognizer = NaturalLanguage.NLLanguageRecognizer.alloc().init() lang_recognizer.processString_(text_to_analyze) dominant_language = lang_recognizer.dominantLanguage() print(f"Dominant language: {dominant_language}")
Debug
Known issues
breakingPyObjC 12.0 dropped support for Python 3.9, and PyObjC 11.0 previously dropped support for Python 3.8. Users upgrading must ensure their environment uses Python 3.10 or newer.
fix
Upgrade Python to 3.10 or later before upgrading PyObjC to versions 11.0 or higher.
affects: >=11.0
gotchaThis library wraps macOS-specific frameworks and will only function on macOS. It is not compatible with other operating systems.
fix
Ensure the application is run on a macOS environment. Consider OS-agnostic alternatives if cross-platform compatibility is required.
affects: all
breakingPyObjC 10.3 introduced breaking changes to how `__init__` is handled in Python classes with custom `__new__` implementations. While 10.3.1 partially reverted this to allow `__init__` when a *user* implements `__new__`, classes relying on PyObjC's provided `__new__` still cannot use `__init__`.
fix
Review classes with custom `__new__` methods and their interaction with `__init__`. Adapt to PyObjC's specific rules or consider alternative initialization patterns.
affects: >=10.3, <11.0
breakingPyObjC 11.1 updated its Automatic Reference Counting (ARC) model for Objective-C initializer methods (those prefixed with 'init'). These methods now correctly model the behavior of 'stealing a reference to self and returning a new reference', which may affect memory management and require review of manual `alloc()`/`init_()` patterns.
fix
Test existing code thoroughly, especially where `alloc()` and `init_()` are used directly, to ensure correct reference counting behavior. Consult PyObjC's ARC documentation.
affects: >=11.1
gotchaApple's `NLTokenizer` documentation specifies that instances should be used on one thread or dispatch queue at a time. Failing to adhere to this can lead to unpredictable behavior or crashes in multi-threaded Python applications using this wrapper.
fix
Ensure each `NLTokenizer` instance is confined to a single thread or dispatch queue, or create separate instances for each concurrent task.
affects: all
Upgrade
Version history
12.2latest on PyPI · released May 30, 2026
Audit
Dependencies
pyobjc-corerequiredThe core bridge between Python and Objective-C, required for all PyObjC framework wrappers.
PythonrequiredRequires Python 3.10 or newer.
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources