URL: http://github.com/derek73/python-nameparser/pull/157.patch
771,7 @@ def parse_pieces(self, parts, additional_parts_count=0): # split on periods, any of the split pieces titles or suffixes? # ("Lt.Gov.") period_chunks = part.split(".") - titles = list(filter(self.is_title, period_chunks)) + titles = list(filter(self.is_title, period_chunks)) suffixes = list(filter(self.is_suffix, period_chunks)) # add the part to the constant so it will be found @@ -813,7 +823,7 @@ def join_on_conjunctions(self, pieces, additional_parts_count=0): contiguous_conj_i = [] for i, val in enumerate(conj_index): try: - if conj_index[i+1] == val+1: + if conj_index[i + 1] == val + 1: contiguous_conj_i += [val] except IndexError: pass @@ -823,12 +833,12 @@ def join_on_conjunctions(self, pieces, additional_parts_count=0): delete_i = [] for i in contiguous_conj_i: if type(i) == tuple: - new_piece = " ".join(pieces[i[0]: i[1]+1]) - delete_i += list(range(i[0]+1, i[1]+1)) + new_piece = " ".join(pieces[i[0]: i[1] + 1]) + delete_i += list(range(i[0] + 1, i[1] + 1)) pieces[i[0]] = new_piece else: - new_piece = " ".join(pieces[i: i+2]) - delete_i += [i+1] + new_piece = " ".join(pieces[i: i + 2]) + delete_i += [i + 1] pieces[i] = new_piece # add newly joined conjunctions to constants to be found later self.C.conjunctions.add(new_piece) @@ -853,23 +863,23 @@ def join_on_conjunctions(self, pieces, additional_parts_count=0): continue if i == 0: - new_piece = " ".join(pieces[i:i+2]) - if self.is_title(pieces[i+1]): + new_piece = " ".join(pieces[i:i + 2]) + if self.is_title(pieces[i + 1]): # when joining to a title, make new_piece a title too self.C.titles.add(new_piece) pieces[i] = new_piece - pieces.pop(i+1) + pieces.pop(i + 1) # subtract 1 from the index of all the remaining conjunctions for j, val in enumerate(conj_index): if val > i: - conj_index[j] = val-1 + conj_index[j] = val - 1 else: - new_piece = " ".join(pieces[i-1:i+2]) - if self.is_title(pieces[i-1]): + new_piece = " ".join(pieces[i - 1:i + 2]) + if self.is_title(pieces[i - 1]): # when joining to a title, make new_piece a title too self.C.titles.add(new_piece) - pieces[i-1] = new_piece + pieces[i - 1] = new_piece pieces.pop(i) rm_count = 2 try: @@ -932,7 +942,7 @@ def join_on_conjunctions(self, pieces, additional_parts_count=0): def cap_word(self, word, attribute): if (self.is_prefix(word) and attribute in ('last', 'middle')) \ - or self.is_conjunction(word): + or self.is_conjunction(word): return word.lower() exceptions = self.C.capitalization_exceptions if lc(word) in exceptions: @@ -941,6 +951,7 @@ def cap_word(self, word, attribute): if mac_match: def cap_after_mac(m): return m.group(1).capitalize() + m.group(2).capitalize() + return self.C.regexes.mac.sub(cap_after_mac, word) else: return word.capitalize() @@ -950,6 +961,7 @@ def cap_piece(self, piece, attribute): return "" def replacement(m): return self.cap_word(m.group(0), attribute) + return self.C.regexes.word.sub(replacement, piece) def capitalize(self, force=None): From e1bfb5813300f8190aa55140f4741f25233367ce Mon Sep 17 00:00:00 2001 From: fdesoyeNote: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: