mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-05 06:23:42 +02:00
Fix for title sorting, ignore numerics after 1st title word
This commit is contained in:
parent
c0f25a4428
commit
7977386ca0
1 changed files with 13 additions and 7 deletions
|
|
@ -338,7 +338,7 @@ def stringFromInt(self, intToTranslate):
|
|||
elif hundredsComponent and tensComponent:
|
||||
result = hundredsComponentString + " " + tensComponentString
|
||||
else:
|
||||
prints(" NumberToText.stringFromInt(): empty result translating %d" % intToTranslate)
|
||||
prints(" NumberToText.stringFromInt(): empty result translating %d" % intToTranslate)
|
||||
return result
|
||||
|
||||
def numberTranslate(self):
|
||||
|
|
@ -1879,7 +1879,7 @@ def generateNCXByTags(self, tocTitle):
|
|||
# 'tag', 'file', 'authors'
|
||||
|
||||
self.opts.log.info(self.updateProgressFullStep("generateNCXByTags()"))
|
||||
|
||||
|
||||
if not len(self.genres):
|
||||
self.opts.log.warn(" No genres found in tags.\n"
|
||||
" No Genre section added to Catalog")
|
||||
|
|
@ -2296,14 +2296,20 @@ def generateSortTitle(self, title):
|
|||
# Convert the actual title to a string suitable for sorting.
|
||||
# Convert numbers to strings, ignore leading stop words
|
||||
# The 21-Day Consciousness Cleanse
|
||||
# Scan for numbers in each word clump.
|
||||
|
||||
title_words = title.split(' ')
|
||||
|
||||
# Scan for numbers in each word clump
|
||||
title_words = title.split()
|
||||
stop_words = ['a','an','the']
|
||||
translated = []
|
||||
|
||||
# Remove the stop words
|
||||
# GwR *** conform this with KG's stop word list
|
||||
while title_words[0].lower() in stop_words:
|
||||
stop_word = title_words.pop(0)
|
||||
|
||||
for (i,word) in enumerate(title_words):
|
||||
hit = re.search('[0-9]+',word)
|
||||
if hit :
|
||||
# Don't translate numeric content after first title word
|
||||
if i==0 and re.search('[0-9]+',word):
|
||||
translated.append(EPUB_MOBI.NumberToText(word).text)
|
||||
else:
|
||||
translated.append(word)
|
||||
|
|
|
|||
Loading…
Reference in a new issue