Skip to main content

A modern Python library for Korean josa processing with dictionary support and framework integrations.

Project description

한국어

korean_glue

CI Python License

A modern Python library for Korean josa processing combining rule-based and dictionary-based approaches. Django template tags and Jinja2 filters are included for easy web framework integration.

Installation

pip install korean_glue

Framework integrations rely on Django and Jinja2.

Usage

Basic API

Single-form patterns like , , or are also recognized and automatically expanded to their counterparts.

from korean_glue import attach, get_josa

print(get_josa("사과", "은/는"))  # "는"
print(attach("사과", "은/는"))    # "사과는"
print(get_josa("철수", "은"))    # "는"
print(attach("철수", "은"))      # "철수는"

Custom Exception Rules

from korean_glue import add_exception_rule, remove_exception_rule, attach

add_exception_rule("사과", "은/는", "당")
print(attach("사과", "은/는"))  # "사과당"
remove_exception_rule("사과", "은/는")

Command Line

Install the package and run the kglue command:

kglue '철수(은/는)'
kglue '철수(은)'
kglue 'K(이/가)'
kglue '3(을/를)'

Framework Integrations

Django

To use the filter, load the template tag library first:

{% load korean_glue.integrations.django_tags %}
{{ variable|josa:"을/를" }}

Alternatively add "korean_glue.integrations.django_tags" to OPTIONS['builtins'] in the TEMPLATES setting.

Jinja2

from korean_glue.integrations import jinja_filters
from jinja2 import Environment

env = Environment()
jinja_filters.register(env)
result = env.from_string("{{ word|josa('으로/로') }}").render(word="서울")

Running Tests

After setting up a development environment (see CONTRIBUTING.md), run:

pytest

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 Distribution

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

korean_glue-0.1.4-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file korean_glue-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: korean_glue-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for korean_glue-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 12970dc7aef7d5655c87bba294f117e83b2d87ee447ba164122e9dda98556017
MD5 e62aac6b5a21fe4532b789df115c8bbb
BLAKE2b-256 44387e7901f49b04b42690e895c15779ed8d7abb496d31c73e4392a323e6cd2e

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