Custom dictionary conflict check: conflict scenarios and resolution guide
As a custom dictionary grows and domains multiply, the same word easily ends up duplicated across different dictionaries,
producing analysis results you did not intend. Bareun provides a conflict check
(CheckConflict) that catches this in advance.
This page covers the two kinds of problems (duplicate duplicated and conflict conflict), typical scenarios, and how
to resolve them.
The two things the conflict check catches
CheckConflict inspects the dictionary you are about to register and reports two kinds of problems.
| Type | Meaning | Example |
|---|---|---|
duplicated | The same headword appears two or more times within one dictionary | 민식이법 appears twice in np_set |
conflict | The same headword appears at the same time in different dictionaries | 세종 is in both np_set and cp_set |
The result comes back as Conflict information. It contains which side (left/right) and which word
(left_word/right_word) collided, whether it is a conflict or a duplicate (conflict/duplicated),
and a human-readable explanation (conflict_msg).
Why are conflicts a problem?
If the same headword is in several dictionaries (NP/CP/CP^/VV/VA) at the same time, it becomes ambiguous which part of speech
Bareun should assign to that word. For example, if you register 세종 as both a proper noun and a compound noun, the analysis result
may be inconsistent. The conflict check exposes this ambiguity before you register.
Typical conflict scenarios
graph TD
A[Check headword] --> B{Appears twice in<br>the same dictionary?};
B -- Yes --> DUP[duplicated];
B -- No --> C{Same word in a<br>different kind of dictionary?};
C -- Yes --> CON[conflict];
C -- No --> OK[OK];
- Scenario 1: conflict between noun dictionaries:
세종is registered in both the proper noun dictionary (np_set) and the compound noun dictionary (cp_set). It is ambiguous whether to treat it asNNPorNNG, so it is a conflict. - Scenario 2: conflict between a noun and a predicate:
빛나다is registered in the adjective dictionary (va_set), and빛나is also registered as a proper noun. They are recognized as the same headword, and the intended parts of speech collide. - Scenario 3: duplicate within one dictionary:
압수수색appears twice in one noun dictionary. It is reported as duplicated. - Scenario 4: duplicate across domains: Even if the same word exists in different domains, using them together may apply an unintended priority, so it is safer to check in advance.
Pre-registration check flow
Run the conflict check before registering (UpdateCustomDictionary).
from bareunpy import Tagger
my_tagger = Tagger('YOUR-API-KEY', 'localhost', port=5656)
cust_dic = my_tagger.custom_dict("law_terms")
cust_dic.copy_np_set({'민식이법', '세종'})
cust_dic.copy_cp_set({'압수수색', '세종'}) # '세종' is in two dictionaries -> a conflict is expected
# Check for conflicts before registering
conflicts = cust_dic.check_conflict()
if conflicts:
print("Conflict found:", conflicts) # check left/right and conflict_msg
else:
cust_dic.update()
Conflict found: '세종' is in both the proper noun dictionary (np_set) and the compound noun dictionary (cp_set) at the same time (conflict)
Conflict resolution guide
Steps to resolve a conflict
- Decide on a single part of speech. If
세종is a person or place name, keep it only in the proper noun dictionary. - Remove duplicates (
duplicated) and keep just one. There is no need to register the same word twice in the same dictionary. - If you need both usages, separate the domains. For example, keep it as a proper noun in one domain
and as a compound noun in another, and choose between them with
custom_dict_nameswhen you call. - After cleaning up, run
CheckConflictagain to confirm it is clean.
If you ignore conflicts
If you register with conflicts left in, analysis results may vary depending on the input and context. We recommend keeping the production dictionary at zero conflicts at all times.
Frequently asked questions
Q. What is the difference between duplicated and conflict?
duplicated is when the same headword is repeated within one dictionary, and conflict is when the same headword is present
at the same time in different kinds of dictionaries (NP/CP/CP^/VV/VA).
Q. When should I run the conflict check?
It is best to run it right before registering the dictionary (UpdateCustomDictionary).
If you add it to a CI pipeline and check automatically on every dictionary change, you can keep the production dictionary clean at all times.
Q. What if I really need to use the same word as two parts of speech?
Separate the domains. Register it as a proper noun in one domain and as a compound noun in another, and when you analyze,
select the domain you need with custom_dict_names. That way you can use both without a conflict.