Guides

Semantic text (to_text)

Project a chart, a horoscope or a palace into Markdown text — for a language model, or for a person to read.

For: everyone. This is the library's most direct use

A chart has three projections in x-iztro: to_json / the DTO is the structured form for machines, the translated fields are the display form for UIs, and to_text is the natural-language form for models and people — a complete written description of the chart's facts. Feeding it to a language model is its most common use, but it is not itself a prompt and contains no instructions. Assembling that description by hand is tedious and easy to get incomplete, so every readable object carries its own to_text.

The output is a Markdown subset: only #/##/### headings, - label: value lists, **bold** and one narrow table. Rendered, it is a document; unrendered, the source reads just as well, so pasting it into a chat box loses no structure.

EntryContents
Chart to_textThe natal chart: basic info, a palace overview table, pattern hits, and the twelve palaces in detail starting from the Soul palace
Horoscope to_textThe horoscope: one section each for decadal, age fortune, yearly, monthly, daily and hourly, with each scope's mutagens, flowing stars and patterns
Palace to_textA single palace, character-for-character identical to that palace's section in the natal text
Surrounded palaces to_textThe target palace, its opposite, and the wealth and career positions, one section each
Flanking palaces to_textThe two palaces immediately either side of the target, one section each
Decadal timeline to_textAll twelve decadals in one table: natal palace, nominal ages, years, stem-branch, mutagens
patterns_to_textThe pattern-hit list on its own, from the natal or any horoscope perspective

Everything generates in the chart language: a Chinese chart yields Chinese text, an English chart English text. With a knowledge pack, readings are inlined next to the facts they belong to rather than appended (the mutagen notes are the one appendix).

Usage

chart = astro.by_solar("2000-8-16", 2, "female", language="en-US")
h = chart.horoscope("2025-1-1", 0)

text = f"{chart.to_text()}\n{h.to_text()}"   # str(chart) / str(h) are equivalent
let chart = by_solar("2000-8-16", 2, Gender::Female, true, Language::EnUS, Config::default())?;
let h = chart.horoscope("2025-1-1", 0)?;

let text = format!("{}\n{}", chart.to_text(), h.to_text());
chart, _ := iztro.BySolar("2000-8-16", 2, iztro.GenderFemale, true, iztro.LanguageEnUS, nil)
h, _ := chart.Horoscope("2025-1-1", 0)

natal, _ := chart.ToText()
fortune, _ := h.ToText()

The finer-grained entries:

chart.palace("soul").to_text()                  # one palace
chart.surrounded_palaces("soul").to_text()      # surrounded palaces
chart.flanking_palaces("soul").to_text()        # flanking palaces
chart.decadal_list_to_text()                    # decadal timeline
chart.patterns_to_text()                        # natal patterns
h.patterns_to_text("yearly")                    # patterns from the yearly perspective
chart.PalaceToText(iztro.PalaceTarget{Key: iztro.PalaceSoul})
chart.SurroundedPalacesToText(iztro.PalaceTarget{Key: iztro.PalaceSoul})
chart.FlankingPalacesToText(iztro.PalaceTarget{Key: iztro.PalaceSoul})
chart.DecadalListToText()
chart.PatternsToText(nil)
h.PatternsToText(iztro.ScopeYearly, nil)

On the Rust side these are PalaceRef::to_text(), SurroundedPalaces::to_text(), FlankingPalaces::to_text(), Astrolabe::decadal_list_to_text() and the free functions of the text module (astrolabe_to_text / horoscope_to_text / palace_to_text / surrounded_palaces_to_text / flanking_palaces_to_text / decadal_list_to_text / patterns_to_text); the convenience methods emit in the chart language, the free functions take an explicit language — see Rust — TextOptions. All three languages emit identical text.

Structure at a glance

The skeleton of a natal text, top to bottom:

# Natal Chart <solar date> <hour> <gender>
## Basic Info          four lines of merged fields + birth-year mutagens (with landing palaces)
## Palace Overview     a narrow table Palace | Major Stars | Minor Stars | Decadal, Soul palace first
## Patterns            the hit list; omitted entirely when there are no hits
## Palaces             from the Soul palace in order: soul, siblings, spouse, children, wealth, health, surface, friends, career, property, spirit, parents
### soul (ren woo) · Decadal 3-12   one section per palace: major, minor and adjective stars, trine & opposite, stem flying, twelve gods, age-fortune years
### siblings (xin si) · Decadal 13-22
…

A horoscope text:

