| | --- |
| | language: |
| | - en |
| | license: apache-2.0 |
| | task_categories: |
| | - text-generation |
| | tags: |
| | - crossword |
| | - rebus |
| | - nested-clues |
| | - word-puzzles |
| | pretty_name: Nested Crossword Clues |
| | size_categories: |
| | - 10K<n<100K |
| | source_datasets: |
| | - albertxu/CrosswordQA |
| | - wikimedia/wikipedia |
| | --- |
| | |
| | # Nested Crossword Clues |
| |
|
| | A dataset of English sentences with recursively nested crossword clue definitions. Each example starts from a natural sentence sampled from English Wikipedia, where content words are replaced by crossword-style definitions from [CrosswordQA](https://huggingface.co/datasets/albertxu/CrosswordQA). The definitions themselves are then recursively nested — words within clues are replaced by further clues — up to 10 levels deep. |
| |
|
| | ## Example |
| |
|
| | **Original sentence (level 0):** |
| |
|
| | > He developed the theory of relativity. |
| |
|
| | **Level 1** (words replaced with crossword clues): |
| |
|
| | > He [Brought to maturity] the [Hypothesis] of [Family connection]. |
| |
|
| | **Level 2** (words within clues replaced further): |
| |
|
| | > He [Brought to [Full growth]] the [[Educated guess]] of [Family [Link]]. |
| |
|
| | Each example records the sentence at every nesting level, from the plain original to the maximally nested version. |
| |
|
| | ## Dataset Fields |
| |
|
| | | Field | Type | Description | |
| | |-------|------|-------------| |
| | | `example_id` | `int` | Unique example identifier | |
| | | `source_article_title` | `string` | Title of the Wikipedia article the sentence was sampled from | |
| | | `original_sentence` | `string` | The original unmodified sentence (level 0) | |
| | | `levels` | `list[string]` | The sentence at each nesting depth. `levels[0]` is the original, `levels[k]` has `k` layers of `[bracketed clue]` nesting | |
| | | `max_nesting_depth` | `int` | The deepest nesting level achieved for this example | |
| | | `num_replacements_per_level` | `list[int]` | Number of word-to-clue replacements made at each depth level | |
| |
|
| | ## Construction |
| |
|
| | The dataset is built in four phases: |
| |
|
| | 1. **Clue Index**: A lookup table is built from the [CrosswordQA](https://huggingface.co/datasets/albertxu/CrosswordQA) train split (~6.4M clue-answer pairs), mapping lowercase answers (up to 2 words) to their corresponding clue strings. |
| |
|
| | 2. **Sentence Sampling**: Sentences are sampled from [English Wikipedia](https://huggingface.co/datasets/wikimedia/wikipedia) (November 2023 snapshot) via streaming and reservoir sampling. Sentences are filtered to 5–25 words, must end with sentence-ending punctuation, and must be free of wiki markup artifacts. |
| |
|
| | 3. **Recursive Nesting**: For each sentence, content words are replaced with randomly chosen crossword clues from the index. The replacement is then applied recursively to words within the clues themselves, building a tree of nested definitions up to a maximum depth of 10. A max-gap constraint ensures definitions are densely distributed — if too many consecutive words go unreplaced, replacement is forced or the example is dropped. |
| |
|
| | 4. **Anti-cycle Protection**: A set of already-replaced words is tracked across all nesting levels. Clues containing previously replaced words are rejected to prevent circular definitions. |
| |
|
| | ### Filters and Design Choices |
| |
|
| | - **Stopwords skipped**: Common English function words (articles, prepositions, pronouns, auxiliaries) are left unreplaced to maintain readability. |
| | - **Bigram matching**: Two-word answers from CrosswordQA are matched greedily before single words. |
| | - **Max-gap constraint**: At the sentence level (depth 1), if 3+ consecutive content words go unreplaced, the next replacement is forced. If no valid clue exists, the entire example is dropped and a new sentence is sampled. |
| | - **Min answer length**: Answers shorter than 3 characters are excluded from the index. |
| | - **Max clue length**: Clues longer than 80 characters are excluded. |
| | - **No brackets in clues**: Clues containing `[`, `]`, `(`, `)`, `{`, `}` are excluded to avoid ambiguity with the nesting notation. |
| |
|
| | ## Source Datasets |
| |
|
| | - **[CrosswordQA](https://huggingface.co/datasets/albertxu/CrosswordQA)** — 6.4M crossword clue-answer pairs (train split) |
| | - **[English Wikipedia](https://huggingface.co/datasets/wikimedia/wikipedia)** — November 2023 snapshot (`20231101.en` config) |
| |
|
| | ## Generation Script |
| |
|
| | The dataset was generated using [`scripts/build_nested_clues.py`](https://github.com/gsarti/rebus-reasoning/blob/main/scripts/build_nested_clues.py) from the [rebus-reasoning](https://github.com/gsarti/rebus-reasoning) repository. |
| |
|
| | ```bash |
| | python scripts/build_nested_clues.py \ |
| | --num-examples 100000 \ |
| | --max-depth 10 \ |
| | --seed 42 \ |
| | --max-answer-words 2 \ |
| | --max-gap 3 \ |
| | --replacement-prob 0.8 \ |
| | --articles-to-scan 50000 \ |
| | --save-index output/clue_index.json \ |
| | --output output/nested_clues.json |
| | ``` |
| |
|
| | ## License |
| |
|
| | Apache 2.0 |
| |
|