mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get rid of the check for break iterator since the spell code wont exist for long in master without a matching binary release
This commit is contained in:
parent
7088ae51db
commit
17ac015c64
@ -9,7 +9,7 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
import sys
|
import sys
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from calibre.spell.break_iterator import has_break_iterator, split_into_words
|
from calibre.spell.break_iterator import split_into_words
|
||||||
from calibre.spell.dictionary import parse_lang_code
|
from calibre.spell.dictionary import parse_lang_code
|
||||||
from calibre.ebooks.oeb.base import barename
|
from calibre.ebooks.oeb.base import barename
|
||||||
from calibre.ebooks.oeb.polish.container import OPF_NAMESPACES, get_container
|
from calibre.ebooks.oeb.polish.container import OPF_NAMESPACES, get_container
|
||||||
@ -56,17 +56,12 @@ def filter_words(word):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if has_break_iterator:
|
def get_words(text, lang):
|
||||||
def get_words(text, lang):
|
|
||||||
try:
|
try:
|
||||||
ans = split_into_words(unicode(text), lang)
|
ans = split_into_words(unicode(text), lang)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
return ()
|
return ()
|
||||||
return filter(filter_words, ans)
|
return filter(filter_words, ans)
|
||||||
else:
|
|
||||||
def get_words(text, lang):
|
|
||||||
p = patterns()
|
|
||||||
return filter(filter_words, p.split_pat.split(text))
|
|
||||||
|
|
||||||
def add_words(text, sourceline, words, file_name, locale):
|
def add_words(text, sourceline, words, file_name, locale):
|
||||||
candidates = get_words(text, locale.langcode)
|
candidates = get_words(text, locale.langcode)
|
||||||
|
@ -14,8 +14,6 @@ from calibre.utils.localization import lang_as_iso639_1
|
|||||||
_iterators = {}
|
_iterators = {}
|
||||||
_lock = Lock()
|
_lock = Lock()
|
||||||
|
|
||||||
has_break_iterator = hasattr(_icu, 'BreakIterator')
|
|
||||||
|
|
||||||
def split_into_words(text, lang='en'):
|
def split_into_words(text, lang='en'):
|
||||||
with _lock:
|
with _lock:
|
||||||
it = _iterators.get(lang, None)
|
it = _iterators.get(lang, None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user