diff --git a/README.md b/README.md index 95817a4..294a3b5 100644 --- a/README.md +++ b/README.md @@ -17,27 +17,19 @@ More detail can be found in [ Helsinki-NLP/Opus-MT ](https://github.com/Helsinki Use the pre-trained model 'opus-mt-en-zh' to generate the Chinese translation for the sentence "Hello, world.". -*Write the pipeline*: +*Write a pipeline with explicit inputs/outputs name specifications:* ```python -import towhee +from towhee.dc2 import pipe, ops, DataCollection -( - towhee.dc(["Hello, world."]) - .machine_translation.opus_mt(model_name="opus-mt-en-zh") +p = ( + pipe.input('text') + .map('text', 'translation', ops.machine_translation.opus_mt(model_name='opus-mt-en-zh')) + .output('text', 'translation') ) -``` - -*Write a same pipeline with explicit inputs/outputs name specifications:* -```python -import towhee +DataCollection(p('hello, world.')).show() -( - towhee.dc['text'](["Hello, world."]) - .machine_translation.opus_mt['text', 'vec'](model_name="opus-mt-en-zh") - .show() -) ``` @@ -48,7 +40,7 @@ import towhee Create the operator via the following factory method: -***machine_translatioin.opus_mt(model_name="opus-mt-en-zh")*** +***machine_translation.opus_mt(model_name="opus-mt-en-zh")*** **Parameters:** @@ -58,8 +50,12 @@ The model name in string. The default model name is "opus-mt-en-zh". Supported model names: - - opus-mt-en-zh + - opus-mt-en-zh - opus-mt-zh-en + - opus-tatoeba-en-ja + - opus-tatoeba-ja-en + - opus-mt-ru-en + - opus-mt-en-ru
diff --git a/opus_mt.py b/opus_mt.py index 5dd8847..e8e7249 100644 --- a/opus_mt.py +++ b/opus_mt.py @@ -64,4 +64,13 @@ class OpusMT(NNOperator): configs['opus-tatoeba-ja-en'] = {} configs['opus-tatoeba-ja-en']['tokenizer'] = 'Helsinki-NLP/opus-tatoeba-ja-en' configs['opus-tatoeba-ja-en']['model'] = 'Helsinki-NLP/opus-tatoeba-ja-en' + + configs['opus-mt-ru-en'] = {} + configs['opus-mt-ru-en']['tokenizer'] = 'Helsinki-NLP/opus-mt-ru-en' + configs['opus-mt-ru-en']['model'] = 'Helsinki-NLP/opus-mt-ru-en' + + configs['opus-mt-en-ru'] = {} + configs['opus-mt-en-ru']['tokenizer'] = 'Helsinki-NLP/opus-mt-en-ru' + configs['opus-mt-en-ru']['model'] = 'Helsinki-NLP/opus-mt-en-ru' + return configs diff --git a/result.png b/result.png index f4607fc..12513a5 100644 Binary files a/result.png and b/result.png differ