Skip to main content

Python bindings for the Panini morphological extraction engine.

Project description

panini-lang

Python bindings for Panini — an LLM-powered morphological feature extraction engine for any language.

Installation

pip install panini-lang

No other dependencies required. The package ships pre-compiled for macOS, Linux, and Windows.

Quick Start

from panini import extract

result = extract(
    provider="openai",        # "openai" | "anthropic" | "google"
    model="gpt-4o",
    api_key="sk-...",
    language="fra",           # ISO 639-3 code
    text="Je ne sais pas",
    targets=["sais"],
)

print(result)
# {
#   "target_features": [...],
#   "context_features": [...]
# }

Async Support

import asyncio
from panini import async_extract

async def main():
    result = await async_extract(
        provider="anthropic",
        model="claude-opus-4-5",
        api_key="sk-ant-...",
        language="pol",
        text="Nie wiem",
        targets=["wiem"],
    )
    print(result)

asyncio.run(main())

Supported Languages

from panini import supported_languages

supported_languages()
# ['pol', 'tur', 'ara', 'fra']
Code Language
pol Polish
tur Turkish
ara Arabic
fra French

Supported Providers

Provider provider= value Example model
OpenAI "openai" "gpt-4o"
Anthropic "anthropic" "claude-opus-4-5"
Google "google" "gemini-2.0-flash"

Analysis Components

By default, all compatible components are run. You can select specific ones:

result = extract(
    ...,
    components=["morphology", "pedagogical_explanation"],
)
Key Description
morphology POS tag, lemma, case/tense/gender/etc.
pedagogical_explanation HTML explanation for language learners
multiword_expressions Idioms, collocations, phrasal verbs
morpheme_segmentation Morpheme-by-morpheme breakdown (agglutinative languages only)
leipzig_alignment Leipzig-style interlinear glossing

Custom Prompts

Panini ships with built-in extraction prompts. You can override them by passing a YAML file path or a dict:

# From a YAML file
result = extract(..., prompts="/path/to/my_prompts.yml")

# From a dict
result = extract(..., prompts={
    "system_role": "You are a strict NLP extractor...",
    ...
})

# Inspect the built-in default prompts
from panini import get_default_prompts
print(get_default_prompts())

Full API Reference

extract(...) -> dict

Synchronous extraction.

Parameter Type Default Description
provider str required LLM provider: "openai", "anthropic", "google"
model str required Model name (e.g. "gpt-4o")
api_key str required Provider API key
language str required ISO 639-3 language code
text str required Sentence to analyse
targets list[str] required Target words to extract features for
prompts str | dict | None None Path to YAML, dict, or None for built-in defaults
temperature float 0.2 LLM temperature
max_tokens int 4096 Max output tokens
ui_language str "English" Language for pedagogical explanations
components list[str] | None None Components to run (all if None)

async_extract(...) -> dict

Asynchronous version of extract(). Same parameters, returns a coroutine.

supported_languages() -> list[str]

Returns the list of supported ISO 639-3 language codes.

get_default_prompts() -> dict

Returns the built-in extraction prompts as a Python dict.

version() -> str

Returns the current package version.

License

MIT

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

panini_lang-0.2.0-cp38-abi3-win_amd64.whl (6.4 MB view details)

Uploaded CPython 3.8+Windows x86-64

panini_lang-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.9 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

panini_lang-0.2.0-cp38-abi3-macosx_11_0_arm64.whl (7.2 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

panini_lang-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl (7.4 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file panini_lang-0.2.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: panini_lang-0.2.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 6.4 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for panini_lang-0.2.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 fb7d2a695ea9adeec21bac4350375507431d8ca885db10b6f3a995a4da42443e
MD5 f87c09777b9c39be0cb1a6034f25d972
BLAKE2b-256 08d5fc0508fa6826b6ebe7d4344a849263ecab9d9ca2f6d9e35318adab6f6a48

See more details on using hashes here.

Provenance

The following attestation bundles were made for panini_lang-0.2.0-cp38-abi3-win_amd64.whl:

Publisher: publish-panini-lang.yml on yro7/panini

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file panini_lang-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for panini_lang-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 15d169bcfdf43429018a1030d6bb042c6555d936396bd54467eb07135d3288de
MD5 3cde8e2bf6d11542aad6300fd993da4b
BLAKE2b-256 2b80f3fcd9d7643d4e91ef0aa248b167c376bd2d68080ca7869fa26979e257db

See more details on using hashes here.

Provenance

The following attestation bundles were made for panini_lang-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-panini-lang.yml on yro7/panini

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file panini_lang-0.2.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for panini_lang-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7e3ffa988204ec7451ecfd81a358532f67a86fa5cc8c03a79029ed3bfd291393
MD5 f01922e945e9009bb223437a7145cd49
BLAKE2b-256 45ef911600ff41d5940b04a0872ad61883dc9404b1ed35ae11968eb6db3c488e

See more details on using hashes here.

Provenance

The following attestation bundles were made for panini_lang-0.2.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: publish-panini-lang.yml on yro7/panini

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file panini_lang-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for panini_lang-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4ef015d2659463be310bc4a4ca4bef299ce13ca55cafe310bf646c9a77333cc7
MD5 83b2fe7a5cf30b03d54a7348b62886e9
BLAKE2b-256 fd84f54a924daac86c70d4bb43652bd7148b1c092a66e03fd6f853cd6162efbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for panini_lang-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: publish-panini-lang.yml on yro7/panini

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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