Multi-tenant custom dictionary operation patterns
In an environment where several customers, teams, or workloads share one Bareun server, each needs to recognize a different vocabulary.
Bareun supports this multi-tenancy naturally through the custom dictionary and the custom_dict_names option.
You manage dictionaries with CustomDictionaryService and choose which dictionaries to use when you make an analysis request.
This document describes patterns for running separate dictionaries per user or per workload.
Core idea: split dictionaries by tenant
Create a dictionary per tenant (customer, team, or domain), and on each request specify that tenant's dictionary with custom_dict_names. If you specify several, the dictionary listed first takes priority.
graph TD T1[Tenant A] --> D1[dict-tenant-a] T2[Tenant B] --> D2[dict-tenant-b] S[Shared vocabulary] --> DC[dict-common] D1 --> REQ[AnalyzeSyntax<br/>custom_dict_names=dict-tenant-a, dict-common] DC --> REQ
Kinds of custom dictionary entries
A dictionary created with CustomDictionaryService can hold the following sets of entries.
| Set | Part of speech | Use |
|---|---|---|
np_set | Proper noun (NP) | Company names, product names, and so on |
cp_set | Compound noun (CP) | Compound nouns |
cp_caret_set | Compound noun split (CP^) | Mark the split point with ^ |
vv_set / va_set | Verbs and adjectives | Domain-specific predicates |
mm_set / mag_set / ic_set | Determiners, adverbs, interjections | Other parts of speech |
Specifying dictionaries in a request
from bareunpy import Tagger
tagger = Tagger("koba-XXXX-...", host="api.bareun.ai", port=443)
# Specify the tenant-specific dictionary first and the shared dictionary after it (the earlier one has priority).
res = tagger.tags(
["우리 제품 바른토크의 신규 기능을 소개합니다."],
custom_dict_names=["dict-tenant-a", "dict-common"],
)
In the morphemes of the analysis result, out_of_vocab is IN_CUSTOM_DICT, and custom_dict_name holds the name of the dictionary that was actually applied, so you can check which dictionary decided the word.
Zero-downtime updates
You can safely change custom dictionaries while the service is running. The Bareun server detects file changes in the dictionary directory in real time, and also checks periodically, so it reloads changes with zero downtime.
- Adding, editing, or deleting a dictionary takes effect without a server restart.
- If the same entry conflicts across several dictionaries, you can check in advance with
CheckConflict.
Check for conflicts between dictionaries in advance
If the same entry exists at the same time in several dictionaries such as NP/CP/CP^/VV/VA, it is reported as a conflict.
Before combining tenant dictionaries, checking duplicates (duplicated) and conflicts (conflict) with CheckConflict can reduce unexpected differences in analysis.
Frequently asked questions
Q. How do I make each tenant recognize a different vocabulary?
Create a custom dictionary per tenant, and specify that dictionary in custom_dict_names on each analysis request. If you specify several dictionaries together, the one listed first takes priority.
Q. Do I have to restart when I change a dictionary during operation?
No. The Bareun server detects file changes in the dictionary directory in real time and checks periodically, so it reloads changes with zero downtime. Changes take effect without a restart.
Q. Can I tell which dictionary decided a word?
If a morpheme's out_of_vocab is IN_CUSTOM_DICT, the word came from a custom dictionary, and custom_dict_name holds the name of the dictionary that was actually applied.