# What Is the Purpose of wanxiang_reverse.dict.yaml? Understanding Rime Wanxiang Reverse Lookup

> Discover the purpose of wanxiang_reverse.dict.yaml for Rime Wanxiang. Input Chinese characters using component radicals and stroke patterns for efficient typing.

- Repository: [amzxyz/rime_wanxiang](https://github.com/amzxyz/rime_wanxiang)
- Tags: deep-dive
- Published: 2026-02-24

---

**[`wanxiang_reverse.dict.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang_reverse.dict.yaml) serves as the reverse-lookup dictionary for the Wanxiang Rime input method, enabling users to input Chinese characters by typing component radicals or stroke patterns instead of full codes.**

This file powers the "component assembly" (部件拆字) feature in the `amzxyz/rime_wanxiang` repository, allowing you to construct characters by combining their constituent parts or query them via stroke sequences. When paired with its schema configuration, it transforms how users interact with the input method—particularly for rare characters or when you remember a character's shape but not its pronunciation.

## How Reverse Lookup Works in Wanxiang

The reverse-lookup system bridges the gap between visual character components and their digital representation. Unlike standard input where you type phonetic or structural codes to get characters, reverse lookup lets you query the database using partial components.

### Component-to-Character Mapping

The dictionary stores **bidirectional mappings** between component strings and Chinese characters. Each entry follows a tab-separated format where the character precedes its component code:

```yaml

# wanxiang_reverse.dict.yaml excerpt

雨   yu
辰   if   # stroke-type code for "辰"

震   yuif

```

When you type `` ` `` followed by component combinations like `yuif` (representing 雨 + 辰), the engine queries [`wanxiang_reverse.dict.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang_reverse.dict.yaml) and returns **震** as a candidate. The system also supports stroke-based queries using sequences like `hspzn`, `hupvd`, or `hslzy` to locate characters by their stroke patterns.

### Schema Integration Points

The reverse-lookup functionality is wired into the main schemas through specific translator attachments. In [`wanxiang.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang.schema.yaml) and [`wanxiang_t9.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang_t9.schema.yaml), the following configuration activates the feature:

```yaml
engine:
  segmentors:
    - affix_segmentor@wanxiang_reverse   # adds the reverse-lookup tag

  translators:
    - reverse_lookup_translator@wanxiang_reverse

```

The [`wanxiang_reverse.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang_reverse.schema.yaml) file defines the trigger mechanism with a recognizer pattern that matches `` ` `` followed by alphabetic characters:

```yaml
recognizer:
  patterns:
    wanxiang_reverse: "^`[A-Za-z]*$"

```

When this pattern matches, the segment is tagged and processed by the `table_translator`, which reads [`wanxiang_reverse.dict.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang_reverse.dict.yaml) to generate candidates.

## Triggering Reverse Lookup in Practice

To use the reverse-lookup feature in any Wanxiang layout, switch to the default mode and type the **backtick prefix** `` ` `` followed by component codes:

```text
`yuif

```

- `` ` `` – The reverse-lookup prefix (disappears after conversion)
- `yu` – Component code for "雨"
- `if` – Component code for "辰" (stroke representation)

The engine consults [`wanxiang_reverse.dict.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang_reverse.dict.yaml), locates the record mapping `yuif` → **震**, and presents the character with auxiliary codes (`y`, `i`) for further input. This method proves essential when you know a character's radical composition but cannot recall its full structural code or pronunciation.

## Customizing the Reverse Dictionary

You can extend the default component mappings without modifying the core dictionary. Create a custom configuration file at `~/.config/ibus/rime/wanxiang_reverse.custom.yaml` or use the repository's [`custom/wanxiang_reverse.custom.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/custom/wanxiang_reverse.custom.yaml) template:

```yaml

# custom/wanxiang_reverse.custom.yaml

mount:
  - wanxiang_reverse

```

Add entries using the same tab-separated format—character first, then the component string. The schema automatically loads these extensions through [`set_schema.lua`](https://github.com/amzxyz/rime_wanxiang/blob/main/set_schema.lua), and the Lua logic in [`lua/wanxiang.lua`](https://github.com/amzxyz/rime_wanxiang/blob/main/lua/wanxiang.lua) checks `seg:has_tag("wanxiang_reverse")` to apply special processing rules for custom entries.

## Summary

- **[`wanxiang_reverse.dict.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang_reverse.dict.yaml)** functions as the data source for component-based and stroke-based character lookup in the Wanxiang input method.
- The dictionary enables **reverse lookup** via the backtick prefix `` ` ``, allowing users to input characters by their constituent radicals or stroke patterns.
- **Schema integration** occurs through `affix_segmentor` and `reverse_lookup_translator` attachments in the main schema files ([`wanxiang.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang.schema.yaml) and [`wanxiang_t9.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang_t9.schema.yaml)).
- The **recognizer pattern** `^`[A-Za-z]*$` triggers the lookup mode, routing queries to the `table_translator`.
- Users can **extend functionality** through [`wanxiang_reverse.custom.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang_reverse.custom.yaml) without altering the core dictionary, with Lua scripts handling tag-specific processing.

## Frequently Asked Questions

### How do I activate reverse lookup in Wanxiang?

Type the backtick character `` ` `` followed by the component codes or stroke sequence for the character you want to find. For example, typing `` `yuif `` queries the dictionary for characters composed of the "雨" and "辰" components, returning "震" as the primary candidate.

### What file format does wanxiang_reverse.dict.yaml use?

The file uses a **tab-separated plain text format** where each line contains a Chinese character, a tab character, and the associated component or stroke code string. Comments begin with `#`, and the file includes YAML headers defining the dictionary name and version metadata.

### Can I add my own component mappings to the reverse dictionary?

Yes. Create a [`wanxiang_reverse.custom.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang_reverse.custom.yaml) file in your Rime configuration directory (or the repository's `custom/` folder) and add entries following the same tab-separated format. The input method automatically merges these custom entries with the base dictionary when processing reverse-lookup queries.

### Why does reverse lookup require a separate schema file?

The [`wanxiang_reverse.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang_reverse.schema.yaml) file isolates the reverse-lookup configuration—including the prefix trigger, recognizer patterns, and dictionary references—from the main input schema. This modular design allows the reverse-lookup translator to function as an **affix segmentor** that intercepts specific input patterns (those starting with `` ` ``) without interfering with standard typing flows.