refactor: replace fixed STYLE_user with open-ended style tag system
- STYLE_user renamed to STYLE_H1K0 in VOCAB (author's personal tag) - Style field now accepts any [A-Za-z][A-Za-z0-9_]* identifier in .chord files - Unknown styles fall back to STYLE_other at tokenization time with a log warning - Test fixtures updated to style: other; drop closed _VALID_STYLES frozenset - Spec bumped to v2.1: documents open style field, fallback behaviour, and §5.7 guide on registering a new style token Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -2,6 +2,6 @@
|
||||
# key: C_major
|
||||
# time: 4/4
|
||||
# subdivision: 4
|
||||
# style: user
|
||||
# style: other
|
||||
|
||||
| C . . . . | G . . . |
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@
|
||||
# key: C_major
|
||||
# time: 4/4
|
||||
# subdivision: 4
|
||||
# style: user
|
||||
# style: other
|
||||
|
||||
| C . . . | Xyz . . . |
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@
|
||||
# key: C_major
|
||||
# time: 4/4
|
||||
# subdivision: 4
|
||||
# style: user
|
||||
# style: other
|
||||
|
||||
| C . . . | Am7 . . . | F . . . | G7 . . . |
|
||||
|
||||
Vendored
+1
-1
@@ -2,6 +2,6 @@
|
||||
# key: B_minor
|
||||
# time: 4/4
|
||||
# subdivision: 4
|
||||
# style: user
|
||||
# style: other
|
||||
|
||||
| Bm . . . | C#m7b5 . . . | D . . . | F#7 . . . |
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
# key: C_major
|
||||
# time: 4/4
|
||||
# subdivision: 4
|
||||
# style: user
|
||||
# style: other
|
||||
# function: chorus
|
||||
|
||||
| C . . . | Am7 . . . | F/A . . . | G7 . . . | // first half
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@
|
||||
# key: F#_major
|
||||
# time: 4/4
|
||||
# subdivision: 4
|
||||
# style: user
|
||||
# style: other
|
||||
|
||||
| F#maj7 . . . | D#m7 . . . | Bmaj7 . F#/A# . | C# . . . |
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@
|
||||
# key: G#_minor
|
||||
# time: 4/4
|
||||
# subdivision: 4
|
||||
# style: user
|
||||
# style: other
|
||||
|
||||
| G#m . . . | A#maj7 . . . | Bmaj7/F# . . . | D#7 . . . |
|
||||
|
||||
@@ -40,7 +40,7 @@ class TestParseChordFile:
|
||||
assert p.key == "C_major"
|
||||
assert p.time == "4/4"
|
||||
assert p.subdivision == 4
|
||||
assert p.style == "user"
|
||||
assert p.style == "other"
|
||||
assert p.function == "chorus"
|
||||
|
||||
def test_c_major_bar_count(self):
|
||||
|
||||
@@ -21,7 +21,7 @@ def _write_pt(tmp_path: Path, stem: str, n_tokens: int) -> Path:
|
||||
"""Write a dummy .pt file with sequential token IDs."""
|
||||
tokens = torch.arange(n_tokens, dtype=torch.long)
|
||||
path = tmp_path / f"{stem}.pt"
|
||||
torch.save({"tokens": tokens, "meta": {"style": "user", "function": "verse"}}, path)
|
||||
torch.save({"tokens": tokens, "meta": {"style": "other", "function": "verse"}}, path)
|
||||
return path
|
||||
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ class TestTokenizeStructure:
|
||||
assert toks[1] == "MODE_major"
|
||||
assert toks[2] == "TIME_4/4"
|
||||
assert toks[3] == "SUB_4"
|
||||
assert toks[4] == "STYLE_user"
|
||||
assert toks[4] == "STYLE_other" # 'unspecified' is not in VOCAB → falls back to STYLE_other
|
||||
assert toks[5] == "FUNC_chorus"
|
||||
|
||||
def test_bar_token_count_matches_bar_count(self):
|
||||
|
||||
Reference in New Issue
Block a user