RandomNameAnd6 commited on
Commit
be9dc9f
·
verified ·
1 Parent(s): 4ae72aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -42,7 +42,7 @@ def levenshtein_distance(s1, s2):
42
 
43
  return previous_row[-1]
44
 
45
- def string_similarity_index(original_text, comparison_text, threshold=0.65):
46
  """
47
  Calculate the similarity index between two strings based on Levenshtein distance
48
  and compare it to a threshold.
@@ -67,6 +67,14 @@ def string_similarity_index(original_text, comparison_text, threshold=0.65):
67
  # Compare the similarity score to the threshold
68
  return similarity_score >= threshold
69
 
 
 
 
 
 
 
 
 
70
  # Function to generate an AI title
71
  def generate_ai_title():
72
  while True:
@@ -78,7 +86,7 @@ def generate_ai_title():
78
  is_unique = True
79
  for title in dhar_mann_titles:
80
  title = title.strip() # Remove any extra whitespace characters like newlines
81
- if string_similarity_index(generated_title, title):
82
  is_unique = False
83
  print(f"Regenerating! Generated title was: \"{generated_title}\", and the real title was \"{title}\"")
84
  break
 
42
 
43
  return previous_row[-1]
44
 
45
+ def string_similarity_index(original_text, comparison_text, threshold=0.605):
46
  """
47
  Calculate the similarity index between two strings based on Levenshtein distance
48
  and compare it to a threshold.
 
67
  # Compare the similarity score to the threshold
68
  return similarity_score >= threshold
69
 
70
+ def remove_suffix(input_string):
71
+ if input_string.endswith(" | Dhar Mann"):
72
+ return input_string[:-12]
73
+ elif input_string.endswith(" | Dhar Mann Studios"):
74
+ return input_string[:-20]
75
+ else:
76
+ return input_string
77
+
78
  # Function to generate an AI title
79
  def generate_ai_title():
80
  while True:
 
86
  is_unique = True
87
  for title in dhar_mann_titles:
88
  title = title.strip() # Remove any extra whitespace characters like newlines
89
+ if string_similarity_index(remove_suffix(generated_title), remove_suffix(title)):
90
  is_unique = False
91
  print(f"Regenerating! Generated title was: \"{generated_title}\", and the real title was \"{title}\"")
92
  break