# What Are the Supported Languages for Chapter Detection in book-to-skill?

> Discover the seven languages supported for chapter detection in book-to-skill, including English, French, German, Spanish, Italian, and Dutch. Learn how language-specific keywords enhance its regex.

- Repository: [Virgilio Junior/book-to-skill](https://github.com/virgiliojr94/book-to-skill)
- Tags: how-to-guide
- Published: 2026-08-27

---

**`book-to-skill` supports chapter detection in seven natural languages: English, French, German, Spanish, Italian, Dutch, plus an abbreviated form (`ch.`), through language-specific keyword matching in its core regex.**

The `book-to-skill` library extracts structured content from books by identifying chapter boundaries automatically. Understanding which languages the chapter detection supports helps users determine if their documents will be parsed correctly without manual preprocessing. According to the `virgiliojr94/book-to-skill` source code, the detection system recognizes diverse linguistic conventions through a carefully crafted regular expression.

## How Chapter Detection Works in book-to-skill

The chapter detection logic resides in **[`book_to_skill/utils.py`](https://github.com/virgiliojr94/book-to-skill/blob/main/book_to_skill/utils.py)** at [**line 109**](https://github.com/virgiliojr94/book-to-skill/blob/master/book_to_skill/utils.py#L109). The implementation uses a **regex-based approach** that matches language-specific chapter keywords regardless of case or formatting variants.

The detection captures:

- Full chapter keywords in multiple languages
- Abbreviated forms (`ch.` or `ch`)
- Associated chapter numbers (Arabic numerals, Roman numerals, or other numeral systems)

### Detecting Structure with `detect_structure`

The primary entry point for chapter detection is the **`detect_structure()`** function in [`utils.py`](https://github.com/virgiliojr94/book-to-skill/blob/main/utils.py). This function processes raw text and returns identified structural elements including chapters.

## Complete List of Supported Languages for Chapter Detection

| Language | Keyword Matched | Notes |
|----------|---------------|-------|
| **English** | `chapter` | Standard form |
| **French** | `chapitre` | Common in French-language publications |
| **German** | `kapitel` | Used in German academic and trade books |
| **Spanish** | `capítulo` | Regex pattern `cap[ií]tulo` handles both `capitulo` and `capítulo` with accented í |
| **Italian** | `capitolo` | Standard Italian chapter designation |
| **Dutch** | `hoofdstuk` | Used in Dutch and Flemish books |
| **Abbreviation** | `ch.` / `ch` | Universal shorthand across languages |

These keywords trigger chapter detection whether they appear as standalone headings or embedded in longer text sequences.

## Code Examples: Chapter Detection in Practice

### Basic Chapter Detection

```python
from book_to_skill.utils import detect_structure

# English chapter heading

text_en = "# Chapter 3\nContent of the third chapter."

print(detect_structure(text_en))

# → detects chapter 3

```

### German Language Detection

```python
from book_to_skill.utils import detect_structure

text_de = "# Kapitel 5\nInhalt des fünften Kapitels."

print(detect_structure(text_de))

# → detects chapter 5

```

### Spanish with Accented Character

```python
from book_to_skill.utils import detect_structure

text_es = "# Capítulo 2\nContenido del segundo capítulo."

print(detect_structure(text_es))

# → detects chapter 2

```

### Abbreviated Chapter Form

```python
from book_to_skill.utils import detect_structure

text_abbr = "# Ch. 7\nSome content."

print(detect_structure(text_abbr))

# → detects chapter 7

```

## Where Chapter Detection Is Used

The supported languages for chapter detection power multiple components throughout the `book-to-skill` codebase:

- **[`book_to_skill/utils.py`](https://github.com/virgiliojr94/book-to-skill/blob/main/book_to_skill/utils.py)** — Contains the core regex and **`detect_structure()`** helper
- **[`book_to_skill/parsers/text.py`](https://github.com/virgiliojr94/book-to-skill/blob/main/book_to_skill/parsers/text.py)** — Applies detection when processing plain-text book files
- **[`tools/discovery_tax.py`](https://github.com/virgiliojr94/book-to-skill/blob/main/tools/discovery_tax.py)** — Invokes **`split_chapters()`**, which relies on the same language-aware detection rules

## Summary

- **Seven language variants** are supported for chapter detection: English (`chapter`), French (`chapitre`), German (`kapitel`), Spanish (`capítulo`/`capitulo`), Italian (`capitolo`), Dutch (`hoofdstuk`), and abbreviated `ch.`/`ch`
- The detection regex in **[`book_to_skill/utils.py`](https://github.com/virgiliojr94/book-to-skill/blob/main/book_to_skill/utils.py)** (line 109) handles case-insensitive matching and numeral variations
- **Spanish detection** specifically accommodates both accented (`í`) and unaccented (`i`) forms via pattern `cap[ií]tulo`
- All chapter numbers—Arabic, Roman, or other systems—are captured alongside the detected keyword
- The `detect_structure()` function provides the primary API for chapter identification

## Frequently Asked Questions

### Can I use book-to-skill with books in languages not on the supported list?

Currently, `book-to-skill` only recognizes the seven language variants explicitly defined in the regex. Books in Portuguese (`capítulo`), Russian, Chinese, or other languages will likely require manual chapter splitting or preprocessing to insert recognizable keywords. You can inspect the detection logic in [`book_to_skill/utils.py`](https://github.com/virgiliojr94/book-to-skill/blob/main/book_to_skill/utils.py) to understand the matching constraints.

### Does the Spanish detection require the accented í in capítulo?

No. The regex pattern `cap[ií]tulo` explicitly matches both `capitulo` (without accent) and `capítulo` (with accented í). This accommodates encoding variations and different input source formats without failing detection.

### Is the abbreviated "ch." form case-sensitive?

No. The chapter detection regex operates case-insensitively, so `CH.`, `Ch.`, `ch.`, and `CH` all trigger successful chapter identification. This flexibility handles diverse formatting conventions across publishers and document sources.

### How does book-to-skill handle Roman numerals in chapter headings?

The detection regex captures chapter numbers following the keyword regardless of numeral system. Both Arabic numerals (`Chapter 5`) and Roman numerals (`Chapter V`) are recognized and extracted as part of the chapter identifier, enabling consistent structural parsing across document styles.