gsarti commited on
Commit
c997d6a
·
verified ·
1 Parent(s): a44f5fd

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +96 -0
README.md ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: apache-2.0
5
+ task_categories:
6
+ - text-generation
7
+ tags:
8
+ - crossword
9
+ - rebus
10
+ - nested-clues
11
+ - word-puzzles
12
+ pretty_name: Nested Crossword Clues
13
+ size_categories:
14
+ - 10K<n<100K
15
+ source_datasets:
16
+ - albertxu/CrosswordQA
17
+ - wikimedia/wikipedia
18
+ ---
19
+
20
+ # Nested Crossword Clues
21
+
22
+ 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.
23
+
24
+ ## Example
25
+
26
+ **Original sentence (level 0):**
27
+
28
+ > He developed the theory of relativity.
29
+
30
+ **Level 1** (words replaced with crossword clues):
31
+
32
+ > He [Brought to maturity] the [Hypothesis] of [Family connection].
33
+
34
+ **Level 2** (words within clues replaced further):
35
+
36
+ > He [Brought to [Full growth]] the [[Educated guess]] of [Family [Link]].
37
+
38
+ Each example records the sentence at every nesting level, from the plain original to the maximally nested version.
39
+
40
+ ## Dataset Fields
41
+
42
+ | Field | Type | Description |
43
+ |-------|------|-------------|
44
+ | `example_id` | `int` | Unique example identifier |
45
+ | `source_article_title` | `string` | Title of the Wikipedia article the sentence was sampled from |
46
+ | `original_sentence` | `string` | The original unmodified sentence (level 0) |
47
+ | `levels` | `list[string]` | The sentence at each nesting depth. `levels[0]` is the original, `levels[k]` has `k` layers of `[bracketed clue]` nesting |
48
+ | `max_nesting_depth` | `int` | The deepest nesting level achieved for this example |
49
+ | `num_replacements_per_level` | `list[int]` | Number of word-to-clue replacements made at each depth level |
50
+
51
+ ## Construction
52
+
53
+ The dataset is built in four phases:
54
+
55
+ 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.
56
+
57
+ 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.
58
+
59
+ 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.
60
+
61
+ 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.
62
+
63
+ ### Filters and Design Choices
64
+
65
+ - **Stopwords skipped**: Common English function words (articles, prepositions, pronouns, auxiliaries) are left unreplaced to maintain readability.
66
+ - **Bigram matching**: Two-word answers from CrosswordQA are matched greedily before single words.
67
+ - **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.
68
+ - **Min answer length**: Answers shorter than 3 characters are excluded from the index.
69
+ - **Max clue length**: Clues longer than 80 characters are excluded.
70
+ - **No brackets in clues**: Clues containing `[`, `]`, `(`, `)`, `{`, `}` are excluded to avoid ambiguity with the nesting notation.
71
+
72
+ ## Source Datasets
73
+
74
+ - **[CrosswordQA](https://huggingface.co/datasets/albertxu/CrosswordQA)** — 6.4M crossword clue-answer pairs (train split)
75
+ - **[English Wikipedia](https://huggingface.co/datasets/wikimedia/wikipedia)** — November 2023 snapshot (`20231101.en` config)
76
+
77
+ ## Generation Script
78
+
79
+ 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.
80
+
81
+ ```bash
82
+ python scripts/build_nested_clues.py \
83
+ --num-examples 100000 \
84
+ --max-depth 10 \
85
+ --seed 42 \
86
+ --max-answer-words 2 \
87
+ --max-gap 3 \
88
+ --replacement-prob 0.8 \
89
+ --articles-to-scan 50000 \
90
+ --save-index output/clue_index.json \
91
+ --output output/nested_clues.json
92
+ ```
93
+
94
+ ## License
95
+
96
+ Apache 2.0