# Chinese Text Project

> Explore the Chinese Text Project, the open digital library of pre-modern Chinese writing. Look up a character's pronunciations, strokes and simplified or traditional forms; find classics such as the Analects and the Dao De Jing by title; get a text's author, dynasty and a link to read it on ctext.org; search the dictionary for words, people and places; and list China's dynasties with their dates. No account or API key required.

App · 9 actions. Web page: https://docs.lodol.com/docs/integrations/chinese-text-project

## Actions

### Find texts by title

Find books in the library whose title contains some Chinese characters, traditional or simplified. Titles are only in Chinese, so search for 論語 rather than Analects.

**Inputs**

- Title (`title`, text, required): All or part of the title, in Chinese characters.
- Classics only (`classics_only`, true/false): Turn on to leave out texts contributed to the library's Wiki and keep only its curated classics. Default: `false`.
- How many (`limit`, number): The most texts to return, between 1 and 500. From 1 to 500. Default: `25`.
- Characters (`script`, text): Show Chinese in traditional characters, as the library holds it, or converted to simplified characters. One of: `traditional` (Traditional characters (as the library holds them)), `simplified` (Simplified characters). Default: `traditional`.

**Outputs**

- `count` (number): How many texts are returned.
- `first_text_id` (text): The first match's text ID.
- `first_title` (text): The first match's title.
- `texts` (list): The matching texts.
- `total_found` (number): How many texts matched in all.

**Example output**

```json
{
  "count": 3,
  "first_text_id": "ctp:art-of-war",
  "first_title": "\u5b6b\u5b50\u5175\u6cd5",
  "texts": [
    {
      "is_core_classic": true,
      "text_id": "ctp:art-of-war",
      "title": "\u5b6b\u5b50\u5175\u6cd5"
    },
    {
      "is_core_classic": true,
      "text_id": "ctp:sunzi-suan-jing",
      "title": "\u5b6b\u5b50\u7b97\u7d93"
    },
    {
      "is_core_classic": false,
      "text_id": "ctp:wb389011",
      "title": "\u5341\u4e00\u5bb6\u6ce8\u5b6b\u5b50"
    }
  ],
  "total_found": 30
}
```

### Get a link to a text

Get the ctext.org page for a book or chapter to share or open, in English or Chinese, optionally with a word or phrase highlighted wherever it appears.

**Inputs**

- Text (`text`, text, required): Pick a classic from the list, or type any text: its ctext.org link, its title in Chinese (such as 論語), or its text ID from another step (such as ctp:analects or ctp:analects/xue-er for one chapter).
- Highlight (`highlight`, text): Optional. Chinese characters to highlight on the page, such as 仁.
- Page language (`page_language`, text): Which version of the page the link opens. One of: `en` (English), `zh` (Chinese (traditional characters)), `zhs` (Chinese (simplified characters)). Default: `en`.

**Outputs**

- `highlight` (text): The characters highlighted, if any.
- `page_language` (text): The page language chosen.
- `text_id` (text): The text's ID.
- `web_link` (text): The page on ctext.org.

**Example output**

```json
{
  "highlight": "\u670b",
  "page_language": "en",
  "text_id": "ctp:analects/xue-er",
  "web_link": "https://ctext.org/analects/xue-er?searchu=\u670b"
}
```

### Get details of a text

Get what the library knows about a book or one of its chapters: its title, author, dynasty, when it was written, the edition it follows, and a link to read it on ctext.org.

**Inputs**

- Text (`text`, text, required): Pick a classic from the list, or type any text: its ctext.org link, its title in Chinese (such as 論語), or its text ID from another step (such as ctp:analects or ctp:analects/xue-er for one chapter).
- Characters (`script`, text): Show Chinese in traditional characters, as the library holds it, or converted to simplified characters. One of: `traditional` (Traditional characters (as the library holds them)), `simplified` (Simplified characters). Default: `traditional`.

**Outputs**

- `author` (text): The author, where known.
- `book_text_id` (text): The book's text ID.
- `book_title` (text): The title of the book it belongs to.
- `dynasty` (text): The dynasty or span of dynasties it dates from.
- `dynasty_from` (text): The earliest dynasty it dates from.
- `dynasty_to` (text): The latest dynasty it dates from.
- `edition` (text): The printed edition the text follows.
- `edition_link` (text): The edition's scans on ctext.org.
- `is_chapter` (true/false): True when this is a chapter of a book.
- `is_core_classic` (true/false): True for the library's curated classics.
- `last_updated` (text): When the library last changed it.
- `tags` (list): The library's labels for it, e.g. TEXTDB for the curated database.
- `text_id` (text): The text's ID.
- `title` (text): The title of this text or chapter.
- `web_link` (text): Where to read it on ctext.org.
- `written` (text): When it was written, as readable text.
- `written_from_year` (number): Earliest year of writing, where known (negative is BC).
- `written_to_year` (number): Latest year of writing, where known (negative is BC).

