Skip to content

Commit

Permalink
Fix --use-mtpe
Browse files Browse the repository at this point in the history
  • Loading branch information
thatDudo committed Oct 23, 2023
1 parent 49d6aff commit a195189
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manga_translator/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _format_action_invocation(self, action: argparse.Action) -> str:
parser.add_argument('--no-hyphenation', action='store_true', help='If renderer should be splitting up words using a hyphen character (-)')
parser.add_argument('--manga2eng', action='store_true', help='Render english text translated from manga with some additional typesetting. Ignores some other argument options')
parser.add_argument('--gpt-config', type=file_path, help='Path to GPT config file, more info in README')
parser.add_argument('--mtpe', action='store_true', help='Turn on/off machine translation post editing (MTPE) on the command line (works only on linux right now)')
parser.add_argument('--use-mtpe', action='store_true', help='Turn on/off machine translation post editing (MTPE) on the command line (works only on linux right now)')

g = parser.add_mutually_exclusive_group()
g.add_argument('--save-text', action='store_true', help='Save extracted text and translations into a text file.')
Expand Down
4 changes: 2 additions & 2 deletions manga_translator/manga_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ async def translate_path(self, path: str, dest: str = None, params: dict = None)

file_path = os.path.join(root, f)
output_dest = replace_prefix(file_path, path, _dest)
p, _ = os.path.splitext(output_dest)
output_dest = f'{p}.{file_ext}'
p, ext = os.path.splitext(output_dest)
output_dest = f'{p}.{file_ext or ext[1:]}'

if await self.translate_file(file_path, output_dest, params):
translated_count += 1
Expand Down
5 changes: 3 additions & 2 deletions manga_translator/translators/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,14 @@ async def translate(self, from_lang: str, to_lang: str, queries: List[str], use_
import arabic_reshaper
translations = [arabic_reshaper.reshape(t) for t in translations]

if use_mtpe:
translations = await self.mtpe_adapter.dispatch(queries, translations)

# Merge with the queries without text
for i, trans in enumerate(translations):
final_translations[query_indices[i]] = trans
self.logger.info(f'{i}: {queries[i]} => {trans}')

if use_mtpe:
final_translations = await self.mtpe_adapter.dispatch(queries, final_translations)
return final_translations

@abstractmethod
Expand Down

0 comments on commit a195189

Please sign in to comment.