Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/Data/curation/builders/phrase_deriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def zipped_readings_and_values(self) -> list[tuple[str, str]]:
if len(reading_parts) != len(self.value):
return None

self._cached_zipped_readings_and_values = list(zip(reading_parts, self.value, strict=True))
# Manual length validation for Python 3.9+ compatibility (strict=True requires 3.10+)
self._cached_zipped_readings_and_values = list(zip(reading_parts, self.value))
return self._cached_zipped_readings_and_values

@classmethod
Expand Down
53 changes: 27 additions & 26 deletions Source/Data/curation/validators/score_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def four_char_walk(
segcand = ""
segscore = 0
thisbpmf = "-".join(bpmfinput[0:2])
(segcand, segscore) = seg_pick(thisbpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, thisbpmf, segcand, segscore)
thisbpmf = "-".join(bpmfinput[2:4])
(a, b) = two_char_walk(phrases, thisbpmf)
segcand += a
Expand All @@ -163,16 +163,16 @@ def four_char_walk(
segcand = ""
segscore = 0
thisbpmf = "-".join(bpmfinput[0:3])
(segcand, segscore) = seg_pick(thisbpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, thisbpmf, segcand, segscore)
mybpmf = bpmfinput[3]
(segcand, segscore) = seg_pick(mybpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, mybpmf, segcand, segscore)
candidate.append((segcand, segscore))
# 1234
thisbpmf = "-".join(bpmfinput[0:4])
if thisbpmf in phrases:
segcand = ""
segscore = 0
(segcand, segscore) = seg_pick(thisbpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, thisbpmf, segcand, segscore)
candidate.append((segcand, segscore))
#
candidate.sort(key=lambda x: x[1], reverse=True)
Expand All @@ -195,7 +195,7 @@ def five_char_walk(
segcand = ""
segscore = 0
mybpmf = bpmfinput[0]
(segcand, segscore) = seg_pick(mybpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, mybpmf, segcand, segscore)
thisbpmf = "-".join(bpmfinput[1:5])
(a, b) = four_char_walk(phrases, thisbpmf)
segcand += a
Expand All @@ -211,9 +211,9 @@ def five_char_walk(
segcand = ""
segscore = 0
thisbpmf = "-".join(bpmfinput[0:2])
(segcand, segscore) = seg_pick(thisbpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, thisbpmf, segcand, segscore)
thisbpmf = "-".join(bpmfinput[2:5])
(a, b) = three_char_walk(thisbpmf)
(a, b) = three_char_walk(phrases, thisbpmf)
segcand += a
segscore += b
candidate.append((segcand, segscore))
Expand All @@ -226,7 +226,7 @@ def five_char_walk(
segcand = ""
segscore = 0
thisbpmf = "-".join(bpmfinput[0:3])
(segcand, segscore) = seg_pick(thisbpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, thisbpmf, segcand, segscore)
thisbpmf = "-".join(bpmfinput[3:5])
(a, b) = two_char_walk(phrases, thisbpmf)
segcand += a
Expand All @@ -237,16 +237,16 @@ def five_char_walk(
segcand = ""
segscore = 0
thisbpmf = "-".join(bpmfinput[0:4])
(segcand, segscore) = seg_pick(thisbpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, thisbpmf, segcand, segscore)
mybpmf = bpmfinput[4]
(segcand, segscore) = seg_pick(mybpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, mybpmf, segcand, segscore)
candidate.append((segcand, segscore))
# 12345
if "-".join(bpmfinput[0:5]) in phrases:
segcand = ""
segscore = 0
thisbpmf = "-".join(bpmfinput[0:5])
(segcand, segscore) = seg_pick(thisbpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, thisbpmf, segcand, segscore)
candidate.append((segcand, segscore))
#
candidate.sort(key=lambda x: x[1], reverse=True)
Expand All @@ -270,9 +270,9 @@ def six_char_walk(
segcand = ""
segscore = 0
mybpmf = bpmfinput[0]
(segcand, segscore) = seg_pick(mybpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, mybpmf, segcand, segscore)
thisbpmf = "-".join(bpmfinput[1:6])
(a, b) = four_char_walk(phrases, thisbpmf)
(a, b) = five_char_walk(phrases, thisbpmf)
segcand += a
segscore += b
candidate.append((segcand, segscore))
Expand All @@ -287,9 +287,9 @@ def six_char_walk(
segcand = ""
segscore = 0
thisbpmf = "-".join(bpmfinput[0:2])
(segcand, segscore) = seg_pick(thisbpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, thisbpmf, segcand, segscore)
thisbpmf = "-".join(bpmfinput[2:6])
(a, b) = three_char_walk(thisbpmf)
(a, b) = four_char_walk(phrases, thisbpmf)
segcand += a
segscore += b
candidate.append((segcand, segscore))
Expand All @@ -303,9 +303,9 @@ def six_char_walk(
segcand = ""
segscore = 0
thisbpmf = "-".join(bpmfinput[0:3])
(segcand, segscore) = seg_pick(thisbpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, thisbpmf, segcand, segscore)
thisbpmf = "-".join(bpmfinput[3:6])
(a, b) = three_char_walk(thisbpmf)
(a, b) = three_char_walk(phrases, thisbpmf)
segcand += a
segscore += b
candidate.append((segcand, segscore))
Expand All @@ -318,7 +318,7 @@ def six_char_walk(
segcand = ""
segscore = 0
thisbpmf = "-".join(bpmfinput[0:4])
(segcand, segscore) = seg_pick(thisbpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, thisbpmf, segcand, segscore)
thisbpmf = "-".join(bpmfinput[4:6])
(a, b) = two_char_walk(phrases, thisbpmf)
segcand += a
Expand All @@ -329,44 +329,45 @@ def six_char_walk(
segcand = ""
segscore = 0
thisbpmf = "-".join(bpmfinput[0:5])
(segcand, segscore) = seg_pick(thisbpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, thisbpmf, segcand, segscore)
mybpmf = bpmfinput[5]
(segcand, segscore) = seg_pick(mybpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, mybpmf, segcand, segscore)
candidate.append((segcand, segscore))
# 123456
if "-".join(bpmfinput[0:6]) in phrases:
segcand = ""
segscore = 0
thisbpmf = "-".join(bpmfinput[0:6])
(segcand, segscore) = seg_pick(thisbpmf, segcand, segscore)
(segcand, segscore) = seg_pick(phrases, thisbpmf, segcand, segscore)
candidate.append((segcand, segscore))
#
candidate.sort(key=lambda x: x[1], reverse=True)
return candidate[0]


def check_bpmf_output(phrases: dict[str, list[tuple[str, float]]], bpmf2chk: str) -> None:
if len(bpmf2chk.split("-")) == 2:
length = len(bpmf2chk.split("-"))
if length == 2:
(a, b) = two_char_walk(phrases, bpmf2chk)
(c, d) = phrases[bpmf2chk][0]
if (a, b) != (c, d):
print(f"{c} {d:f} {a} {b:f}")
if len(bpmf2chk.split("-")) == 3:
elif length == 3:
(a, b) = three_char_walk(phrases, bpmf2chk)
(c, d) = phrases[bpmf2chk][0]
if (a, b) != (c, d):
print(f"{c} {d:f} {a} {b:f}")
if len(bpmf2chk.split("-")) == 4:
elif length == 4:
(a, b) = four_char_walk(phrases, bpmf2chk)
(c, d) = phrases[bpmf2chk][0]
if (a, b) != (c, d):
print(f"{c} {d:f} {a} {b:f}")
if len(bpmf2chk.split("-")) == 5:
elif length == 5:
(a, b) = five_char_walk(phrases, bpmf2chk)
(c, d) = phrases[bpmf2chk][0]
if (a, b) != (c, d):
print(f"{c} {d:f} {a} {b:f}")
if len(bpmf2chk.split("-")) == 6:
elif length == 6:
(a, b) = six_char_walk(phrases, bpmf2chk)
(c, d) = phrases[bpmf2chk][0]
if (a, b) != (c, d):
Expand Down