# Horoscope <solar date> (<lunar date>)
## Decadal Fortune · Soul Palace: Natal X (stem-branch)   mutagens, patterns + a twelve-palace table (Decadal | Natal | Major | Minor | Scope Stars); "Childhood Fortune" before the decadals start
## Age Fortune · Soul Palace: Natal X · Nominal Age N      palace names, mutagens, that palace's three star groups
## Yearly · Soul Palace: Natal X (stem-branch)             mutagens, patterns + a twelve-palace table (with a Twelve Gods column)
## Monthly · Soul Palace: Natal X (stem-branch)            palace names, mutagens, scope stars (with landing palaces), patterns
## Daily · …                                               as monthly
## Hourly · …                                              as monthly

What the natal text looks like

Below is the complete opening (basic info, overview table, patterns) and the first two palaces of the chart for 2000-8-16, Yin hour, female, charted with language="en-US"; the other ten palaces follow in the same shape:

# Natal Chart 2000-8-16 Tiger hour female

## Basic Info
- Solar: 2000-8-16 · Lunar: 二〇〇〇年七月十七 · Hour: Tiger hour (03:00~05:00)
- Pillars: geng chen - jia shen - bing woo - geng yin · Zodiac: dragon · Sign: leo
- Five Elements Class: wood 3rd · Soul Star: rebel · Body Star: scholar
- Soul Palace: woo · Body Palace: xu (career) · Original Palace: chen (spouse)
- Birth-Year Mutagen: sun [A]→children, warrior [B]→wealth, moon [C]→friends, fortunate [D]→health

## Palace Overview
| Palace | Major Stars | Minor Stars | Decadal |
|---|---|---|---|
| **soul** woo | emperor([+3]) | artist([-3]) | 3-12 |
| siblings si | advisor([-1]) | — | 13-22 |
| spouse chen [Original Palace] | marshal([+3]) | helper, impulsive([-3]) | 23-32 |
| children mao | sun([+3]) [A], sage([+3]) | — | 33-42 |
| wealth yin | warrior([+1]) [B], minister([+3]) | horse | 43-52 |
| health chou | fortunate([-2]) [D], advocator([-2]) | assistant, fickle | 53-62 |
| surface zi | wolf([+2]) | spark([-3]) | 63-72 |
| friends hai | moon([+3]) [C] | — | 73-82 |
| career xu [Body Palace] | judge([0]), empress([+3]) | officer | 83-92 |
| property you | — | ideologue, driven([-3]) | 93-102 |
| spirit shen | rebel([+1]) | scholar([+1]), money | 103-112 |
| parents wei | — | aide, tangled([+3]) | 113-122 |

## Patterns
- **Empress and Minister Facing the Palace** (soul): empress([+3]), minister([+3])

## Palaces

### soul (ren woo) · Decadal 3-12
- Major Stars: emperor([+3])
- Minor Stars: artist([-3])
- Adjective Stars: refined, lucky, intercepted, instigated, considery(Y)
- Trine & Opposite: Opposite surface · Trine wealth, career
- Stem ren Flying: sage [A]→children, emperor [B]→soul, officer [C]→career, warrior [D]→wealth
- Twelve Gods: Changsheng·weak, Boshi·dragon, Suiqian·downcast, Jiangqian·disastery
- Age Fortune Years: 5, 17, 29, 41, 53, 65, 77, 89, 101, 113

### siblings (xin si) · Decadal 13-22
- Major Stars: advisor([-1])
- Adjective Stars: cheerful, utopian, alone
- Trine & Opposite: Opposite friends · Trine health, property
- Stem xin Flying: advocator [A]→health, sun [B]→children, artist [C]→soul, scholar [D]→spirit
- Twelve Gods: Changsheng·sick, Boshi·consumer, Suiqian·unlucky, Jiangqian·robbed
- Age Fortune Years: 6, 18, 30, 42, 54, 66, 78, 90, 102, 114

(the other ten palaces follow in the same shape)

Both the overview table and the detail sections start from the Soul palace and run by decreasing palace index (soul, siblings, spouse, children, wealth, health, surface, friends, career, property, spirit, parents) — not by cell position on the chart. The Patterns section lists every hit of the pattern engine on the natal chart, one per line: pattern name, landing palace, forming stars; with no hits the section is omitted.

Lunar dates stay in Chinese

Lunar is the one field that is not localized: the lunar date is written with Chinese numerals whatever the chart language. 二〇二四年腊月初二 below is the 2nd day of the 12th lunar month, 2024. Pillars is the four pillars in iztro's romanization (午 renders as woo to keep it apart from 戊 wu).

What the horoscope text looks like

