Skip to main content

bareun-baropy

Bareun Korean morphological analyzer as a Python package. 한국어 형태소 분석기 바른(Bareun)을 pip install 한 번으로 쓰는 파이썬 패키지입니다.

The analysis server binary is bundled in the wheel, so there is nothing else to install and no server to run. The package starts the server for you, analyzes text, and shuts it down when you are done. This release covers morphological analysis only (no spelling correction API).

Install

pip install bareun-baropy
  • Python 3.10 or later.
  • Platforms (CPU only):
    • Linux x86_64 (glibc 2.28+) and Linux aarch64 (glibc 2.34+)
    • macOS on Apple silicon (arm64, signed and notarized)
    • Windows x64 (tested) and Windows ARM64 (built for ARM64 but not yet tested on real hardware; please report problems)
  • The package version follows the Bareun release it ships. 3.4.x contains the Bareun 3.4.0 server (3.4.1 only fixes the package description).

Quick start

An API key is required. Get one at https://bareun.ai/. It is registered automatically on the first call. Pass it as api_key= or set the BAREUN_API_KEY environment variable.

import baropy

with baropy.Bareun(api_key="koba-...") as b:          # or: export BAREUN_API_KEY=koba-...
    res = b.analyze("나는 책을 읽었다.")
    print(res.morphemes.pairs())                      # [('나', 'NP'), ('는', 'JX'), ('책', 'NNG'), ...]
    print(res.morphemes.nouns().texts())              # ['책']

The first call downloads the model into your user cache folder (it is not part of the wheel) and can take a while. Later calls start in seconds. baropy fetch downloads the model ahead of time.

For one-off scripts, module-level functions share a single default object (the key comes from BAREUN_API_KEY):

import baropy
print(baropy.analyze("바른 형태소 분석기").morphemes.pairs())
baropy.release()                                      # unload the model when finished

Results

analyze() returns an Analysis > Sentence > Token (eojeol) > Morpheme tree. All objects are read-only.

res = b.analyze("하늘이 맑다. 구름이 없다.")
for sent in res.sentences:
    for tok in sent.tokens:
        print(tok.text, tok.morphemes.tagged())       # e.g. 하늘이 하늘/NNG 이/JKS

res.morphemes.verbs().texts()                         # filter by part of speech
res.morphemes.frequency(top=5)                        # most frequent morphemes: [(text, count), ...]
  • b.analyze(["문장 하나", "문장 둘"]) takes a list; res.sentences[i] matches input i.
  • b.analyze(text, sense=True) adds word sense (WSD) results to each morpheme.
  • b.tokenize(text) splits text into eojeol only.
  • MorphemeSeq helpers: texts, pairs, tagged, select, where, nouns, verbs, adjectives, adverbs, tokens, stats, tag_counts, frequency.

Custom dictionaries

Add your own words by domain name, then use them per call or as defaults.

b.dicts.put("lab", np=["바른"], cp=["형태소분석기"])    # replaces the whole dictionary "lab"
b.analyze("바른 형태소분석기", dicts="lab")
b.default_dicts = ["lab"]                             # use it on every call
b.dicts.list()                                        # see what is registered
b.dicts.remove("lab")

Kinds: np, cp, cp_caret (compound split), vv, va, mm, mag, ic. Names may contain only letters, digits, _ and - (lower-cased).

Options

baropy.Bareun(
    api_key=None,            # or BAREUN_API_KEY
    idle_timeout=3600.0,     # unload the model after this many idle seconds (None: never)
    session_timeout=None,    # hard limit for one session
    background=False,        # True: leave a detached server running (server mode)
    cache_dir=None,          # model and runtime files (default: user cache folder)
    threads=4,
    start_timeout=1800.0,    # how long to wait for the first model download
)

By default the server is a hidden child process bound to 127.0.0.1 on a random port. It is tied to your Python process and exits with it. With background=True it runs as a detached server on a fixed port instead; in that mode anyone on the machine who can reach the port can use the registered key, so use it only on machines you trust.

