romanizer.py 750 B

123456789101112131415161718192021222324252627282930
  1. # @package ext
  2. __doc__ = """
  3. Transliterate a number of Indian and other Asian scripts using Aksharamukha:
  4. https://github.com/virtualvinodh/aksharamukha-python """
  5. from logging import getLogger
  6. from aksharamukha.transliterate import process
  7. from scriptshifter.exceptions import BREAK
  8. logger = getLogger(__name__)
  9. def s2r_post_config(ctx, src_script):
  10. # options = detect_preoptions(ctx.src, src_script)
  11. options = [n for n, v in ctx.options.items() if v and n != "capitalize"]
  12. logger.info(f"Options for {src_script}: {options}")
  13. ctx.dest = process(src_script, "IAST", ctx.src, pre_options=options)
  14. return BREAK
  15. def r2s_post_config(ctx, dest_script):
  16. ctx.dest = process("IAST", dest_script, ctx.src)
  17. return BREAK