Target date 2025-1-1, early Zi hour. The decadal and yearly scopes expand a twelve-palace table, age fortune writes only its landing palace and that palace's stars, and the monthly and finer scopes write landing palace, re-laid-out palace names, mutagens, scope stars and patterns:

# Horoscope 2025-1-1 (二〇二四年腊月初二)

## Decadal Fortune · Soul Palace: Natal spouse (geng chen)
- Mutagen: sun [A]→Natal children, warrior [B]→Natal wealth, moon [C]→Natal friends, fortunate [D]→Natal health
- Patterns: Marshal, Rebel and Wolf (soul), Meeting of Wind and Cloud (soul)

| Decadal Fortune | Natal | Major Stars | Minor Stars | Scope Stars |
|---|---|---|---|---|
| soul | spouse | marshal([+3]) | helper, impulsive([-3]) | — |
| siblings | children | sun([+3]) [A], sage([+3]) | — | artist(D) |
| spouse | wealth | warrior([+1]) [B], minister([+3]) | horse | horse(D) |
| children | health | fortunate([-2]) [D], advocator([-2]) | assistant, fickle | assistant(D) |
| wealth | surface | wolf([+2]) | spark([-3]) | — |
| health | friends | moon([+3]) [C] | — | scholar(D), attractive(D) |
| surface | career | judge([0]), empress([+3]) | officer | — |
| friends | property | — | ideologue, driven([-3]) | driven(D) |
| career | spirit | rebel([+1]) | scholar([+1]), money | money(D) |
| property | parents | — | aide, tangled([+3]) | aide(D), tangled(D) |
| spirit | soul | emperor([+3]) | artist([-3]) | — |
| parents | siblings | advisor([-1]) | — | cheerful(D) |

## Age Fortune · Soul Palace: Natal career · Nominal Age 25
- Palace Names: soul→Natal career, siblings→Natal property, spouse→Natal spirit, children→Natal parents, wealth→Natal soul, health→Natal siblings, surface→Natal spouse, friends→Natal children, career→Natal wealth, property→Natal health, spirit→Natal surface, parents→Natal friends
- Mutagen: fortunate [A]→Natal health, advisor [B]→Natal siblings, scholar [C]→Natal spirit, judge [D]→Natal career
- Major Stars: judge([0]), empress([+3])
- Minor Stars: officer
- Adjective Stars: gifted, frail

## Yearly · Soul Palace: Natal spouse (jia chen)
- Mutagen: judge [A]→Natal career, rebel [B]→Natal spirit, warrior [C]→Natal wealth, sun [D]→Natal children
- Patterns: Marshal, Rebel and Wolf (soul), Money and Horse Galloping Together (spouse), Money and Horse Bearing the Seal (spouse), Scholar and Artist Flanking Life (soul, broken), Literary Stars in Hidden Support (soul)

| Yearly | Natal | Major Stars | Minor Stars | Scope Stars | Twelve Gods |
|---|---|---|---|---|---|
| soul | spouse | marshal([+3]) | helper, impulsive([-3]) | — | Suiqian·initial, Jiangqian·religious |
| siblings | children | sun([+3]) [A], sage([+3]) | — | driven(Y) | Suiqian·illness, Jiangqian·listless |
| spouse | wealth | warrior([+1]) [B], minister([+3]) | horse | money(Y), horse(Y) | Suiqian·sorrowing, Jiangqian·varied |
(the other nine rows follow in the same shape)

## Monthly · Soul Palace: Natal friends (ding chou)
- Palace Names: soul→Natal friends, siblings→Natal career, spouse→Natal property, children→Natal spirit, wealth→Natal parents, health→Natal soul, surface→Natal siblings, friends→Natal spouse, career→Natal children, property→Natal wealth, spirit→Natal health, parents→Natal surface
- Mutagen: moon [A]→Natal friends, fortunate [B]→Natal health, advisor [C]→Natal siblings, advocator [D]→Natal health
- Scope Stars: attractive(M)→property, artist(M)→surface, tangled(M)→surface, money(M)→health, driven(M)→wealth, cheerful(M)→children, aide(M)→spouse, scholar(M)→spouse, assistant(M)→soul, horse(M)→soul
- Patterns: Advisor, Moon, Fortunate and Sage (soul), Sun Shining on Thunder Gate (career), Sun and Moon Both Bright (soul), Cinnabar and Cassia Steps (soul), Bright Moon at Heaven's Gate (soul), Money and Horse Galloping Together (property), Open and Hidden Fortune (soul), Money and Horse Bearing the Seal (property), Literary Stars Facing Life (soul, broken), Literary Stars in Hidden Support (soul)