Cache folders: Linux ~/.cache/bareun, macOS ~/Library/Caches/bareun, Windows %LOCALAPPDATA%\bareun\Cache.

Command line

baropy help       open the documentation for the installed version
baropy version    print the package version
baropy fetch      download the model ahead of time (key from BAREUN_API_KEY)
baropy serve      run server mode in this terminal (Ctrl-C to stop)
baropy stop       stop a server started in server mode
baropy register   register BAREUN_API_KEY with a running server

Errors

All errors derive from baropy.BaropyError: AuthError (key rejected), ModelFetchError (model download failed), ServerStartError (server did not start), AnalysisError (the call failed).

Documentation and license

Metadata

Release files for bareun-baropy 3.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for bareun-baropy 3.4.1
File Actions
bareun_baropy-3.4.1-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for bareun_baropy-3.4.1-py3-none-win_arm64.whl
bareun_baropy-3.4.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for bareun_baropy-3.4.1-py3-none-win_amd64.whl
bareun_baropy-3.4.1-py3-none-manylinux_2_34_aarch64.whl Python 3 none Linux glibc 2.34+ ARM64 Details for bareun_baropy-3.4.1-py3-none-manylinux_2_34_aarch64.whl
bareun_baropy-3.4.1-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for bareun_baropy-3.4.1-py3-none-manylinux_2_28_x86_64.whl
bareun_baropy-3.4.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for bareun_baropy-3.4.1-py3-none-macosx_11_0_arm64.whl

Total release size: 74.5 MB

Release files / bareun_baropy-3.4.1-py3-none-win_arm64.whl

Download URL bareun_baropy-3.4.1-py3-none-win_arm64.whl
Size 11.6 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
1aa547d7e368201a95de26b8a516bb962debcb4e26ff85585353ae30eb8ef296
BLAKE2b-256 checksum
How to use checksums
28827a836a705fb257568979e7653470d09137188ee9fb0687b5b9f0a315fa73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-142-generic

Release files / bareun_baropy-3.4.1-py3-none-win_amd64.whl

Download URL bareun_baropy-3.4.1-py3-none-win_amd64.whl
Size 12.4 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
285f852c72a356eb2e4b85e6d1d93f637a31753406dc16e695bf8e008c95b268
BLAKE2b-256 checksum
How to use checksums
609874e024412e398e72479669891179e405bb80cfacee508347886caba5ed7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-142-generic

Release files / bareun_baropy-3.4.1-py3-none-manylinux_2_34_aarch64.whl

Download URL bareun_baropy-3.4.1-py3-none-manylinux_2_34_aarch64.whl
Size 15.4 MB
Tags Linux glibc 2.34+ ARM64 Python 3
SHA-256 checksum
How to use checksums
c02d716bb87c8eea5258173220b74297be57c2b587295a607c1bb9e5c6e40502
BLAKE2b-256 checksum
How to use checksums
bd0a8e1c4a57d734e20186fc60574d71a1a1e3c7128c386e940ec8cc444308f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-142-generic

Release files / bareun_baropy-3.4.1-py3-none-manylinux_2_28_x86_64.whl

Download URL bareun_baropy-3.4.1-py3-none-manylinux_2_28_x86_64.whl
Size 17.1 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
83e70115c780d58491691de5332fe33f8ee8ed2934fbd5e16000b7b8554af8cf
BLAKE2b-256 checksum
How to use checksums
0b1eaef44ca6a9b3c8218d97472098fc13cd83405f272c9d881462209d3c39e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-142-generic

Release files / bareun_baropy-3.4.1-py3-none-macosx_11_0_arm64.whl

Download URL bareun_baropy-3.4.1-py3-none-macosx_11_0_arm64.whl
Size 18.1 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5f800a71b5cf81efb15aec1cc304633d72fd5ea44c4cb0d6e8eed96b75bba9a3
BLAKE2b-256 checksum
How to use checksums
d0710ed0f94546d398cccbd184ff6aff5574ddafad846a21cfc79469ebc27202
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-142-generic

Security for bareun-baropy 3.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.4.1 This release

5 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page