Merge pull request '重新修改factor' (#65) from zy into master

This commit is contained in:
MillerEvan 2022-09-19 16:41:05 +08:00
commit 2fc11e838c
1 changed files with 24 additions and 18 deletions

View File

@ -278,31 +278,37 @@ def factor_extractor(function_id_1: int, function_id_2: int, mysqlOp: MySQLOpera
if "test" or "Test" in path:
is_test = 2
else:
is_test = 0
filepath_1 = filepath[0].get("filepath").decode()
filepath_2 = filepath[1].get("filepath").decode()
while len(filepath_1) > 1:
path_1 = re.split("[\\\\ |/]", filepath_1, 1)
path_2 = re.split("[\\\\ |/]", filepath_2, 1)
if (path_1[0] == "test" or path_1[0] == "Test") and is_test <= 2:
is_test = is_test + 1
if (path_2[0] == "test" or path_2[0] == "Test") and is_test <= 2:
is_test = is_test + 1
if path_1[0] == path_2[0]:
if len(filepath_1) == len(filepath_2) == 0:
if filepath[0] == filepath[1]:
file_distance = 0
filepath = filepath[0].get("filepath").decode()
path = re.split("[\\\\ |/]", filepath)
if "test" or "Test" in path:
is_test = 2
else:
is_test = 0
filepath_1 = filepath[0].get("filepath").decode()
filepath_2 = filepath[1].get("filepath").decode()
while len(filepath_1) > 1:
path_1 = re.split("[\\\\ |/]", filepath_1, 1)
path_2 = re.split("[\\\\ |/]", filepath_2, 1)
if (path_1[0] == "test" or path_1[0] == "Test") and is_test <= 2:
is_test = is_test + 1
if (path_2[0] == "test" or path_2[0] == "Test") and is_test <= 2:
is_test = is_test + 1
if path_1[0] == path_2[0]:
file_distance = 0
break
else:
del path_1[0]
del path_2[0]
filepath_1 = path_1[0]
filepath_2 = path_2[0]
else:
if len(path_1) > len(path_2):
file_distance = len(path_1)
else:
file_distance = len(path_2)
break
if len(path_1) > len(path_2):
file_distance = len(path_1)
else:
file_distance = len(path_2)
break
except Exception:
print(repoInfo.id)
print(function_id_1, function_id_2)