## Daily · Soul Palace: Natal surface (geng woo)
- Palace Names: soul→Natal surface, siblings→Natal friends, spouse→Natal career, children→Natal property, wealth→Natal spirit, health→Natal parents, surface→Natal soul, friends→Natal siblings, career→Natal spouse, property→Natal children, spirit→Natal wealth, parents→Natal health
- Mutagen: sun [A]→Natal children, warrior [B]→Natal wealth, moon [C]→Natal friends, fortunate [D]→Natal health
- Scope Stars: artist(d)→property, cheerful(d)→property, aide(d)→health, tangled(d)→health, money(d)→wealth, horse(d)→wealth, driven(d)→children, attractive(d)→children, scholar(d)→siblings, assistant(d)→parents
- Patterns: Fire and Wolf (soul), Bell and Wolf (soul), Marshal, Rebel and Wolf (soul), Money and Horse Galloping Together (spirit), Money and Horse Bearing the Seal (spirit), Literary Stars Facing Life (soul, broken), Literary Stars in Hidden Support (soul)

## Hourly · Soul Palace: Natal surface (bing zi)
(written like the daily section)

The decadal, yearly and finer scopes each carry a patterns line from their own perspective, with the palace in parentheses written as re-laid out at that scope; age fortune has no pattern perspective. Each scope's Mutagen line points to palaces of the natal chart (the mutagen stars sit on the natal chart and are not re-laid out with the scope), so a landing palace is written Natal friends; the scope-star lines and the twelve-palace tables are the ones that use the scope's re-laid-out palace names. When the subject has not yet entered the decadals, the decadal section's heading and table header read Childhood Fortune instead of Decadal Fortune — childhood and decadal are different reading semantics.

Format conventions

NotationMeaning
# Natal Chart 2000-8-16 Tiger hour female, # Horoscope 2025-1-1 (…)Document title: the natal chart carries solar date, hour and gender; the horoscope carries the target date in solar and lunar form
## Basic Info, ## Palace Overview, ## Patterns, ## Palaces, ## Mutagen NotesThe natal sections; ## Decadal Fortune, ## Age Fortune, ## Yearly, ## Monthly, ## Daily, ## Hourly are the horoscope sections
### soul (ren woo) · Decadal 3-12One section per palace: palace name, its stem and branch, and the nominal-age range when this palace is the decadal
### career (bing xu) · Decadal 83-92 [Body Palace]The bracket marks this palace as also being the Body palace; [Original Palace] marks the Original palace. The overview table's Palace column carries the same marks
- label: valueA fact line; several fields on one line are separated by ·, list items by ,
| Palace | Major Stars | Minor Stars | Decadal |The narrow overview table, Soul palace in bold; an empty cell is —
emperor([+3])The parentheses hold brightness on a −3…+3 scale; a star without brightness has no parentheses
sun([+3]) [A]The mutagen, right after the star name (and brightness): [A]/[B]/[C]/[D] are Lu/Quan/Ke/Ji. A Chinese chart writes the full word, 化禄
moon [C]→friendsThe arrow points to the palace this mutagen star sits in on the natal chart. Birth-year mutagens and stem flying are written this way; no arrow when the star is not on the chart
- Mutagen: moon [A]→Natal friends, …A horoscope scope's mutagen line: the landing palace is still the natal chart's, but inside a scope section a bare palace name means the scope's re-laid-out palace, so the Natal prefix marks the frame of reference
attractive(M)→propertyScope-star lines on the monthly and finer scopes: the arrow points to the palace the flowing star lands in, as re-laid out at that scope
- Major Stars: EmptyA palace with no major star says Empty; the minor and adjective lines are omitted when empty
- Trine & Opposite: Opposite surface · Trine wealth, careerThis palace's opposite, and the other two palaces of its trine, always in wealth-position, career-position order (surrounded palaces)
### Target Palace · soul (ren woo) · Decadal 3-12A palace heading in the surrounded-palaces text: the palace name is preceded by its role — Target Palace, Opposite Palace, Wealth Palace, Career Palace
### Previous Palace · siblings (xin si) · Decadal 13-22A palace heading in the flanking-palaces text: the roles are Previous Palace and Next Palace, and the fact lines match the surrounded-palaces text
| # | Natal Palace | Nominal Age | Years | Stem-Branch | Mutagen |The decadal timeline's header: twelve rows, one per decadal, in starting order; the arrows in the Mutagen column point at natal palaces
- Stem ren Flying: sage [A]→children, …The flying-star mutagens driven by this palace's stem: the mutagen stars and where each lands
- Twelve Gods: Changsheng·weak, Boshi·dragon, Suiqian·downcast, Jiangqian·disasteryOne god from each of the four groups, written group·god, always in the order Changsheng-12, Boshi-12, Sui-qian-12, Jiang-qian-12; the yearly table's Twelve Gods column holds only the Sui-qian and Jiang-qian pair
- Age Fortune Years: 5, 17, 29, …The nominal ages (虚岁) at which age fortune lands on this palace
- **Empress and Minister Facing the Palace** (soul): empress([+3]), minister([+3])A pattern line: pattern name in bold, landing palace in parentheses, forming stars after the colon
Scholar and Artist Flanking Life (soul, broken)broken appended in the parentheses: the pattern forms but is broken
## Decadal Fortune · Soul Palace: Natal spouse (geng chen)Which natal palace this scope's Soul palace landed on; the parentheses hold that scope's stem and branch
## Age Fortune · Soul Palace: Natal career · Nominal Age 25Where age fortune landed, and the nominal age
| Decadal Fortune | Natal | Major Stars | Minor Stars | Scope Stars |A scope's twelve-palace table: the first column is this scope's re-laid-out palace name, the second the natal palace name; major and minor stars are the natal chart's, scope stars are this scope's
- Palace Names: soul→Natal career, …Age fortune and the monthly and finer scopes have no palace table; this line carries the mapping instead: starting from that scope's soul palace, the left side is the scope's re-laid-out name and the right side is the natal one
**emperor([+3])**: bodyA reading entry (only with a knowledge pack): the heading is the star, pattern or mutagen as written on its fact line, the body is the pack's text verbatim
**emperor × empress (same palace)**: bodyA combined reading for two major stars sharing a palace
Conditions: …The forming conditions, at the end of a pattern reading

