Skip to content

Commit

Permalink
Merge branch 'master' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
PJ-Finlay committed Aug 15, 2024
2 parents 635f4eb + 1a60301 commit 61e4733
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ Install [GUI](https://github.com/argosopentech/argos-translate-gui):
pip install argostranslategui
```

### Installation for macOS

1. Download the latest [macOS release.](https://github.com/argosopentech/argos-translate/releases/)
2. Extract the archive.
3. Copy the `.app` file to the Applications directory.

### Python source installation into virtualenv

Download a copy of this repo and install with pip.
Expand Down Expand Up @@ -112,7 +106,6 @@ The GUI code is in a [separate repository](https://github.com/argosopentech/argo

![Screenshot](/img/Screenshot.png)
![Screenshot2](/img/Screenshot2.png)
![Argos Translate macOS Screenshot](/img/ArgosTranslateMacOSScreenshot.png)


## [Packages](https://www.argosopentech.com/argospm/index/)
Expand Down
3 changes: 2 additions & 1 deletion argostranslate/apply_bpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,9 @@ def isolate_glossary(word, glossary):


if __name__ == "__main__":

currentdir = os.path.dirname(
os.path.abspath(inspect.getfile(inspect.currentframe())) # type: ignore
os.path.abspath(inspect.getfile(inspect.currentframe()))
)
newdir = os.path.join(currentdir, "subword_nmt")
if os.path.isdir(newdir):
Expand Down
24 changes: 24 additions & 0 deletions argostranslate/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,27 @@ def uninstall(pkg):
with package_lock:
info("Uninstalled package", pkg)
shutil.rmtree(pkg.package_path)

def install_package_for_language_pair(from_code: str, to_code: str) -> bool:
"""Installs the necessary package to translate between a pair of languages
Args:
from_code (str): The ISO 639 code for the language being translated from
to_code (str): The ISO 639 code for the language being translated to
Returns:
True if the package was installed successfully,
False if the installation failed or was not possible
"""
available_packages = get_available_packages()
try:
package_to_install = next(
filter(
lambda x: x.from_code == from_code and x.to_code == to_code,
available_packages,
)
)
except StopIteration:
return False

install_from_path(package_to_install.download())
return True

8 changes: 8 additions & 0 deletions argostranslate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
std_out_stream_handler = logging.StreamHandler(sys.stdout)
logger.addHandler(std_out_stream_handler)

# Python Logging Levels:
# https://docs.python.org/3/library/logging.html#levels


def debug(*argv):
"""Debug level log"""
logger.debug(str(argv))


def get_json_string(argv):
if len(argv) == 1:
Expand Down

0 comments on commit 61e4733

Please sign in to comment.