mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix for title sorting, ignore numerics after 1st title word
This commit is contained in:
parent
c0f25a4428
commit
7977386ca0
@ -338,7 +338,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
elif hundredsComponent and tensComponent:
|
elif hundredsComponent and tensComponent:
|
||||||
result = hundredsComponentString + " " + tensComponentString
|
result = hundredsComponentString + " " + tensComponentString
|
||||||
else:
|
else:
|
||||||
prints(" NumberToText.stringFromInt(): empty result translating %d" % intToTranslate)
|
prints(" NumberToText.stringFromInt(): empty result translating %d" % intToTranslate)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def numberTranslate(self):
|
def numberTranslate(self):
|
||||||
@ -1879,7 +1879,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
# 'tag', 'file', 'authors'
|
# 'tag', 'file', 'authors'
|
||||||
|
|
||||||
self.opts.log.info(self.updateProgressFullStep("generateNCXByTags()"))
|
self.opts.log.info(self.updateProgressFullStep("generateNCXByTags()"))
|
||||||
|
|
||||||
if not len(self.genres):
|
if not len(self.genres):
|
||||||
self.opts.log.warn(" No genres found in tags.\n"
|
self.opts.log.warn(" No genres found in tags.\n"
|
||||||
" No Genre section added to Catalog")
|
" No Genre section added to Catalog")
|
||||||
@ -2296,14 +2296,20 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
# Convert the actual title to a string suitable for sorting.
|
# Convert the actual title to a string suitable for sorting.
|
||||||
# Convert numbers to strings, ignore leading stop words
|
# Convert numbers to strings, ignore leading stop words
|
||||||
# The 21-Day Consciousness Cleanse
|
# The 21-Day Consciousness Cleanse
|
||||||
|
# Scan for numbers in each word clump.
|
||||||
|
|
||||||
title_words = title.split(' ')
|
title_words = title.split()
|
||||||
|
stop_words = ['a','an','the']
|
||||||
# Scan for numbers in each word clump
|
|
||||||
translated = []
|
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):
|
for (i,word) in enumerate(title_words):
|
||||||
hit = re.search('[0-9]+',word)
|
# Don't translate numeric content after first title word
|
||||||
if hit :
|
if i==0 and re.search('[0-9]+',word):
|
||||||
translated.append(EPUB_MOBI.NumberToText(word).text)
|
translated.append(EPUB_MOBI.NumberToText(word).text)
|
||||||
else:
|
else:
|
||||||
translated.append(word)
|
translated.append(word)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user