Skip to content

Commit

Permalink
Also dump synth dict with debug
Browse files Browse the repository at this point in the history
  • Loading branch information
p-goulart committed Mar 26, 2024
1 parent 0ad40a0 commit cac9d60
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
18 changes: 15 additions & 3 deletions lib/languagetool_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,26 @@ def build_synth_binary(self) -> None:
self.variant.copy_synth_info()
self.variant.rename_synth_tag_files()

def dump_dictionary(self) -> None:
def dump_pos_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()}"
f"-o {self.variant.pos_dump_dict_java_output_path()}"
)
ShellCommand(cmd_dump).run_with_output()
LOGGER.info(f"Done dumping {self.variant} dictionary!")
LOGGER.info(f"Done dumping {self.variant} POS dictionary!")

def dump_synth_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.synth_dict_java_output_path()} "
f"-info {self.variant.synth_info_java_input_path()} "
f"-o {self.variant.synth_dump_dict_java_output_path()}"
)
ShellCommand(cmd_dump).run_with_output()
LOGGER.info(f"Done dumping {self.variant} synth dictionary!")
5 changes: 4 additions & 1 deletion lib/variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,12 @@ 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:
def pos_dump_dict_java_output_path(self) -> str:
return path.join(gd.DIRS.LT_RESULTS_DIR, f"{self.pretty.lower()}.dump")

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


# Portuguese
PT_BR = Variant('pt-BR')
Expand Down
3 changes: 2 additions & 1 deletion scripts/build_tagger_dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def main():
custom_version: tuple[str, str] = (custom_install_env_var_name, CUSTOM_INSTALL_VERSION)
install_dictionaries(custom_version)
if LOGGER.level == 10: # DEBUG
lt.dump_dictionary()
lt.dump_pos_dictionary()
lt.dump_synth_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 cac9d60

Please sign in to comment.