Skip to content

Commit

Permalink
Add dict dumping
Browse files Browse the repository at this point in the history
  • Loading branch information
p-goulart committed Jan 31, 2024
1 parent e34ca7e commit e007a69
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/languagetool_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,15 @@ def build_synth_binary(self) -> None:
LOGGER.info(f"Done compiling {self.variant} synthesiser dictionary!")
self.variant.copy_synth_info()
self.variant.rename_synth_tag_files()

def dump_dictionary(self) -> None:
LOGGER.info(f"Dumping dictionary for {self.variant}...")
cmd_dump = (
f"java -cp {gd.DIRS.LT_JAR_PATH} "
f"org.languagetool.tools.DictionaryExporter "
f"-i {self.variant.pos_dict_java_output_path()} "
f"-info {self.variant.pos_info_java_input_path()} "
f"-o {self.variant.dump_dict_java_output_path()}"
)
ShellCommand(cmd_dump).run()
LOGGER.info(f"Done dumping {self.variant} dictionary!")
3 changes: 3 additions & 0 deletions lib/variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def rename_synth_tag_files(self) -> None:
def copy_spell_info(self) -> None:
return shutil.copy(self.info('source'), self.info('target'))

def dump_dict_java_output_path(self) -> str:
return path.join(gd.DIRS.LT_RESULTS_DIR, f"{self.pretty.lower()}.dump")


# Portuguese
PT_BR = Variant('pt-BR')
Expand Down
2 changes: 2 additions & 0 deletions scripts/build_tagger_dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def main():
lt.build_synth_binary()
if FORCE_INSTALL:
install_dictionaries(custom_version=CUSTOM_INSTALL_VERSION)
if LOGGER.level == 10: # DEBUG
lt.dump_dictionary()
end_time = datetime.now()
LOGGER.debug(f"Finished at {end_time.strftime('%r')}. "
f"Total time elapsed: {pretty_time_delta(end_time - start_time)}.")
Expand Down

0 comments on commit e007a69

Please sign in to comment.