home / skills / openclaw / skills / tc-dict

tc-dict skill

/skills/kai-tw/tc-dict

This skill enables fast lookup of traditional Chinese dictionary definitions from MOE Taiwan, with automatic updates and version control.

npx playbooks add skill openclaw/skills --skill tc-dict

Review the files below or copy the command above to add this skill to your agents.

Files (9)
SKILL.md
4.9 KB
---
name: openclaw-tc-dict-skill
description: Query Traditional Chinese dictionaries from Ministry of Education (MOE) Taiwan. Supports looking up word definitions from the "國語辭典簡編本" (Concised Mandarin Dictionary) with automatic version management and optional periodic updates. Use when you need to look up Chinese word meanings, check definitions, or ensure you have the latest dictionary data.
---

# OpenClaw Traditional Chinese Dictionary Skill

## Installation

This skill requires Python dependencies. Install them with `uv`:

```bash
# Install dependencies (recommended: use uv for faster installation)
uv pip install -r requirements.txt

# Alternative: use pip if uv is not available
pip install -r requirements.txt
```

**Required packages:**
- `pandas>=2.0.0` — Data processing
- `openpyxl>=3.1.0` — Excel file reading

## Security

This skill implements the following security measures:

✅ **TLS Certificate Verification** — All HTTPS connections to MOE servers use proper SSL/TLS certificate validation (no disabled verification)

✅ **Zip-Slip Protection** — Dictionary downloads validate all zip file paths before extraction to prevent directory traversal attacks (path validation applied)

✅ **Safe File Handling** — Extracted files are validated and stored in user-isolated directory (`~/.openclaw/dictionaries/`)

⚠️ **Cron/Automatic Updates** — If you enable automatic updates via cron, the skill will download dictionary files from MOE on your specified schedule. Consider the frequency and enable notifications to track changes.

## Overview

This skill enables you to query Traditional Chinese dictionaries published by Taiwan's Ministry of Education. It provides:

- **Word lookup** — Search for word definitions with automatic fuzzy matching
- **Dictionary management** — Download, extract, and version-control dictionary data
- **Update automation** — Automatic periodic checks (cron) + manual update requests
- **Extensible design** — Currently supports "國語辭典簡編本" (Concised Dictionary), with room for other MOE dictionaries in the future

## Core Capabilities

### 1. Query Words

Users can look up words using natural language like:
- "請告訴我『蒼鷺』的意思" (Tell me the meaning of '蒼鷺')
- "查『梅雨』" (Look up '梅雨')
- "『破曉』是什麼意思?" (What does '破曉' mean?)

The skill returns the primary definition first. If the user asks for details, provide:
- Full definition
- Examples/usage
- Related information from the dictionary

**Implementation**: See `query_dictionary.py` for the search logic.

### 2. Manage Dictionary Updates

Users can trigger updates in two ways:

**Manual update:**
- "更新字典" (Update dictionary)
- "重新下載國語辭典" (Re-download the dictionary)

**Automatic update (cron):**
- Set up a cron job to check for updates monthly
- Compare local version (stored in metadata.json) against MOE's latest version
- Download and extract only if a newer version exists

**Implementation**: See `download_dictionary.py` for download/extraction logic and `check_updates.py` for version management.

## Configuration

The skill respects a configuration file at `~/.openclaw/dictionaries/config.json`:

```json
{
  "storage_path": "~/.openclaw/dictionaries",
  "auto_update_interval_days": 30,
  "dictionaries": {
    "concised": {
      "enabled": true,
      "name": "國語辭典簡編本",
      "source": "https://language.moe.gov.tw/001/Upload/Files/site_content/M0001/respub/dict_concised_download.html"
    }
  }
}
```

Users can customize `storage_path` to store dictionaries elsewhere. The default is `~/.openclaw/dictionaries/`.

## Usage Examples

### Example 1: Simple word lookup
```
User: "請告訴我『藍寶石』的意思"
Response: 藍寶石:寶石名。紅玉髓的一種。(如需詳細資料,請告訴我)
```

### Example 2: Request with details
```
User: "『藍寶石』是什麼意思?告訴我更多"
Response: 藍寶石:寶石名。紅玉髓的一種。
例句:...
相關詞語:...
```

### Example 3: Manual update
```
User: "更新字典"
Response: 正在檢查最新版本...
當前版本:2025-12-29
最新版本:[Latest from MOE]
[如果有更新] 已更新字典至最新版本 (2025-12-29)
[如果無更新] 字典已是最新版本
```

## Bundled Resources

### scripts/
- `download_dictionary.py` — Download zip from MOE, extract, parse xlsx, store locally
- `query_dictionary.py` — Search dictionary data, return definitions and optional details
- `check_updates.py` — Query MOE website for version info, compare with local metadata

See [DICTIONARY_SOURCES.md](references/DICTIONARY_SOURCES.md) for data source URLs and version tracking.

### references/
- `DICTIONARY_SOURCES.md` — All MOE dictionary sources, update URLs, version history
- `SCHEMA.md` — xlsx structure documentation (columns, formats, data layout)

For setting up cron jobs to monitor updates, reference the `scripts/check_updates.py` documentation.

Overview

This skill queries Traditional Chinese dictionaries published by Taiwan's Ministry of Education and returns word definitions, examples, and related information. It manages dictionary files locally with version control and supports manual or scheduled automatic updates. The design focuses on reliable downloads, safe extraction, and fuzzy matching for flexible lookups. Ideal for developers or users who need authoritative Traditional Chinese definitions offline or integrated into other tools.

How this skill works

The skill downloads official dictionary packages from MOE, validates and extracts them into a user-isolated storage path, and parses the Excel data into searchable records. A query module performs exact and fuzzy matching to return primary definitions first, with optional expanded details such as usage examples and related terms. A version-checking component compares local metadata to MOE release info and triggers downloads only when a newer version is available; it can run on demand or via cron.

When to use it

  • You need authoritative Traditional Chinese definitions from Taiwan's Ministry of Education.
  • You want to integrate offline or local dictionary lookups into an application or bot.
  • You need automatic version-managed dictionary updates to stay current.
  • You require safe downloading and extraction with zip-slip protection and TLS verification.
  • You want fuzzy matching for flexible word lookup when exact forms may vary.

Best practices

  • Keep auto-update frequency reasonable (e.g., monthly) to avoid unnecessary downloads and to track meaningful changes.
  • Configure storage_path to a persistent, backed-up directory if used in production workflows.
  • Enable notifications or logs for automated updates so you can audit changes to dictionary data.
  • Validate user input and normalize text before querying to improve fuzzy-match accuracy.
  • Run periodic integrity checks on extracted files to detect corruption early.

Example use cases

  • Ask for a word meaning and get the primary definition with an option to request full details and examples.
  • Embed the skill in a chatbot to answer Traditional Chinese vocabulary queries with up-to-date MOE data.
  • Set a cron job to check for new MOE dictionary releases and auto-pull updates into a local research dataset.
  • Use the parsed Excel data in linguistic analysis pipelines or language-learning apps requiring authoritative definitions.
  • Provide offline dictionary service for environments with limited connectivity by maintaining local copies and version metadata.

FAQ

How are downloads secured?

All HTTPS connections use standard TLS certificate verification and zip extraction validates paths to prevent directory traversal.

Can I control update frequency?

Yes. The config allows setting auto_update_interval_days and you can enable or disable automatic updates; manual updates are also supported.

Where are dictionaries stored?

By default they go to a user-isolated directory, but storage_path in the config can be changed to any writable location.