The first column of a scope table is that scope's name — don't read it backwards

| spouse | wealth | … says "within this decadal this cell is called the Spouse palace, and on the natal chart it is the Wealth palace". A horoscope reading goes by the first column; the second is there so you can map back to the natal chart. See Horoscopes.

The (D) on artist and the (Y) on considery are part of the name

In the en-US vocabulary the flowing stars carry their scope as a suffix inside the name: 运曲 is literally artist(D), 流禄 is money(Y), 月鸾 is attractive(M), and the daily and hourly scopes use (d) and (H). Likewise considery(Y) is the literal name of the star Nianjie (年解), suffix included — iztro's vocabulary bakes it in to separate 年解 from 解神 (considery). So considery(Y) appears among the natal Adjective Stars, where no scope is implied. Verify by key, never by parsing the name.

Date fields echo the input verbatim, without zero padding: pass "2000-8-16" and you get Solar: 2000-8-16.

The seven entries

EntryOutput
ChartThe complete natal text above
HoroscopeThe complete horoscope text above; natal information is not repeated, so the two concatenated make one full context
PalaceThat palace's section from the natal detail (from its ### heading on), character-for-character — the natal text contains it
Surrounded palacesA ## soul Trine & Opposite heading plus one section each for the target, its opposite, and the wealth and career positions; each heading carries a role prefix (### Target Palace · soul …), and the fact lines are character-for-character the palace text
Flanking palacesA ## Flanking Palaces heading plus one section each for the two neighbours, structured like the surrounded text with the role prefixes Previous Palace / Next Palace
Decadal timelineA # Decadal Timeline heading plus a twelve-row table, one row per decadal
patterns_to_textPattern lines only, one per hit; from the natal perspective or any horoscope scope

Eight bridge kinds map onto these: patterns_to_text splits into a natal and a horoscope kind (patternsToText / horoscopePatternsToText), and each of the other six entries is one kind.

Surrounded palaces and a single palace:

## soul Trine & Opposite

### Target Palace · soul (ren woo) · Decadal 3-12
- Major Stars: emperor([+3])
- Minor Stars: artist([-3])
- Adjective Stars: refined, lucky, intercepted, instigated, considery(Y)
- Trine & Opposite: Opposite surface · Trine wealth, career
- Stem ren Flying: sage [A]→children, emperor [B]→soul, officer [C]→career, warrior [D]→wealth
- Twelve Gods: Changsheng·weak, Boshi·dragon, Suiqian·downcast, Jiangqian·disastery
- Age Fortune Years: 5, 17, 29, 41, 53, 65, 77, 89, 101, 113

### Opposite Palace · surface (wu zi) · Decadal 63-72
- Major Stars: wolf([+2])
- Minor Stars: spark([-3])
- Adjective Stars: dignified
- Trine & Opposite: Opposite soul · Trine spirit, spouse
- Stem wu Flying: wolf [A]→surface, moon [B]→friends, helper [C]→spouse, advisor [D]→siblings
- Twelve Gods: Changsheng·molding, Boshi·illness, Suiqian·sinister, Jiangqian·capable
- Age Fortune Years: 11, 23, 35, 47, 59, 71, 83, 95, 107, 119

