Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions python/ArgosTranslation/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# syntax=docker/dockerfile:1.2

#############################################################################
# NOTICE #
# #
# This software (or technical data) was produced for the U.S. Government #
# under contract, and is subject to the Rights in Data-General Clause #
# 52.227-14, Alt. IV (DEC 2007). #
# #
# Copyright 2023 The MITRE Corporation. All Rights Reserved. #
#############################################################################

#############################################################################
# Copyright 2023 The MITRE Corporation #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#############################################################################

ARG BUILD_REGISTRY
ARG BUILD_TAG=latest
FROM ${BUILD_REGISTRY}openmpf_python_executor_ssb:${BUILD_TAG}

RUN pip3 install --no-cache-dir 'argostranslate>=1.8.0'

RUN argospm update

# To download a language model use argospm install translate_<INPUT_ISO_LANG>_en
# Refer to README for list of supported languages
RUN argospm install translate-de_en && \
argospm install translate-fr_en && \
argospm install translate-ru_en && \
argospm install translate-zh_en && \
argospm install translate-es_en && \
argospm install translate-ar_en

ARG RUN_TESTS=false

RUN --mount=target=.,readwrite \
install-component.sh; \
if [ "${RUN_TESTS,,}" == true ]; then python tests/test_argos_translation.py; fi

LABEL org.label-schema.license="Apache 2.0" \
org.label-schema.name="OpenMPF Argos Translation" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://openmpf.github.io" \
org.label-schema.vcs-url="https://github.com/openmpf/openmpf-components" \
org.label-schema.vendor="MITRE"


31 changes: 31 additions & 0 deletions python/ArgosTranslation/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/******************************************************************************
* Copyright 2023 The MITRE Corporation *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
******************************************************************************/

This project contains content developed by The MITRE Corporation. If this code
is used in a deployment or embedded within another project, it is requested
that you send an email to opensource@mitre.org in order to let us know where
this software is being used.

This software makes use of source code and data files from third party software:

--------------------------------------------------------------------------

Argos Translate is licensed under the MIT License.
Copyright (c) 2020 Argos Open Technologies, LLC

Project Page: https://github.com/argosopentech/argos-translate

--------------------------------------------------------------------------
58 changes: 58 additions & 0 deletions python/ArgosTranslation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Overview

This repository contains source code for the OpenMPF Argos Translation Component.

This component translates the input text from a given source language to English. The source language can be provided as a job property, or be indicated in the detection properties from a feed-forward track.


# Job Properties
The below properties can be optionally provided to alter the behavior of the component.

- `FEED_FORWARD_PROP_TO_PROCESS`: Controls which properties of the feed-forward track or detection are considered for translation. This should be a comma-separated list of property names (default: `"TEXT,TRANSCRIPT"`). The first named property in the list that is present is translated. At most, one property will be translated.

- `LANGUAGE_FEED_FORWARD_PROP`: As above, a comma-separated list of property names (default: `"DECODED_LANGUAGE,LANGUAGE"`), which indicate which property of the feed-forward track or detection may be used to determine the source language of the text to be translated. This language is expected to be provided as an ISO 639-1 or and ISO 639-2 language code.

- `DEFAULT_SOURCE_LANGUAGE`: The default source language to use if none of the property names listed in `LANGUAGE_FEED_FORWARD_PROP` are present in a feed-forward track or detection. This language is used when running a generic job with a raw text file (hence no feed-forward tracks).


# Language Identifiers
The following are the ISO 639-1 codes, the ISO 639-2 codes, and their corresponding languages which Argos Translate version 1.7.0 can translate to English.

All translations are either to English or from English. When trying to translate from one non-English language to another, Argos will automatically pivot between languages using the currently installed packages. For example, for Spanish->French Argos would pivot from Spanish->English to English->French. This is associated with a drop in accuracy and increase in runtime.

Language packages are downloaded dynamically as needed. In addition, when building a Docker image the Dockerfile pre-installs German, French, Russian, and Spanish.

Note: Argos underperforms when translating to and from Chinese

| ISO-639-1 | ISO-639-2 | Language |
| --- |---|------------------|
| `ar` | `ara` | Arabic |
| `az` | `aze` | Azerbaijani |
| `zh` | `cmn` | Chinese |
| `cs` | `ces` | Czech |
| `da` | `dan` | Danish |
| `nl` | `nld` | Dutch |
| `eo` | `epo` | Esperanto |
| `fi` | `fin` | Finnish |
| `fr` | `fra` | French |
| `de` | `deu` | German |
| `el` | `ell` | Greek |
| `he` | `heb` | Hebrew |
| `hi` | `hin` | Hindi |
| `hu` | `hun` | Hungarian |
| `id` | `ind` | Indonesian |
| `ga` | `gle` | Irish |
| `it` | `ita` | Italian |
| `ja` | `jpn` | Japanese |
| `ko` | `kor` | Korean |
| `fa` | `fas` | Persian |
| `pl` | `pol` | Polish |
| `pt` | `por` | Portuguese |
| `ru` | `rus` | Russian |
| `sk` | `slk` | Slovak |
| `es` | `spa` | Spanish |
| `sv` | `swe` | Swedish |
| `tr` | `tur` | Turkish |
| `uk` | `ukr` | Ukrainian |


27 changes: 27 additions & 0 deletions python/ArgosTranslation/argos_translation_component/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#############################################################################
# NOTICE #
# #
# This software (or technical data) was produced for the U.S. Government #
# under contract, and is subject to the Rights in Data-General Clause #
# 52.227-14, Alt. IV (DEC 2007). #
# #
# Copyright 2022 The MITRE Corporation. All Rights Reserved. #
#############################################################################

#############################################################################
# Copyright 2022 The MITRE Corporation #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#############################################################################

from .argos_translation_component import ArgosTranslationComponent, TranslationWrapper
Loading