def __init__(self, language = 'en_US', lmin = 2, rmin = 2, compound_lmin = 2, compound_rmin = 2, directory = ''): ''' Return a hyphenator object initialized with a dictionary for the specified language, typically a locale name. Example: 'en_NZ' for English / New Zealand Each class instance has an attribute 'info' of type dict containing metadata on its dictionary including its local file path. If the module-level attribute dict_info does not contain an item for this dictionary, the info attribute of the Hyphenator instance is None. In this case the 'directory' argument must be set to the local path of the hyphenation dictionary. There is also a 'language' attribute of type str which is deprecated since v1.0b1. lmin, rmin, compound_lmin and compound_rmin: set minimum number of chars to be cut off by hyphenation in single or compound words ''' if language in dict_info: file_path = dict_info[language].filepath else: file_path = '/'.join((directory, '/', 'hyph_' + language + '.dic')) self.__hyphenate__ = hnj.hyphenator_(file_path, lmin, rmin, compound_lmin, compound_rmin) self.language = language if language in dict_info: self.info = dict_info[language] else: self.info = None
def __init__(self, language = 'en_US', lmin = 2, rmin = 2, compound_lmin = 2, compound_rmin = 2, directory = config.default_dic_path): """ Return a hyphenator object initialized with a dictionary for the specified language. 'language' should by convention be a string of length 5 of the form "ll_CC" where ll is the language code and CC the country code. This is inspired by the file names of OpenOffice's hyphenation dictionaries. Example: 'en_NZ' for English / New Zealand Each class instance has a member 'language' showing the language of its dictionary. lmin, compound_lmin and friends set the minimum number of characters cut off at the beginning or end of the entire word or compound parts thereof. """ file_path = ''.join((directory, '/hyph_', language, '.dic')) self.__hyphenate__ = hnj.hyphenator_(file_path, lmin, rmin, compound_lmin, compound_rmin) self.language = language
def __init__(self, language='en_US', lmin=2, rmin=2, compound_lmin=2, compound_rmin=2, directory=''): ''' Return a hyphenator object initialized with a dictionary for the specified language, typically a locale name. Example: 'en_NZ' for English / New Zealand Each class instance has an attribute 'info' of type dict containing metadata on its dictionary including its local file path. If the module-level attribute dict_info does not contain an item for this dictionary, the info attribute of the Hyphenator instance is None. In this case the 'directory' argument must be set to the local path of the hyphenation dictionary. There is also a 'language' attribute of type str which is deprecated since v1.0b1. lmin, rmin, compound_lmin and compound_rmin: set minimum number of chars to be cut off by hyphenation in single or compound words ''' if language in dict_info: file_path = dict_info[language].filepath else: file_path = '/'.join((directory, '/', 'hyph_' + language + '.dic')) self.__hyphenate__ = hnj.hyphenator_(file_path, lmin, rmin, compound_lmin, compound_rmin) self.language = language if language in dict_info: self.info = dict_info[language] else: self.info = None