### Wealth Palace · wealth (wu yin) · Decadal 43-52
(fact lines as in the palace text)

### Career Palace · career (bing xu) · Decadal 83-92 [Body Palace]
(fact lines as in the palace text)

The palace text is one of those sections without the role prefix (from ### soul (ren woo) · Decadal 3-12 on).

The Soul palace's flanking palaces — Siblings and Parents — with fact lines in the same shape:

## Flanking Palaces

### Previous Palace · siblings (xin si) · Decadal 13-22
- Major Stars: advisor([-1])
- Adjective Stars: cheerful, utopian, alone
- Trine & Opposite: Opposite friends · Trine health, property
- Stem xin Flying: advocator [A]→health, sun [B]→children, artist [C]→soul, scholar [D]→spirit
- Twelve Gods: Changsheng·sick, Boshi·consumer, Suiqian·unlucky, Jiangqian·robbed
- Age Fortune Years: 6, 18, 30, 42, 54, 66, 78, 90, 102, 114

### Next Palace · parents (gui wei) · Decadal 113-122
- Major Stars: Empty
- Minor Stars: aide, tangled([+3])
- Adjective Stars: social, bottomless
- Trine & Opposite: Opposite health · Trine children, friends
- Stem gui Flying: rebel [A]→spirit, advocator [B]→health, moon [C]→friends, wolf [D]→surface
- Twelve Gods: Changsheng·prime, Boshi·sumo, Suiqian·tied, Jiangqian·condemned
- Age Fortune Years: 4, 16, 28, 40, 52, 64, 76, 88, 100, 112

The decadal timeline is one twelve-row table, one row per decadal (first three rows shown, the other nine are the same shape):

# Decadal Timeline

| # | Natal Palace | Nominal Age | Years | Stem-Branch | Mutagen |
|---|---|---|---|---|---|
| 1 | soul | 3-12 | 2002-2011 | ren woo | sage [A]→Natal children, emperor [B]→Natal soul, officer [C]→Natal career, warrior [D]→Natal wealth |
| 2 | siblings | 13-22 | 2012-2021 | xin si | advocator [A]→Natal health, sun [B]→Natal children, artist [C]→Natal soul, scholar [D]→Natal spirit |
| 3 | spouse | 23-32 | 2022-2031 | geng chen | sun [A]→Natal children, warrior [B]→Natal wealth, moon [C]→Natal friends, fortunate [D]→Natal health |

That table deliberately does not expand each decadal's years — twelve decadals of ten years each would run to a hundred and twenty rows, whereas the point of this table is to take in all twelve decades of a life at once. For the years within one decadal, use yearly_list.

The pattern text:

# Patterns

- **Empress and Minister Facing the Palace** (soul): empress([+3]), minister([+3])

Text with readings

The text above is facts only. Every to_text also has a form that takes a knowledge pack: readings are inlined next to the facts they belong to — each palace's star readings right after that palace's fact lines, the pattern readings right after the pattern list, and the mutagen notes at the end. The material is picked from the pack according to the chart and quoted verbatim. The core only selects and assembles; it holds no interpretive opinion of its own. Pass the bundled default pack and you get iztro-docs' readings; pass a custom pack merged from overlays and you get yours. by_solar and the DTO output are unchanged.

chart.to_text(knowledge=True)          # True takes the bundled pack for the chart language
chart.to_text(knowledge=my_pack)       # or any KnowledgePack
h.to_text(knowledge=True)
chart.palace("soul").to_text(knowledge=True)
chart.surrounded_palaces("soul").to_text(knowledge=True)
chart.flanking_palaces("soul").to_text(knowledge=True)
chart.decadal_list_to_text(knowledge=True)
chart.patterns_to_text(knowledge=True)
h.patterns_to_text("yearly", knowledge=True)

chart.to_text(knowledge=True, config=PatternConfig(borrow=False))   # all five to_text take config
let pack = KnowledgePack::builtin(Language::ZhCN).unwrap();
let opts = TextOptions::new().knowledge(&pack);

chart.to_text_with(&opts);
h.to_text_with(&opts);
chart.palace(Palace::Soul).unwrap().to_text_with(&opts);
chart.surrounded_palaces(Palace::Soul).unwrap().to_text_with(&opts);
chart.flanking_palaces(Palace::Soul).unwrap().to_text_with(&opts);
chart.decadal_list_to_text_with(&opts);
text::patterns_to_text_with(&hits, &names, &opts, chart.language);

let cfg = PatternConfig { borrow: false, ..PatternConfig::default() };
chart.to_text_with(&TextOptions::new().knowledge(&pack).pattern_config(&cfg));
opts := iztro.TextOptions{Knowledge: iztro.BuiltinKnowledge()}   // or iztro.KnowledgeFrom(pack)

chart.ToTextWith(opts)
h.ToTextWith(opts)
chart.PalaceToTextWith(iztro.PalaceTarget{Key: iztro.PalaceSoul}, opts)
chart.SurroundedPalacesToTextWith(iztro.PalaceTarget{Key: iztro.PalaceSoul}, opts)
chart.FlankingPalacesToTextWith(iztro.PalaceTarget{Key: iztro.PalaceSoul}, opts)
chart.DecadalListToTextWith(opts)
chart.PatternsToTextWith(opts)
h.PatternsToTextWith(iztro.ScopeYearly, opts)

cfg := iztro.PatternConfig{Borrow: iztro.Bool(false)}
chart.ToTextWith(iztro.TextOptions{Knowledge: iztro.BuiltinKnowledge(), PatternConfig: &cfg})

The pattern criteria (config / pattern_config / PatternConfig) are the same argument as patterns(config) and act on both the text's pattern section and the pattern readings: change the criteria and the hits and the readings that follow them change together. Omitted, the default criteria apply. The decadal timeline has no pattern section, so it does not take the argument.

Where readings go, and deduplication

EntryWhere the readings land
ChartAfter the hit list under ## Patterns: one entry per pattern; after each palace's ### fact lines: one entry per star in that palace; at the end, ## Mutagen Notes: the four entries Lu, Quan, Ke, Ji
HoroscopeAfter the decadal and yearly twelve-palace tables, and after the fact lines of the monthly and finer scopes: one entry per scope star of that scope, one per pattern hit at that scope
PalaceAfter that palace's fact lines: one entry per star
Surrounded palacesAfter each of the four palaces' fact lines
Flanking palacesAfter each of the two palaces' fact lines
Decadal timelineAfter the table, under ## Star Notes: one entry per mutagen star, a star repeated across decadals read only once
patterns_to_textAfter the pattern list
  • A reading entry is written **heading**: body; the heading is the star exactly as written on its fact line (**emperor([+3])**, **sun([+3]) [A]**), the body is the pack's intro verbatim (Markdown, untrimmed), with a blank line between entries.
  • A combined reading between major stars sharing a palace (the pack's combinations) is written **emperor × empress (same palace)**: … and comes first in that palace's readings; both directions are checked, so a reading recorded under only one of the two stars still appears, once per pair.
  • Within a palace the stars are read in major, minor, adjective order; the twelve gods get no readings.
  • A pattern reading is the intro body followed by a Conditions: … paragraph.
  • The horoscope text reads only scope stars and each scope's patterns; natal stars are not repeated (those readings are in the natal text). A scope star or pattern that appears at several scopes is read only at the first scope it appears in.
  • A star or pattern with no entry in the pack gets no entry and no placeholder.

The Soul palace section of the 2000-8-16 Yin-hour female chart with readings (the bundled pack is Chinese, so the bodies are Chinese; bodies truncated):

### 命宫 (壬午) · 大限 3-12
- 主星: 紫微(庙)
- 辅星: 文曲(陷)
- 杂耀: 凤阁, 天福, 截路, 蜚廉, 年解
- 三方四正: 对宫 迁移 · 三合 财帛, 官禄
- 宫干壬飞化: 天梁化禄→子女, 紫微化权→命宫, 左辅化科→官禄, 武曲化忌→财帛
- 十二神: 长生·衰, 博士·青龙, 岁前·丧门, 将前·灾煞
- 小限虚岁: 5, 17, 29, 41, 53, 65, 77, 89, 101, 113

**紫微(庙)**: 紫微星号称 `帝王星`,并非指紫微坐命者能成帝王,而是指其个性带有“王者”特质……

**文曲(陷)**: 文曲星是紫微斗数里第一文艺之星,代表艺术修养与浪漫……

**凤阁**: 凤阁星会增加比较柔和的技能天赋,比如音乐、舞蹈……

(one entry each for 天福, 截路, 蜚廉, 年解)

The patterns section with readings:

# 格局

- **府相朝垣** (命宫): 天府(庙), 天相(庙)

**府相朝垣**: “食禄千锺”的断语使此格备受欢迎,但成格并不必然富足。……

成立条件: 此格指 天府星 在官禄宫、天相星 在财帛宫会照命宫。……

Section and entry headings are translated into the chart language: on an English chart they read ## Mutagen Notes and **emperor([+3])**, while the bodies stay in the pack's language.

Length

Readings come in full; trimming belongs to the application. Measured character counts for the same chart (Chinese chart, default pack):

EntryFacts onlyWith readings
Natal chart3,38920,765
Horoscope2,6978,698
Palace (Soul)2221,141
Surrounded palaces (Soul)9246,312
Flanking palaces (Soul)4361,874
Decadal timeline1,0456,447
Patterns36328

An English chart is longer (star names are words rather than two characters, and the structural labels are longer): natal 6,757, horoscope 6,378, palace 464, surrounded palaces 1,911, flanking palaces 895, decadal timeline 1,893, patterns 95. Any mainstream model's context window holds either comfortably; trimming is normally unnecessary. The natal chart's readings dominate because every major, minor and adjective star on the chart has an entry. For readings on a few palaces only, use the palace or surrounded-palaces entry; to lay things out yourself, take the chart's sub-pack with for_astrolabe and assemble from it.

Custom packs

The pack is a parameter, so the result of merging overlays is passed the same way:

pack = KnowledgePack.builtin().merged(KnowledgePack.from_json(open("my-school.json").read()))
chart.to_text(knowledge=pack)

The same chart with different packs yields byte-identical facts; only the reading entries change.

English charts have no bundled pack

The bundled default pack is zh-CN only. On an English chart (or any of the other four languages), knowledge=True / BuiltinKnowledge() / KnowledgePack::builtin(Language::EnUS) raise invalid_argument rather than silently falling back to no readings. Pass a pack explicitly — a pack's language is not tied to the chart's, so an English chart with the Chinese pack gives English headings and Chinese bodies.

Six languages

The structural labels (Basic Info, Major Stars, Trine & Opposite, Decadal, …) exist in six sets — zh-CN, zh-TW, en-US, ja-JP, ko-KR, vi-VN — and star names, palace names, stems and branches, brightness, mutagens and pattern names are translated into the chart language. The same chart in all six languages has a line-for-line matching skeleton; only the words differ. The lunar date is written with Chinese numerals in every language (二〇〇〇年七月十七).

The mutagen mark follows the language: Chinese writes 化禄 and Japanese 化祿, English [A] ([A]/[B]/[C]/[D] are Lu, Quan, Ke, Ji), Korean 화록, Vietnamese hóa Lộc. Word spacing follows the language too: in Latin-script languages a space separates the star name from its mutagen mark and the stem from the branch (English sun [A], ### soul (ren woo); Vietnamese Thái Dương hóa Lộc, (Nhâm Ngọ)), and compound labels likewise (Natal spouse); Chinese and Japanese join them directly (太阳化禄, (壬午), 本命夫妻).

The Rust free functions take an explicit language: a Chinese chart rendered as en-US is byte-identical to a natively English chart — star names are translated from their keys, not taken from the names fixed on the chart, so nothing comes out mixed.

Chinese chart or English chart?

Prefer a Chinese chart even when your product is in English. The English vocabulary is iztro's interpretive word list — Ziwei is emperor, Qisha is marshal — brightness degrades to marks such as [+3], mutagens become [A]/[B]/[C]/[D], the flowing stars carry scope suffixes inside their names (artist(D), money(Y)), and a couple of entries are not English words at all (considery, disastery). None of that matches the rendering conventional in English-language Zi Wei writing, so a model may not recognise it.

Mainstream models handle Chinese Zi Wei terminology well, and feeding them the Chinese text gets better results. When you genuinely need English, attach a star-name table alongside it.

Wiring it to a model

The generated text is pure description and contains no instructions. In practice, put your analysis request in front of it:

system = ("You are a Zi Wei Dou Shu analyst. Answer from the given chart only; "
          "do not invent information that is not on it.")
user = f"""{chart.to_text()}

{chart.horoscope("2025-1-1", 0).to_text()}

Analyse this person's career prospects for 2025."""

To have the model interpret along one school's lines rather than freely, replace chart.to_text() with chart.to_text(knowledge=True) (or pass your own pack) and the readings enter the context with the chart. The text is Markdown, so a model reads the palace overview as a table and treats each ### heading as a palace boundary — asking it to "quote the palace section" has a stable anchor. For a fuller integration (tool calls, and not letting the model chart for itself) see Letting an AI read the chart.

When you need finer control

to_text covers the general case. To customise the text structure — describing only a few palaces, or emitting JSON instead of text — walk the chart data and assemble it yourself; every field is public. See the Data model.

On this page