Processing legal documents: combining a custom dictionary with correction
Legal documents require both fixed legal terms and strict spelling and notation.
If a term is not recognized as one word, article search goes off, and if the notation is inconsistent, trust in the document drops.
Bareun fixes legal terms with a custom dictionary and polishes the notation with the spell checker, solving both problems together.
The problem
- Legal terms such as
손해배상청구권(right to claim damages) and채무불이행(default on an obligation) get split into several nouns, and article search misses. - Typos and word spacing errors undermine the accuracy of legal documents.
- Terms specific to law are not in general dictionaries, so they easily become out-of-vocabulary words (OOV).
How to apply Bareun
Combine two steps. First, clean up the notation with the spell check API (CorrectError),
then run morphological analysis with the legal-term custom dictionary (np_set) applied so the terms are recognized as single words.
For how to lock terms in with a dictionary, see Domain dictionary workflow.
graph TD DOC[Legal document] --> COR[Spell check CorrectError]; COR --> CLEAN[Document with cleaned notation]; CLEAN --> DICT[Legal-term custom dictionary]; DICT --> TAG[Bareun morphological analysis]; TAG --> RESULT[Accurate term recognition + indexing];
from bareunpy import Tagger
tagger = Tagger("koba-XXXX-...", "localhost")
# Register legal terms in the proper noun dictionary
# (right to claim damages, default on an obligation, statute of limitations)
cust = tagger.custom_dict("legal_terms")
cust.copy_np_set({"손해배상청구권", "채무불이행", "공소시효"})
cust.update()
tagger.set_domain("legal_terms")
res = tagger.tags(["채무불이행에 따른 손해배상청구권이 발생한다."])
print(res.nouns())
['채무불이행', '손해배상청구권']
The legal terms stay as single words and are not split.
Results and benefits
| Step | Tool | Effect |
|---|---|---|
| Clean the notation | Spell check API | Corrects typos and word spacing |
| Lock in terms | Custom dictionary (np_set) | Keeps legal terms as single words |
| Index and search | Morphological analysis | Keeps article search consistent |
The spell checker is a paid feature
Bareun's spell checker (CorrectError) is a paid, cloud-only feature.
Used together with morphological analysis, it handles everything from input cleanup to term recognition in a single flow.
Frequently asked questions
Q. Should I run correction or analysis first?
Notation errors can interfere with morphological analysis, so it is safer to correct first and then analyze.
Pass the revised sentence from the correction result to the analysis.
Q. What if a legal term conflicts with another dictionary?
A conflict can occur when the same headword exists in several dictionaries at once.
Use CheckConflict to check in advance for duplicates within a dictionary and conflicts between dictionaries.
The priority when using several dictionaries together is covered in Dictionary priority.
Q. Won't correction change legal terms by mistake?
Terms registered in the custom dictionary are protected at the analysis stage. At the correction stage as well, expressions recognized as proper nouns are handled so they avoid excessive changes.
Q. How do I manage and version the legal-term dictionary?
Register and update legal terms through the CustomDictionaryService API (UpdateCustomDictionary).
The dictionary files on the server are in a binary format managed by the server, so you do not edit them directly. For version control, we recommend
keeping your term list source (text) in Git and applying changes through the API.
Related documents
- Getting started with the spell checker: clean up notation with
CorrectError - Domain dictionary workflow: lock legal terms in with a dictionary
- Dictionary priority: how conflicts between dictionaries are handled