Skip to content

Commit 393879a

Browse files
committed
Rename WordDetection -> WordClassification (better fit for the default behavior)
By default the task does multi-class word classification; the "detection" framing is only accurate in keyword-detection mode (``keyword_detection="cat"`` -> binary y/n). WordClassification is the clearer name for both pnpl.tasks.libribrain.WordClassification and the per-dataset variants in gwilliams2022 and pallier2025. A backwards-compatible ``WordDetection = WordClassification`` alias is exported from each module so code written against pnpl 0.1.0 (``from pnpl.tasks import WordDetection``) keeps working unchanged. The public-API test now asserts both names point at the same class. Files renamed (via git mv) so import paths track the class name: pnpl/tasks/libribrain/word_detection.py -> pnpl/tasks/libribrain/word_classification.py pnpl/tasks/gwilliams2022/word_detection.py -> pnpl/tasks/gwilliams2022/word_classification.py pnpl/tasks/pallier2025/word_detection.py -> pnpl/tasks/pallier2025/word_classification.py Internal usage in dataset compat wrappers, examples, tests, and docs all switched to the canonical name. Stale autosummary stubs deleted; new ones regenerate at the WordClassification path.
1 parent 868a733 commit 393879a

25 files changed

Lines changed: 193 additions & 160 deletions
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
pnpl.tasks.gwilliams2022.WordClassification
2+
===========================================
3+
4+
.. currentmodule:: pnpl.tasks.gwilliams2022
5+
6+
.. autoclass:: WordClassification
7+
8+
9+
.. automethod:: __init__
10+
11+
12+
.. rubric:: Methods
13+
14+
.. autosummary::
15+
16+
~WordClassification.__init__
17+
~WordClassification.collect_samples
18+
~WordClassification.get_label
19+
20+
21+
22+
23+
24+
.. rubric:: Attributes
25+
26+
.. autosummary::
27+
28+
~WordClassification.label_info
29+
~WordClassification.require_pronounced
30+
~WordClassification.tmax
31+
~WordClassification.tmin
32+
33+

docs/api/generated/pnpl.tasks.gwilliams2022.WordDetection.rst

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
pnpl.tasks.libribrain.WordClassification
2+
========================================
3+
4+
.. currentmodule:: pnpl.tasks.libribrain
5+
6+
.. autoclass:: WordClassification
7+
8+
9+
.. automethod:: __init__
10+
11+
12+
.. rubric:: Methods
13+
14+
.. autosummary::
15+
16+
~WordClassification.__init__
17+
~WordClassification.collect_samples
18+
~WordClassification.get_label
19+
20+
21+
22+
23+
24+
.. rubric:: Attributes
25+
26+
.. autosummary::
27+
28+
~WordClassification.is_keyword_mode
29+
~WordClassification.keyword_detection
30+
~WordClassification.label_info
31+
~WordClassification.max_word_length
32+
~WordClassification.min_word_length
33+
~WordClassification.negative_buffer
34+
~WordClassification.positive_buffer
35+
~WordClassification.tmax
36+
~WordClassification.tmin
37+
38+

docs/api/generated/pnpl.tasks.libribrain.WordDetection.rst

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
pnpl.tasks.pallier2025.WordClassification
2+
=========================================
3+
4+
.. currentmodule:: pnpl.tasks.pallier2025
5+
6+
.. autoclass:: WordClassification
7+
8+
9+
.. automethod:: __init__
10+
11+
12+
.. rubric:: Methods
13+
14+
.. autosummary::
15+
16+
~WordClassification.__init__
17+
~WordClassification.collect_samples
18+
~WordClassification.get_label
19+
20+
21+
22+
23+
24+
.. rubric:: Attributes
25+
26+
.. autosummary::
27+
28+
~WordClassification.keep_top_k
29+
~WordClassification.label_info
30+
~WordClassification.max_word_length
31+
~WordClassification.min_word_length
32+
~WordClassification.tmax
33+
~WordClassification.tmin
34+
35+

docs/api/generated/pnpl.tasks.pallier2025.WordDetection.rst

Lines changed: 0 additions & 35 deletions
This file was deleted.

docs/api/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ module.
4444
pnpl.tasks.base.TaskProtocol
4545
pnpl.tasks.libribrain.SpeechDetection
4646
pnpl.tasks.libribrain.PhonemeClassification
47-
pnpl.tasks.libribrain.WordDetection
47+
pnpl.tasks.libribrain.WordClassification
4848
pnpl.tasks.gwilliams2022.PhonemeClassification
49-
pnpl.tasks.gwilliams2022.WordDetection
49+
pnpl.tasks.gwilliams2022.WordClassification
5050
pnpl.tasks.armeni2022.PhonemeClassification
5151
pnpl.tasks.schoffelen2019.TrialEpoching
52-
pnpl.tasks.pallier2025.WordDetection
52+
pnpl.tasks.pallier2025.WordClassification
5353
```
5454

5555
## Preprocessing

docs/gwilliams2022.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ prints a warning.
6060
## Selected arguments
6161

6262
- `task` — any object implementing `TaskProtocol`. Built-ins live in
63-
`pnpl.tasks.gwilliams2022` (`PhonemeClassification`, `WordDetection`).
63+
`pnpl.tasks.gwilliams2022` (`PhonemeClassification`, `WordClassification`).
6464
- `preprocessing` — pipeline string used in derivative filenames
6565
(e.g. `"notch+bp+ds"`). Set to `None` to materialize H5 from the raw
6666
KIT recording without filtering.
@@ -77,10 +77,10 @@ prints a warning.
7777
## Available tasks
7878

7979
```python
80-
from pnpl.tasks.gwilliams2022 import PhonemeClassification, WordDetection
80+
from pnpl.tasks.gwilliams2022 import PhonemeClassification, WordClassification
8181
```
8282

8383
- `PhonemeClassification(tmin, tmax, label_type="phoneme" | "voicing")`
8484
— sample windowed around each phoneme onset.
85-
- `WordDetection(tmin, tmax, require_pronounced=True)` — sample
85+
- `WordClassification(tmin, tmax, require_pronounced=True)` — sample
8686
windowed around each word onset; label is the word string.

docs/pallier2025.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ The companion paper is d'Ascoli, Bel, Rapin, King et al.,
2323

2424
```python
2525
from pnpl.datasets import Pallier2025
26-
from pnpl.tasks.pallier2025 import WordDetection
26+
from pnpl.tasks.pallier2025 import WordClassification
2727

