Skip to content

Commit 67db408

Browse files
committed
use more descriptive str1 and str2 variable names when calculating _lcs_length
1 parent 3f3f840 commit 67db408

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/metrax/nlp_metrics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ def _get_ngrams(segment: list[str], max_order: int):
5454
return ngram_counts
5555

5656

57-
def _lcs_length(a: list[str], b: list[str]) -> int:
57+
def _lcs_length(str1: list[str], str2: list[str]) -> int:
5858
"""Computes the length of the Longest Common Subsequence (LCS)."""
59-
lengths = [[0 for j in range(len(b) + 1)] for i in range(len(a) + 1)]
60-
for i, x in enumerate(a):
61-
for j, y in enumerate(b):
59+
lengths = [[0 for j in range(len(str2) + 1)] for i in range(len(str1) + 1)]
60+
for i, x in enumerate(str1):
61+
for j, y in enumerate(str2):
6262
if x == y:
6363
lengths[i + 1][j + 1] = lengths[i][j] + 1
6464
else:
6565
lengths[i + 1][j + 1] = max(lengths[i + 1][j], lengths[i][j + 1])
66-
return lengths[len(a)][len(b)]
66+
return lengths[len(str1)][len(str2)]
6767

6868

6969
@flax.struct.dataclass

0 commit comments

Comments
 (0)