Skip to content

Commit

Permalink
Sundry fixes
Browse files Browse the repository at this point in the history
 - custom install version env var must be formed from language;

 - frequency info added to POS dict compilation.
  • Loading branch information
p-goulart committed Feb 2, 2024
1 parent e007a69 commit 0083920
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/languagetool_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def build_pos_binary(self) -> None:
f"org.languagetool.tools.POSDictionaryBuilder "
f"-i {gd.DIRS.RESULT_POS_DICT_FILEPATH} "
f"-info {self.variant.pos_info_java_input_path()} "
f"-freq {self.variant.freq()} "
f"-o {self.variant.pos_dict_java_output_path()}"
)
ShellCommand(cmd_build).run()
Expand Down
6 changes: 3 additions & 3 deletions lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def compile_lt():
ShellCommand("mvn clean install -DskipTests", cwd=gd.DIRS.LT_DIR).run()


def install_dictionaries(custom_version: Optional[str]):
def install_dictionaries(custom_version: Optional[tuple[str, str]]):
"""Install our dictionaries to the local ~/.m2."""
LOGGER.info("Installing dictionaries...")
env: dict = {}
if custom_version is not None:
LOGGER.info(f"Installing custom version \"{custom_version}\"")
env['PT_DICT_VERSION'] = custom_version
LOGGER.info(f"Installing custom version \"{custom_version[1]}\"")
env[custom_version[0]] = custom_version[1]
else:
LOGGER.info(f"Installing environment-defined version \"{env['PT_DICT_VERSION']}\"")
ShellCommand("mvn clean install", env=env, cwd=gd.DIRS.JAVA_RESULTS_DIR).run()
Expand Down
6 changes: 5 additions & 1 deletion lib/variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ def compounds(self) -> str:
return path.join(gd.DIRS.COMPOUNDS_DIR, f"{self.underscored}.dic")

def freq(self) -> str:
return path.join(gd.DIRS.SPELLING_DICT_DIR, f"{self.lang}_{self.country}_wordlist.xml")
if self.country:
filename = f"{self.lang}_{self.country}_wordlist.xml"
else:
filename = f"{self.lang}_wordlist.xml"
return path.join(gd.DIRS.SPELLING_DICT_DIR, filename)

def java_output_dir(self) -> str:
return path.join(gd.DIRS.JAVA_RESULTS_DIR, "src/main/resources/org/languagetool/resource", self.lang)
Expand Down
4 changes: 3 additions & 1 deletion scripts/build_tagger_dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def main():
lt.build_pos_binary()
lt.build_synth_binary()
if FORCE_INSTALL:
install_dictionaries(custom_version=CUSTOM_INSTALL_VERSION)
custom_install_env_var_name = LANGUAGE.lang.upper() + "_DICT_VERSION"
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()
end_time = datetime.now()
Expand Down

0 comments on commit 0083920

Please sign in to comment.