Fixed Path Exclusion to no longer show grouped paths with too few elements, too short paths, and sorted output

This commit is contained in:
=
2025-08-29 09:00:34 -04:00
parent 8bb86f743c
commit 9a7de412f6
2 changed files with 27 additions and 16 deletions
+8 -2
View File
@@ -72,13 +72,19 @@ def add_longest_common_two_local(df, col="filename_x", new_col="longestcfp", min
return df
def export_groups_for_review(df, col="filename_x", group_col="longestcfp"):
def export_groups_for_review(df, col, group_col, min_number_in_group, path_length_constant):
"""
Compute longest common paths, group filepaths, write CSV for review.
"""
df = add_longest_common_two_local(df, col=col, new_col=group_col)
grouped = df.groupby(group_col)[col].apply(list).reset_index()
return grouped, df
grouped = grouped.sort_values(by=col)
print("Before filtering:", len(grouped))
grouped = grouped[grouped[col].apply(lambda x: len(x) >= min_number_in_group)]
filtered = grouped[grouped[group_col].apply(lambda x: len(os.path.normpath(x).split(os.sep)) >= path_length_constant)]
print("After filtering:", len(grouped))
return filtered, df