{"library":"pyobjc-framework-naturallanguage","title":"PyObjC NaturalLanguage Framework","description":"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.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pyobjc-framework-naturallanguage"],"cli":null},"imports":["import NaturalLanguage","from NaturalLanguage import NLTokenizer","from NaturalLanguage import NLLanguageRecognizer","from NaturalLanguage import NLTokenUnit"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import NaturalLanguage\nfrom Foundation import NSMakeRange\n\ntext_to_analyze = \"The quick brown fox jumps over the lazy dog. This is a second sentence.\"\n\n# --- Tokenization Example ---\n# Create an NLTokenizer instance for word units\ntokenizer = NaturalLanguage.NLTokenizer.alloc().initWithUnit_(NaturalLanguage.NLTokenUnitWord)\n\n# Set the string to be tokenized\ntokenizer.setString_(text_to_analyze)\n\ntokens = []\n# Enumerate tokens using a Python callable as the Objective-C block\ndef token_block_handler(token_range, flags):\n    start = token_range.location\n    length = token_range.length\n    token_text = text_to_analyze[start : start + length]\n    tokens.append(token_text)\n    return True  # Return True to continue enumeration\n\ntokenizer.enumerateTokensInRange_usingBlock_(\n    NSMakeRange(0, len(text_to_analyze)),\n    token_block_handler\n)\n\nprint(f\"Original text: '{text_to_analyze}'\")\nprint(f\"Tokens (words): {tokens}\")\n\n# --- Language Recognition Example ---\nlang_recognizer = NaturalLanguage.NLLanguageRecognizer.alloc().init()\nlang_recognizer.processString_(text_to_analyze)\ndominant_language = lang_recognizer.dominantLanguage()\nprint(f\"Dominant language: {dominant_language}\")\n","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":null,"pypi_latest":"12.1","is_stale":null,"summary":{"python_range":"3.10–3.9","success_rate":0,"avg_install_s":null,"avg_import_s":null,"wheel_type":null},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyobjc-framework-naturallanguage","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyobjc-framework-naturallanguage","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.1,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyobjc-framework-naturallanguage","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyobjc-framework-naturallanguage","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.1,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyobjc-framework-naturallanguage","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyobjc-framework-naturallanguage","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyobjc-framework-naturallanguage","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyobjc-framework-naturallanguage","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.7,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyobjc-framework-naturallanguage","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyobjc-framework-naturallanguage","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.9,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}