fix: timed phrases may contain colons and @; only :number before the window is a weight
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
64a6b93713
commit
aa4efe3248
+3
-1
@@ -67,8 +67,10 @@ def parse(text: str):
|
||||
|
||||
|
||||
# (phrase@2.0-3.5) / (phrase:1.5@2.0-3.5): a TIMED phrase. Seconds from the scene start.
|
||||
# The phrase may contain `:` and `@` (shortcut replacements do): only a `:number` directly
|
||||
# before the `@t0-t1)` tail is a weight. Parentheses inside the phrase are still not allowed.
|
||||
_TIMED = re.compile(
|
||||
r"(?<!\\)\(([^():@]*?)(?::\s*(-?\d+(?:\.\d+)?))?\s*@\s*(\d+(?:\.\d+)?)\s*-\s*(\d+(?:\.\d+)?)\s*\)")
|
||||
r"(?<!\\)\(([^()]*?)(?::\s*(-?\d+(?:\.\d+)?))?\s*@\s*(\d+(?:\.\d+)?)\s*-\s*(\d+(?:\.\d+)?)\s*\)")
|
||||
# H3's latent time grid: latent frame k spans FRAME_PER_TOKEN[k % 5] pixel frames at 24 fps.
|
||||
FPS = 24
|
||||
FRAME_PER_TOKEN = (1, 4, 4, 4, 4)
|
||||
|
||||
@@ -440,7 +440,7 @@
|
||||
|
||||
// Timed phrases: `(phrase@t0-t1)` / `(phrase:w@t0-t1)`, seconds from the scene start. Mirrors
|
||||
// h3_token_weights._TIMED — the phrase is only allowed to shape the video inside its window.
|
||||
const TIMED_RE = /(?<!\\)\(([^():@]*?)(?::\s*(-?\d+(?:\.\d+)?))?\s*@\s*(\d+(?:\.\d+)?)\s*-\s*(\d+(?:\.\d+)?)\s*\)/g;
|
||||
const TIMED_RE = /(?<!\\)\(([^()]*?)(?::\s*(-?\d+(?:\.\d+)?))?\s*@\s*(\d+(?:\.\d+)?)\s*-\s*(\d+(?:\.\d+)?)\s*\)/g;
|
||||
function updateTimedHint() {
|
||||
if (!timedHintEl) return;
|
||||
const txt = composeTextarea ? composeTextarea.value : "";
|
||||
|
||||
@@ -867,3 +867,9 @@ def test_timed_and_untimed_spans_stack_and_a_window_weight_is_a_boost():
|
||||
assert prefix[0, 0, 0, 7] == inside[0, 0, 0, 7] == pytest.approx(math.log(2.0))
|
||||
assert inside[0, 0, 0, 4] == pytest.approx(math.log(1.5)) and prefix[0, 0, 0, 4] == 0
|
||||
assert outside[0, 0, 0, 4] == tw.MASKED_BIAS
|
||||
|
||||
|
||||
def test_a_phrase_may_contain_colons_and_at_signs():
|
||||
clean, spans = tw.parse_timed("(camera: slow push-in, mail@x.com @1-2) (fast:0.5@2-3)")
|
||||
assert clean == "camera: slow push-in, mail@x.com fast"
|
||||
assert spans == [(0, 32, 1.0, 1.0, 2.0), (33, 37, 0.5, 2.0, 3.0)]
|
||||
|
||||
Reference in New Issue
Block a user