def format_desc(desc, ref_desc, use_colour):
"""
Return potentially colourised string list of descriptor features.
"""
desc, ref_desc = desc_to_str(desc), desc_to_str(ref_desc)
final_string = ""
for string, ref_string in zip(desc.split(","), ref_desc.split(",")):
for char, ref_char in itertools.zip_longest(string, ref_string):
# If a character in the string is identical to the reference
# string, we highlight it in red. That makes it easier to visually
# spot similarities in the descriptors.
if (char == ref_char) and use_colour:
final_string += termcolor.colored(char, "red")
else:
final_string += char if char is not None else " "
final_string += ","
return final_string.split(",")
评论列表
文章目录