Nick Canu commited on
Commit
1b91973
·
1 Parent(s): 0fd0fe9

revising title generator

Browse files
Files changed (1) hide show
  1. title_generator.py +8 -8
title_generator.py CHANGED
@@ -75,22 +75,22 @@ class Title_Generator:
75
  def candidate_score(self,candidates,ex_check=None):
76
 
77
 
78
- if ex_check != None:
79
- pat = re.compile("((?:" + "|".join(map(re.escape, candidates[0]+[cand.upper() for cand in candidates[0]])) + "|" + "|".join(ex_check) +"))")
80
- desc = re.sub(pat, "__", candidates[1])
81
- else:
82
- pat = re.compile("((?:" + "|".join(map(re.escape, candidates[0]+[cand.upper() for cand in candidates[0]])) + "))")
83
- desc = re.sub(pat, "__", candidates[1])
84
 
85
 
86
  if re.search(re.compile(re.escape("__")), desc):
87
- reg = re.compile("("+"|".join(ex_check) + ")")
88
  hold = candidates[0]
89
  gen_desc = re.sub(re.compile(re.escape("__")),"",desc)
90
  candidates = self.candidate_generator(gen_desc)
91
- next = [cand for cand in candidates[0]+hold if not reg.search(cand)]
92
  candidates = (next, desc)
93
 
 
 
 
 
94
  #check for existing games and duplicates
95
  #transform function from https://stackoverflow.com/questions/42165779/python-how-to-remove-duplicate-valuescase-insensitive-from-a-list-with-same-o
96
  def transform(L):
 
75
  def candidate_score(self,candidates,ex_check=None):
76
 
77
 
78
+
79
+ pat = re.compile("((?:" + "|".join(map(re.escape, candidates[0]+[cand.upper() for cand in candidates[0]])) + "))")
80
+ desc = re.sub(pat, "__", candidates[1])
 
 
 
81
 
82
 
83
  if re.search(re.compile(re.escape("__")), desc):
 
84
  hold = candidates[0]
85
  gen_desc = re.sub(re.compile(re.escape("__")),"",desc)
86
  candidates = self.candidate_generator(gen_desc)
87
+ next = candidates[0]+hold
88
  candidates = (next, desc)
89
 
90
+ reg = re.compile("("+"|".join(ex_check) + ")")
91
+ step = [cand for cand in candidates[0] if not reg.search(cand)]
92
+ candidates = (step,candidates[1])
93
+
94
  #check for existing games and duplicates
95
  #transform function from https://stackoverflow.com/questions/42165779/python-how-to-remove-duplicate-valuescase-insensitive-from-a-list-with-same-o
96
  def transform(L):