# ocr.xml Configuration File Documentation
This document describes the `ocr.xml` configuration file used by Spire.OCR. Through this file, you can customize the model data path, dependent library path, and the language types to be recognized (including Chinese, Traditional Chinese, English, French, German, Japanese, and Korean).

## Configuration Parameters

### modelPath (Model Path)
- **Function**: Specifies the storage location of the language model data used by the OCR engine.
- **Type**: Relative path (relative to the `ocr.xml` file) or absolute path of the model directory.
- **Default Value**: `"model"`, which refers to the directory where the `ocr.xml` file is located.
- **Modification Notes**: You can modify this path to point to another directory storing model data. Ensure the new path is correct and the model data is compatible with the OCR engine.

### libPath (Library Path)
- **Function**: Specifies the storage path of the dependent libraries required by the OCR engine.
- **Type**: Relative path (relative to the `ocr.xml` file) or absolute path of the dependent library directory.
- **Default Value**: `"lib"`, which refers to the directory where the `ocr.xml` file is located.
- **Modification Notes**: If your dependent libraries are stored in other locations, you can modify this path. Verify the accuracy of the path and ensure all necessary dependent libraries are present.

### lang (Language Type)
- **Function**: Sets the languages to be recognized by the OCR engine, supporting system preset language packs and user-defined language models.
- **Format**: The folder name of the corresponding language pack (or custom model) under the model directory.
- **Default Value**: `"english"`.
- **Modification Notes**: Simply modify this value to the folder name of the required language pack/custom model. Ensure that a folder with the same name exists in the directory specified by `modelPath`, and the folder contains complete model data.

- **Language Pack Changes and Automatic Matching Rules Across Versions**:
  Early versions supported language packs including `Chinese`, `Chinesetraditional`, `English`, `French`, `German`, `Japan`, and `Korean`. The current version only retains core language packs: `ch`, `english`, `korean`, and `latin`. To ensure compatibility, the program has added an automatic matching logic:
  - If early-version language pack names (e.g., `Chinese`, `Chinesetraditional`, `Japan`) are set in the `lang` field, the program will first check whether the corresponding folders exist in the model directory. If not, it will automatically match the `ch` language pack for recognition (since `ch` supports mixed recognition of Chinese, English, and Japanese, covering the needs of the above languages).
  - If `French` or `German` are set, the program will first check the corresponding folders. If not found, it will automatically match the `latin` language pack (which supports recognition of multiple languages such as English, French, and German).

- **Preset Language Recognition Packs and Capabilities Supported in Current Version**:
  - `ch`: Supports mixed recognition of Chinese, English, and Japanese, covering Simplified Chinese, Chinese Pinyin, Traditional Chinese, English, and Japanese.
  - `english`: Only supports English recognition.
  - `korean`: Only supports Korean recognition.
  - `latin`: Supports multi-language recognition, covering English, French, German, and Latin.

- **Custom Language Recognition Model Notes**: The platform supports user-defined language recognition models. To use a custom model, there is no need to modify complex configurations. You only need to create a dedicated folder (the folder name can be customized, e.g., `"custom-lang"`) under the model directory specified by `modelPath`, and place the complete data of the custom model in the folder. Then fill in the name of this custom folder in the `lang` field to complete the configuration and use of the custom model.

## Important Notes
1. **Modification Restrictions**: Do not modify any fields other than `modelPath`, `libPath`, and `lang`. Modifying other parameters such as `platform` and `version` may cause the OCR engine to run abnormally or result in incorrect recognition results.
2. **Path Flexibility**: Both `modelPath` and `libPath` support relative and absolute paths, facilitating flexible management of OCR-related resources.
3. **Model/Language Pack Availability**: Before modifying the `lang` field, confirm that the corresponding preset language pack or custom model folder exists in the directory specified by `modelPath`, and the folder contains complete model data (preset packs need to ensure the integrity of the language pack, and custom models need to comply with engine compatibility specifications). For example, when setting `lang="ch"`, ensure that a language pack folder named `"ch"` exists in the model directory; when setting a custom model, ensure that the value of `lang` is exactly the same as the name of the custom folder.
4. **Target Platforms for Dependent Libraries**: Supported target platforms include Windows X64, macOS 10.15, and Linux Ubuntu 18.04 LTS. When using, ensure that the version of the dependent libraries used is not lower than the requirements of the above target platforms.
5. **Mixed Language Recognition Notes**: When using the `ch` or `latin` preset language packs, the OCR engine will automatically recognize all languages within the corresponding scope without separate switching, making it suitable for text recognition scenarios containing multiple languages.
6. **Custom Model Compatibility**: Custom models must be compatible with the current version of the Spire.OCR engine. It is recommended to develop based on the official model templates to avoid recognition failures caused by incompatible model formats.