SuperAPI AI Directory

hwp-analyze

General & other

View repository

Updated 10-15 23:26

About this skill

Hangul File Analysis

Input

$ARGUMENTS

Processing method by OS

Windows: Use pyhwpx (recommended)

On Windows + an environment with the Hangul program installed, use pyhwpx.

from pyhwpx import Hwp

hwp = Hwp()
hwp.open("서식.hwp")  # .hwp, .hwpx 모두 지원
Field list lookup

fields = hwp.get_field_list() print(fields)

Field value lookup

for field in fields: value = hwp.get_field_text(field) print(f"{field}: {value}")

hwp.quit()


**pyhwpx 설치**: `pip install pyhwpx`

### macOS/Linux: XML 직접 파싱 (.hwpx만 지원)

HWPX는 ZIP 형식의 압축 파일입니다.

hwpx file/ ├── Contents/ │ ├── section0.xml # Body content (first section) │ ├── section1.xml # Additional section (if any) │ └── header.xml # Header information ├── settings.xml # Document settings └── mimetype # File type information


#### 처리 절차

1. **압축 해제**
```bash
unzip -o {파일}.hwpx -d {임시디렉토리}/
  1. Read XML: Contents/section0.xml Read the file with the Read tool.

  2. XML structure analysis

Namespace: hp = http://www.hancom.co.kr/hwpml/2011/paragraph

Tag Meaning
<hp:tbl> 표 (table)
<hp:tr> 행 (table row)
<hp:tc> 셀 (table cell)
<hp:t> Text content
<hp:p> Paragraph

Table structure example:

<hp:tbl>
  <hp:tr>
    <hp:tc><hp:p><hp:t>필드명</hp:t></hp:p></hp:tc>
    <hp:tc><hp:p><hp:t>값</hp:t></hp:p></hp:tc>
  </hp:tr>
</hp:tbl>
  1. Field extraction: In a 2-column table, the first column is the field name, the second column is the value

  2. Clean up temporary files

rm -rf {임시디렉토리}

What to inform the user

  • Number of tables found
  • List of fields to fill (empty cells)
  • Fields already filled (if any)
  • Guidance for the next step (/hwp-fillfill with)

Caution

  • On macOS/Linux, .hwpis not supported → guide them to resave in Hangul as .hwpxguide to save again as
  • On Windows, pyhwpx supports both .hwp, .hwpx all supported
  • Complex tables (merged cells, etc.) may appear with a different structure