forked from openlp/openlp
Fix many whitespace issues.
This commit is contained in:
parent
9597c9f129
commit
6d5935a0b9
@ -167,19 +167,19 @@ class DuplicateSongRemovalForm(OpenLPWizard):
|
|||||||
self.duplicateSearchProgressBar.setValue(1)
|
self.duplicateSearchProgressBar.setValue(1)
|
||||||
self.notifyNoDuplicates()
|
self.notifyNoDuplicates()
|
||||||
return
|
return
|
||||||
# with x songs we have x*(x-1)/2 comparisons
|
# with x songs we have x*(x - 1) / 2 comparisons
|
||||||
maxProgressCount = maxSongs*(maxSongs-1)/2
|
maxProgressCount = maxSongs * (maxSongs - 1) / 2
|
||||||
self.duplicateSearchProgressBar.setMaximum(maxProgressCount)
|
self.duplicateSearchProgressBar.setMaximum(maxProgressCount)
|
||||||
songs = self.plugin.manager.get_all_objects(Song)
|
songs = self.plugin.manager.get_all_objects(Song)
|
||||||
for outerSongCounter in range(maxSongs-1):
|
for outerSongCounter in range(maxSongs - 1):
|
||||||
for innerSongCounter in range(outerSongCounter+1, maxSongs):
|
for innerSongCounter in range(outerSongCounter + 1, maxSongs):
|
||||||
doubleFinder = DuplicateSongFinder()
|
doubleFinder = DuplicateSongFinder()
|
||||||
if doubleFinder.songsProbablyEqual(songs[outerSongCounter], songs[innerSongCounter]):
|
if doubleFinder.songsProbablyEqual(songs[outerSongCounter], songs[innerSongCounter]):
|
||||||
duplicateAdded = self.addDuplicatesToSongList(songs[outerSongCounter], songs[innerSongCounter])
|
duplicateAdded = self.addDuplicatesToSongList(songs[outerSongCounter], songs[innerSongCounter])
|
||||||
if duplicateAdded:
|
if duplicateAdded:
|
||||||
self.foundDuplicatesEdit.appendPlainText(songs[outerSongCounter].title + " = " +
|
self.foundDuplicatesEdit.appendPlainText(songs[outerSongCounter].title + " = " +
|
||||||
songs[innerSongCounter].title)
|
songs[innerSongCounter].title)
|
||||||
self.duplicateSearchProgressBar.setValue(self.duplicateSearchProgressBar.value()+1)
|
self.duplicateSearchProgressBar.setValue(self.duplicateSearchProgressBar.value() + 1)
|
||||||
self.reviewTotalCount = len(self.duplicateSongList)
|
self.reviewTotalCount = len(self.duplicateSongList)
|
||||||
if self.reviewTotalCount == 0:
|
if self.reviewTotalCount == 0:
|
||||||
self.notifyNoDuplicates()
|
self.notifyNoDuplicates()
|
||||||
|
@ -75,7 +75,7 @@ class DuplicateSongFinder(object):
|
|||||||
diff_no_typos = self.__removeTypos(diff_tuples)
|
diff_no_typos = self.__removeTypos(diff_tuples)
|
||||||
#print(diff_no_typos)
|
#print(diff_no_typos)
|
||||||
if self.__lengthOfEqualBlocks(diff_no_typos) >= self.minBlockSize or \
|
if self.__lengthOfEqualBlocks(diff_no_typos) >= self.minBlockSize or \
|
||||||
self.__lengthOfLongestEqualBlock(diff_no_typos) > len(small)*2/3:
|
self.__lengthOfLongestEqualBlock(diff_no_typos) > len(small) * 2 / 3:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@ -87,7 +87,7 @@ class DuplicateSongFinder(object):
|
|||||||
``opcode``
|
``opcode``
|
||||||
The difference.
|
The difference.
|
||||||
"""
|
"""
|
||||||
return max(opcode[2]-opcode[1], opcode[4] - opcode[3])
|
return max(opcode[2] - opcode[1], opcode[4] - opcode[3])
|
||||||
|
|
||||||
def __removeTypos(self, diff):
|
def __removeTypos(self, diff):
|
||||||
"""
|
"""
|
||||||
@ -104,11 +104,11 @@ class DuplicateSongFinder(object):
|
|||||||
del diff[0]
|
del diff[0]
|
||||||
#remove typos in the middle of string
|
#remove typos in the middle of string
|
||||||
if len(diff) >= 3:
|
if len(diff) >= 3:
|
||||||
for index in range(len(diff)-3, -1, -1):
|
for index in range(len(diff) - 3, -1, -1):
|
||||||
if self.__opLength(diff[index]) >= self.minFragmentSize and \
|
if self.__opLength(diff[index]) >= self.minFragmentSize and \
|
||||||
diff[index+1][0] != "equal" and self.__opLength(diff[index+1]) <= self.maxTypoSize and \
|
diff[index + 1][0] != "equal" and self.__opLength(diff[index + 1]) <= self.maxTypoSize and \
|
||||||
self.__opLength(diff[index+2]) >= self.minFragmentSize:
|
self.__opLength(diff[index + 2]) >= self.minFragmentSize:
|
||||||
del diff[index+1]
|
del diff[index + 1]
|
||||||
#remove typo at the end of string
|
#remove typo at the end of string
|
||||||
if len(diff) >= 2:
|
if len(diff) >= 2:
|
||||||
if self.__opLength(diff[-2]) >= self.minFragmentSize and \
|
if self.__opLength(diff[-2]) >= self.minFragmentSize and \
|
||||||
@ -116,12 +116,12 @@ class DuplicateSongFinder(object):
|
|||||||
del diff[-1]
|
del diff[-1]
|
||||||
|
|
||||||
#merge fragments
|
#merge fragments
|
||||||
for index in range(len(diff)-2, -1, -1):
|
for index in range(len(diff) - 2, -1, -1):
|
||||||
if diff[index][0] == "equal" and self.__opLength(diff[index]) >= self.minFragmentSize and \
|
if diff[index][0] == "equal" and self.__opLength(diff[index]) >= self.minFragmentSize and \
|
||||||
diff[index+1][0] == "equal" and self.__opLength(diff[index+1]) >= self.minFragmentSize:
|
diff[index + 1][0] == "equal" and self.__opLength(diff[index + 1]) >= self.minFragmentSize:
|
||||||
diff[index] = ("equal", diff[index][1], diff[index+1][2], diff[index][3],
|
diff[index] = ("equal", diff[index][1], diff[index + 1][2], diff[index][3],
|
||||||
diff[index+1][4])
|
diff[index + 1][4])
|
||||||
del diff[index+1]
|
del diff[index + 1]
|
||||||
|
|
||||||
return diff
|
return diff
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user