**Example output**

```json
{
  "author": null,
  "book_text_id": "ctp:analects",
  "book_title": "\u8ad6\u8a9e",
  "dynasty": "Spring and Autumn \u2013 Warring States",
  "dynasty_from": "Spring and Autumn",
  "dynasty_to": "Warring States",
  "edition": "\u6b66\u82f1\u6bbf\u5341\u4e09\u7d93\u6ce8\u758f",
  "edition_link": "http://ctext.org/library.pl?if=en&res=77721",
  "is_chapter": true,
  "is_core_classic": true,
  "last_updated": "2015-12-07 20:40:31",
  "tags": [
    "TEXTDB"
  ],
  "text_id": "ctp:analects/xue-er",
  "title": "\u5b78\u800c",
  "web_link": "https://ctext.org/analects/xue-er",
  "written": null,
  "written_from_year": null,
  "written_to_year": null
}
```

### Get library statistics

Get the library's running totals: characters of classical text, texts and chapters in its Wiki, scanned pages, parallel passages and more.

**Inputs**: None.

**Outputs**

- `classical_characters` (number): Characters of pre-Qin and Han text in the database.
- `direct_quotations` (number): Identical quotations found.
- `later_characters` (number): Characters of post-Han text in the database.
- `linked_characters` (number): Characters linked to a dictionary meaning.
- `linked_characters_percent` (number): Share of characters linked to a meaning, in percent.
- `paragraphs` (number): Paragraphs in the database.
- `parallel_passage_groups` (number): Groups of parallel passages.
- `parallel_passages` (number): Parallel passages in all.
- `scanned_pages` (number): Pages of scanned books in the library.
- `statistics_updated` (text): When the totals were last worked out.
- `wiki_chapters` (number): Chapters in the Wiki.
- `wiki_characters` (number): Characters in the Wiki.
- `wiki_texts` (number): Texts in the Wiki.

**Example output**

```json
{
  "classical_characters": 5687102,
  "direct_quotations": 3100,
  "later_characters": 20385859,
  "linked_characters": 451466,
  "linked_characters_percent": 7.9,
  "paragraphs": 85560,
  "parallel_passage_groups": 139634,
  "parallel_passages": 480270,
  "scanned_pages": 36361785,
  "statistics_updated": "2023-04-06 15:55:04",
  "wiki_chapters": 524934,
  "wiki_characters": 7076266392,
  "wiki_texts": 46085
}
```

### Identify a ctext.org link

Find out which book or chapter a ctext.org page shows, and get its title and text ID to use in later steps.

**Inputs**

- Link (`url`, text, required): A page on ctext.org showing a text or chapter.

**Outputs**

- `book_text_id` (text): The book's text ID.
- `book_title` (text): The title of the book it belongs to.
- `is_core_classic` (true/false): True for the library's curated classics.
- `text_id` (text): The text's ID.
- `title` (text): The title of the text or chapter.

**Example output**

```json
{
  "book_text_id": "ctp:mengzi",
  "book_title": "\u5b5f\u5b50",
  "is_core_classic": true,
  "text_id": "ctp:mengzi/liang-hui-wang-i",
  "title": "\u6881\u60e0\u738b\u4e0a"
}
```

### List Chinese dynasties

List the dynasties and periods of Chinese history with their dates, from the Western Zhou to the Republican era, or just the ones in power in a given year.

**Inputs**

- In the year (`year`, number): Optional. Only list dynasties in power that year. Use a negative number for BC, e.g. -500 for 500 BC. From -3000 to 2100.
- Names in (`name_language`, text): Give the dynasty names in English or Chinese. One of: `en` (English), `zh` (Chinese). Default: `en`.

**Outputs**

- `count` (number): How many dynasties are listed.
- `dynasties` (list): The dynasties, earliest first.
- `year` (number): The year asked about, if any.
- `year_label` (text): That year as readable text.

**Example output**

```json
{
  "count": 3,
  "dynasties": [
    {
      "dynasty_id": 27,
      "end_year": -221,
      "name": "Zhou",
      "period": "1046 BC \u2013 221 BC",
      "start_year": -1046
    },
    {
      "dynasty_id": 2,
      "end_year": -256,
      "name": "Eastern Zhou",
      "period": "770 BC \u2013 256 BC",
      "start_year": -770
    },
    {
      "dynasty_id": 3,
      "end_year": -476,
      "name": "Spring and Autumn",
      "period": "772 BC \u2013 476 BC",
      "start_year": -772
    }
  ],
  "year": -500,
  "year_label": "500 BC"
}
```

### List the classic texts

List the library's curated classics, such as the Analects, the Mencius, the Dao De Jing and the Art of War, with each one's text ID for later steps.

**Inputs**