2828
ds = Pallier2025(
2929
data_path="./data/pallier2025",
30-
task=WordDetection(tmin=0.0, tmax=3.0),
30+
task=WordClassification(tmin=0.0, tmax=3.0),
3131
include_subjects=["01"],
3232
include_runs=["01"], # one ~10 min audiobook segment
3333
preprocessing="notch+bp+ds", # 50/100 Hz notch, 0.1–125 Hz bp, 250 Hz resample
@@ -76,7 +76,7 @@ notch or SSS. The pipeline is configurable on a per-step basis:
7676
```python
7777
ds = Pallier2025(
7878
data_path="./data/pallier2025",
79-
task=WordDetection(tmin=0.0, tmax=3.0),
79+
task=WordClassification(tmin=0.0, tmax=3.0),
8080
include_subjects=["01"],
8181
preprocessing="bp+ds",
8282
preprocessing_config={
@@ -91,7 +91,7 @@ mechanism (defaults < JSON < dataset config).
9191

9292
## Selected arguments
9393

94-
- `task` — currently `pnpl.tasks.pallier2025.WordDetection`.
94+
- `task` — currently `pnpl.tasks.pallier2025.WordClassification`.
9595
- `preprocessing` — pipeline string used in derivative filenames.
9696
Default `"notch+bp+ds"`. `None` materializes H5 from the raw FIF
9797
unchanged.
@@ -106,7 +106,7 @@ mechanism (defaults < JSON < dataset config).
106106

107107
## Available task
108108

109-
`WordDetection(tmin, tmax, min_word_length, max_word_length, keep_top_k)`
109+
`WordClassification(tmin, tmax, min_word_length, max_word_length, keep_top_k)`
110110
windowed around each word onset.
111111

112112
- `tmin`, `tmax` — defaults `0.0`, `3.0` to match d'Ascoli 2025.

docs/tasks.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ default `label_info` implementation if you set `_classes` /
5353
from pnpl.tasks import (
5454
SpeechDetection,
5555
PhonemeClassification,
56-
WordDetection,
56+
WordClassification,
5757
)
5858
```
5959

@@ -65,20 +65,20 @@ from pnpl.tasks import (
6565
*speech* / *silence*. Returns a per-time-point label array.
6666
- `PhonemeClassification(tmin, tmax, label_type="phoneme" | "voicing", exclude_phonemes=[])`
6767
— sample windowed around each phoneme onset.
68-
- `WordDetection(tmin, tmax, min_word_length=1, max_word_length=None, keyword_detection=None)`
68+
- `WordClassification(tmin, tmax, min_word_length=1, max_word_length=None, keyword_detection=None)`
6969
— multi-class word classification *or* binary keyword detection
7070
(`keyword_detection="cat"` → 1 if the window's word is `"cat"`, else
7171
0). `tmin` / `tmax` may be `None` to auto-compute from word duration.
7272

7373
## MEG-MASC tasks (Gwilliams 2022)
7474

7575
```python
76-
from pnpl.tasks.gwilliams2022 import PhonemeClassification, WordDetection
76+
from pnpl.tasks.gwilliams2022 import PhonemeClassification, WordClassification
7777
```
7878

7979
- `PhonemeClassification(tmin, tmax, label_type="phoneme" | "voicing")`
8080
— phoneme-aligned epochs from the MEG-MASC events.tsv.
81-
- `WordDetection(tmin, tmax, require_pronounced=True)` — word-aligned
81+
- `WordClassification(tmin, tmax, require_pronounced=True)` — word-aligned
8282
epochs; label is the lower-cased word string.
8383

8484
## Armeni 2022 tasks
@@ -94,10 +94,10 @@ from pnpl.tasks.armeni2022 import PhonemeClassification
9494
## Pallier 2025 (LittlePrince Listen) tasks
9595

9696
```python
97-
from pnpl.tasks.pallier2025 import WordDetection
97+
from pnpl.tasks.pallier2025 import WordClassification
9898
```
9999

100-
- `WordDetection(tmin, tmax, min_word_length, max_word_length, keep_top_k)`
100+
- `WordClassification(tmin, tmax, min_word_length, max_word_length, keep_top_k)`
101101
— windowed around each word onset (`trial_type='Word'` rows in the
102102
events.tsv). Default `tmin=0.0`, `tmax=3.0` matches the d'Ascoli et
103103
al. (Nat Commun 2025) recipe. `keep_top_k` restricts the label

0 commit comments

Comments
 (0)