Skip to content

Commit

Permalink
rename "build_options" to "compile_options"
Browse files Browse the repository at this point in the history
  • Loading branch information
kmike committed Jan 25, 2015
1 parent d71435c commit bb7c1c2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions pymorphy2/opencorpora_dict/compile.py
Expand Up @@ -26,14 +26,14 @@

CompiledDictionary = collections.namedtuple(
'CompiledDictionary',
'gramtab suffixes paradigms words_dawg prediction_suffixes_dawgs parsed_dict build_options'
'gramtab suffixes paradigms words_dawg prediction_suffixes_dawgs parsed_dict compile_options'
)

_pick_second = operator.itemgetter(1)


def convert_to_pymorphy2(opencorpora_dict_path, out_path, source_name,
overwrite=False, build_options=None):
overwrite=False, compile_options=None):
"""
Convert a dictionary from OpenCorpora XML format to
Pymorphy2 compacted format.
Expand All @@ -50,11 +50,11 @@ def convert_to_pymorphy2(opencorpora_dict_path, out_path, source_name,

parsed_dict = parse_opencorpora_xml(opencorpora_dict_path)
simplify_tags(parsed_dict)
compiled_dict = compile_parsed_dict(parsed_dict, build_options)
compiled_dict = compile_parsed_dict(parsed_dict, compile_options)
save_compiled_dict(compiled_dict, out_path, source_name=source_name)


def compile_parsed_dict(parsed_dict, build_options=None):
def compile_parsed_dict(parsed_dict, compile_options=None):
"""
Return compacted dictionary data.
"""
Expand All @@ -64,7 +64,7 @@ def compile_parsed_dict(parsed_dict, build_options=None):
max_suffix_length=5,
paradigm_prefixes=PARADIGM_PREFIXES,
)
options.update(build_options or {})
options.update(compile_options or {})
paradigm_prefixes = options["paradigm_prefixes"]

gramtab = []
Expand Down Expand Up @@ -170,7 +170,7 @@ def fix_strings(paradigm):
words_dawg=words_dawg,
prediction_suffixes_dawgs=prediction_suffixes_dawgs,
parsed_dict=parsed_dict,
build_options=options,
compile_options=options,
)


Expand Down
2 changes: 1 addition & 1 deletion pymorphy2/opencorpora_dict/storage.py
Expand Up @@ -145,7 +145,7 @@ def _dawg_len(dawg):
['suffixes_length', len(compiled_dict.suffixes)],

['words_dawg_length', words_dawg_len],
['build_options', compiled_dict.build_options],
['compile_options', compiled_dict.compile_options],
['prediction_suffixes_dawg_lengths', prediction_suffixes_dawg_lenghts],
['prediction_prefixes_dawg_length', len(PREDICTION_PREFIXES)],
])
Expand Down
2 changes: 1 addition & 1 deletion pymorphy2/units/by_analogy.py
Expand Up @@ -169,7 +169,7 @@ def init(self, morph):

def _max_suffix_length(self):
try:
return self.dict.meta['build_options']['max_suffix_length']
return self.dict.meta['compile_options']['max_suffix_length']
except KeyError:
# dicts v2.4 support
return self.dict.meta['prediction_options']['max_suffix_length']
Expand Down
2 changes: 1 addition & 1 deletion tests/test_opencorpora_dict.py
Expand Up @@ -56,7 +56,7 @@ def test_convert_to_pymorphy2(self, tmpdir):
'min_ending_freq': 0,
}
convert_to_pymorphy2(self.XML_PATH, out_path, overwrite=True,
build_options=options, source_name='toy')
compile_options=options, source_name='toy')

# use it
morph = pymorphy2.MorphAnalyzer(out_path)
Expand Down

0 comments on commit bb7c1c2

Please sign in to comment.