- Characters (`script`, text): Show Chinese in traditional characters, as the library holds it, or converted to simplified characters. One of: `traditional` (Traditional characters (as the library holds them)), `simplified` (Simplified characters). Default: `traditional`.

**Outputs**

- `count` (number): How many classics there are.
- `texts` (list): The classic texts.

**Example output**

```json
{
  "count": 5,
  "texts": [
    {
      "is_core_classic": true,
      "text_id": "ctp:mozi",
      "title": "\u58a8\u5b50"
    },
    {
      "is_core_classic": true,
      "text_id": "ctp:analects",
      "title": "\u8ad6\u8a9e"
    },
    {
      "is_core_classic": true,
      "text_id": "ctp:mengzi",
      "title": "\u5b5f\u5b50"
    },
    {
      "is_core_classic": true,
      "text_id": "ctp:hanfeizi",
      "title": "\u97d3\u975e\u5b50"
    },
    {
      "is_core_classic": true,
      "text_id": "ctp:zhuangzi",
      "title": "\u838a\u5b50"
    }
  ]
}
```

### Look up a Chinese character

Get one Chinese character's pronunciations (Mandarin pinyin, zhuyin, Cantonese and the reconstructed Tang-era reading), its radical and stroke counts, and its other forms, such as the simplified or traditional version.

**Inputs**

- Character (`character`, text, required): One Chinese character, traditional or simplified.

**Outputs**

- `cantonese` (list): Cantonese readings in Jyutping.
- `character` (text): The character looked up.
- `dictionary_link` (text): The character's page on ctext.org.
- `middle_chinese` (list): Reconstructed Tang dynasty readings, where known.
- `pinyin` (list): Mandarin readings in pinyin.
- `pinyin_text` (text): The Mandarin readings as one line.
- `radical` (text): The radical the character is indexed under.
- `simplified_forms` (list): Its simplified forms, if any.
- `strokes_besides_radical` (number): How many strokes it has beyond its radical.
- `total_strokes` (number): How many strokes it is written with.
- `traditional_forms` (list): Its traditional forms, if any.
- `variant_count` (number): How many other forms are listed.
- `variants` (list): Every other form of the character, with how it relates.
- `zhuyin` (list): Mandarin readings in zhuyin (bopomofo).

**Example output**

```json
{
  "cantonese": [
    "ji6"
  ],
  "character": "\u7fa9",
  "dictionary_link": "https://ctext.org/dictionary.pl?if=en&char=\u7fa9",
  "middle_chinese": [
    "ngy\u025b\u0300"
  ],
  "pinyin": [
    "y\u00ec"
  ],
  "pinyin_text": "y\u00ec",
  "radical": "\u7f8a",
  "simplified_forms": [
    "\u4e49"
  ],
  "strokes_besides_radical": 7,
  "total_strokes": 13,
  "traditional_forms": [],
  "variant_count": 2,
  "variants": [
    {
      "character": "\u4e49",
      "relation": "Same meaning",
      "relation_code": "kSemanticVariant"
    },
    {
      "character": "\u4e49",
      "relation": "Simplified form",
      "relation_code": "kSimplifiedVariant"
    }
  ],
  "zhuyin": [
    "\u3127\u02cb"
  ]
}
```

### Search the dictionary

Find words, people and places in the library's dictionary of classical Chinese by the characters they are written with, such as every person whose name contains 孔.

**Inputs**

- Characters (`word`, text, required): The Chinese characters to look for.
- Match (`match`, text): How the entry has to match the characters. One of: `contains` (Contains these characters), `starts_with` (Starts with these characters), `exact` (Exactly these characters). Default: `contains`.
- Kinds of entry (`entry_types`, list): Optional. Leave empty to include every kind. One or more of: `word` (Words and phrases), `name` (People), `place` (Places).
- How many (`limit`, number): The most entries to return, between 1 and 500. From 1 to 500. Default: `50`.
- Characters used (`script`, text): Search and show the dictionary in traditional characters, as it is held, or converted to simplified. Type your characters in the same form. One of: `traditional` (Traditional characters (as the library holds them)), `simplified` (Simplified characters). Default: `traditional`.

**Outputs**

- `count` (number): How many entries are returned.
- `entries` (list): The matching entries, exact matches and shortest first.
- `total_found` (number): How many entries matched in all.

**Example output**

```json
{
  "count": 3,
  "entries": [
    {
      "entry_id": 3871,
      "entry_type": "name",
      "entry_type_label": "Person",
      "headword": "\u5b54"
    },
    {
      "entry_id": 1963,
      "entry_type": "name",
      "entry_type_label": "Person",
      "headword": "\u5b54\u4e18"
    },
    {
      "entry_id": 5179,
      "entry_type": "name",
      "entry_type_label": "Person",
      "headword": "\u5b54\u4f0b"
    }
  ],
  "total_found": 14
}
```
