@@ -30,31 +30,31 @@ def detect_changes(original_text: str, optimized_text: str) -> list[str]:
3030
3131 try :
3232 # Split into lines for comparison
33- original_lines = [line .strip () for line in original_text .split (' \n ' ) if line .strip ()]
34- optimized_lines = [line .strip () for line in optimized_text .split (' \n ' ) if line .strip ()]
33+ original_lines = [line .strip () for line in original_text .split (" \n " ) if line .strip ()]
34+ optimized_lines = [line .strip () for line in optimized_text .split (" \n " ) if line .strip ()]
3535
3636 logger .debug (f"Detecting changes: { len (original_lines )} original lines vs { len (optimized_lines )} optimized lines" )
3737
3838 # Use SequenceMatcher to find differences
3939 matcher = SequenceMatcher (None , original_lines , optimized_lines )
4040
4141 for tag , i1 , i2 , j1 , j2 in matcher .get_opcodes ():
42- if tag == ' equal' :
42+ if tag == " equal" :
4343 continue
4444
4545 # Find section context for this change
4646 current_section , current_subsection = _find_section_context (i1 , original_lines )
4747 section_label = f"{ current_section } - { current_subsection } " if current_subsection else current_section
4848
49- if tag == ' replace' :
49+ if tag == " replace" :
5050 # Lines were changed
5151 original_chunk = original_lines [i1 :i2 ]
5252 optimized_chunk = optimized_lines [j1 :j2 ]
5353
5454 change_type = _analyze_change_type (original_chunk , optimized_chunk , current_section )
5555 changes .append (f"{ section_label } : { change_type } " )
5656
57- elif tag == ' delete' :
57+ elif tag == " delete" :
5858 # Lines were removed
5959 deleted_chunk = original_lines [i1 :i2 ]
6060
@@ -70,7 +70,7 @@ def detect_changes(original_text: str, optimized_text: str) -> list[str]:
7070 else :
7171 changes .append (f"{ section_label } : Removed { len (deleted_chunk )} less relevant item(s)" )
7272
73- elif tag == ' insert' :
73+ elif tag == " insert" :
7474 # Lines were added
7575 added_chunk = optimized_lines [j1 :j2 ]
7676
@@ -154,28 +154,28 @@ def _identify_section(line: str) -> str | None:
154154
155155 line_stripped = line .strip ()
156156 line_lower = line_stripped .lower ()
157- line_clean = line_stripped .rstrip (':' ).replace ('**' , '' ).replace ('*' , '' ).replace ('#' , '' ).strip ()
157+ line_clean = line_stripped .rstrip (":" ).replace ("**" , "" ).replace ("*" , "" ).replace ("#" , "" ).strip ()
158158
159159 # Skip empty lines or lines that are too long to be headers
160160 if not line_clean or len (line_clean ) > 60 :
161161 return None
162162
163163 # Skip bullet points
164- if line_stripped .startswith (('• ' , '- ' , '* ' , '○ ' , '▪ ' , '― ' )):
164+ if line_stripped .startswith (("• " , "- " , "* " , "○ " , "▪ " , "― " )):
165165 return None
166166
167167 # Skip lines with too many commas
168- if line .count (',' ) > 2 :
168+ if line .count ("," ) > 2 :
169169 return None
170170
171171 # Check if it's likely a section header
172172 is_header = False
173173
174174 if line_stripped .isupper ():
175175 is_header = True
176- elif line_stripped .endswith (':' ):
176+ elif line_stripped .endswith (":" ):
177177 is_header = True
178- elif '**' in line or line .startswith ('#' ):
178+ elif "**" in line or line .startswith ("#" ):
179179 is_header = True
180180 elif len (line_clean .split ()) <= 4 and len (line_clean ) < 40 :
181181 if line_clean [0 ].isupper ():
@@ -207,8 +207,8 @@ def _analyze_change_type(original: list[str], optimized: list[str], section: str
207207 Returns:
208208 Description of the change
209209 """
210- original_text = ' ' .join (original ).lower ()
211- optimized_text = ' ' .join (optimized ).lower ()
210+ original_text = " " .join (original ).lower ()
211+ optimized_text = " " .join (optimized ).lower ()
212212
213213 # Extract words for comparison
214214 original_words = set (original_text .split ())
@@ -220,7 +220,7 @@ def _analyze_change_type(original: list[str], optimized: list[str], section: str
220220 # Get significant additions (filter out common words)
221221 significant_additions = []
222222 for w in added_words :
223- cleaned = w .strip (' .,;:!?()[]{}" \' -' )
223+ cleaned = w .strip (" .,;:!?()[]{}\" '-" )
224224 if cleaned and cleaned not in COMMON_WORDS and len (cleaned ) > 2 :
225225 significant_additions .append (cleaned )
226226
@@ -231,9 +231,9 @@ def _analyze_change_type(original: list[str], optimized: list[str], section: str
231231 added_verbs = [w for w in significant_additions if w .lower () in ACTION_VERBS ]
232232
233233 # Provide specific feedback based on section and what was added
234- if section .lower () in [' skills' , ' technical skills' , ' technologies' ]:
234+ if section .lower () in [" skills" , " technical skills" , " technologies" ]:
235235 if significant_additions :
236- sample_skills = ', ' .join (sorted (list (set (significant_additions ))[:5 ]))
236+ sample_skills = ", " .join (sorted (list (set (significant_additions ))[:5 ]))
237237 return f"Added skills: { sample_skills } "
238238 elif len (added_words ) > len (removed_words ):
239239 return "Enhanced skill list with relevant technologies"
@@ -242,15 +242,15 @@ def _analyze_change_type(original: list[str], optimized: list[str], section: str
242242 display_limit = 8
243243 if added_tech :
244244 total = len (set (added_tech ))
245- sample = ', ' .join (sorted (list (set (added_tech ))[:display_limit ]))
245+ sample = ", " .join (sorted (list (set (added_tech ))[:display_limit ]))
246246 if total > display_limit :
247247 return f"Added keywords: { sample } , +{ total - display_limit } more"
248248 else :
249249 return f"Added keywords: { sample } "
250250
251251 elif added_testing :
252252 total = len (set (added_testing ))
253- sample = ', ' .join (sorted (list (set (added_testing ))[:display_limit ]))
253+ sample = ", " .join (sorted (list (set (added_testing ))[:display_limit ]))
254254 if total > display_limit :
255255 return f"Added testing keywords: { sample } , +{ total - display_limit } more"
256256 else :
@@ -260,17 +260,16 @@ def _analyze_change_type(original: list[str], optimized: list[str], section: str
260260 return "Added quantifiable metrics and impact"
261261
262262 elif added_verbs :
263- sample = ', ' .join (sorted (list (set (added_verbs ))[:3 ]))
263+ sample = ", " .join (sorted (list (set (added_verbs ))[:3 ]))
264264 return f"Strengthened with action verbs: { sample } "
265265
266266 elif len (significant_additions ) > 0 :
267-
268267 total = len (set (significant_additions ))
269268 if total <= display_limit :
270- sample = ', ' .join (sorted (list (set (significant_additions ))))
269+ sample = ", " .join (sorted (list (set (significant_additions ))))
271270 return f"Added keywords: { sample } "
272271 else :
273- sample = ', ' .join (sorted (list (set (significant_additions ))[:display_limit ]))
272+ sample = ", " .join (sorted (list (set (significant_additions ))[:display_limit ]))
274273 return f"Added keywords: { sample } , +{ total - display_limit } more"
275274 elif len (added_words ) > len (removed_words ):
276275 return "Enhanced with additional keywords"
@@ -293,17 +292,17 @@ def _consolidate_changes(changes: list[str]) -> list[str]:
293292 change_dict : dict [str , list [str ]] = {}
294293
295294 for change in changes :
296- if ':' in change :
297- section_label = change .split (':' , 1 )[0 ].strip ()
298- description = change .split (':' , 1 )[1 ].strip ()
295+ if ":" in change :
296+ section_label = change .split (":" , 1 )[0 ].strip ()
297+ description = change .split (":" , 1 )[1 ].strip ()
299298
300299 if section_label not in change_dict :
301300 change_dict [section_label ] = []
302301 change_dict [section_label ].append (description )
303302 else :
304- if ' Other' not in change_dict :
305- change_dict [' Other' ] = []
306- change_dict [' Other' ].append (change )
303+ if " Other" not in change_dict :
304+ change_dict [" Other" ] = []
305+ change_dict [" Other" ].append (change )
307306
308307 # Format consolidated changes
309308 grouped_changes = []
@@ -324,17 +323,17 @@ def _consolidate_changes(changes: list[str]) -> list[str]:
324323 if any (
325324 keyword_type in desc
326325 for keyword_type in [
327- ' Added skills:' ,
328- ' Added keywords:' ,
329- ' Added tech keywords:' ,
330- ' Added testing keywords:' ,
326+ " Added skills:" ,
327+ " Added keywords:" ,
328+ " Added tech keywords:" ,
329+ " Added testing keywords:" ,
331330 ]
332331 ):
333332 # Extract keywords
334- parts = desc .split (':' , 1 )
333+ parts = desc .split (":" , 1 )
335334 if len (parts ) > 1 :
336335 keyword_str = parts [1 ].strip ()
337- keyword_list = keyword_str .split (',' )[:- 1 ] if '+' in keyword_str else keyword_str .split (',' )
336+ keyword_list = keyword_str .split ("," )[:- 1 ] if "+" in keyword_str else keyword_str .split ("," )
338337 all_keywords .extend ([k .strip () for k in keyword_list if k .strip ()])
339338 else :
340339 other_changes .append (desc )
0 commit comments