# Path: sanskrit_parser/base/sanskrit_base.py
# class SanskritNormalizedString(SanskritString):
#     """ SanskritString plus Normalization of input
#     """
#     def __init__(self, thing=None, encoding=None, unicode_encoding='utf-8',
#                  strict_io=True, replace_ending_visarga='s'):
#         super().__init__(thing, encoding, unicode_encoding)
#         if not strict_io:
#             # Normalize
#             logger.debug("Before normalization: %s", self.thing)
#             tmp = normalization.normalize(self.thing)
#             if replace_ending_visarga == 's':
#                 self.thing = normalization.replace_ending_visarga_s(tmp)
#             elif replace_ending_visarga == 'r':
#                 self.thing = normalization.replace_ending_visarga_r(tmp)
#             else:
#                 self.thing = tmp
#             # Lazy Anusvaras (see issue #103)
#             try:
#                 self.thing = sanscript.SCHEMES[sanscript.SLP1].fix_lazy_anusvaara(self.thing)
#             except (NameError, AttributeError):
#                 print("Not fixing lazy anusvaras, you probably have an older version of indic_transliteration")
#             logger.debug("After normalization: %s", self.thing)
# 
# SCHEMES = {
#     'Bengali': BENGALI,
#     'Devanagari': DEVANAGARI,
#     'Gujarati': GUJARATI,
#     'Gurmukhi': GURMUKHI,
#     'Kannada': KANNADA,
#     'Malayalam': MALAYALAM,
#     'Oriya': ORIYA,
#     'Tamil': TAMIL,
#     'Telugu': TELUGU,
#     'HK': HK,
#     'IAST': IAST,
#     'ITRANS': ITRANS,
#     'Kolkata': KOLKATA,
#     'SLP1': SLP1,
#     'Velthuis': VELTHUIS,
#     'WX': WX
# }
# 
# @contextmanager
# def outputctx(strict_io):
#     global denormalize
#     save_denormalize = denormalize
#     denormalize = not strict_io
#     yield
#     denormalize = save_denormalize
# 
# Path: sanskrit_parser/util/data_manager.py
# def data_file_path(filename):
#     file_manager = ExitStack()
#     atexit.register(file_manager.close)
#     ref = importlib_resources.files('sanskrit_parser') / 'data' / filename
#     path = file_manager.enter_context(
#         importlib_resources.as_file(ref))
#     return str(path)


import itertools
import pickle
import logging
import datetime
from zipfile import ZipFile
from sanskrit_parser.base.sanskrit_base import SanskritNormalizedString, SCHEMES, outputctx
from sanskrit_parser.util.data_manager import data_file_path
    from argparse import ArgumentParser
            ie = SCHEMES[args.input_encoding]

        # Setup logging
        if args.loglevel:
            numeric_level = getattr(logging, args.loglevel.upper(), None)
            if not isinstance(numeric_level, int):
                raise ValueError('Invalid log level: %s' % args.loglevel)
            logging.basicConfig(filename="sandhi.log", filemode="wb", level=numeric_level)

        logging.info("---------------------------------------------------")
        logging.info("Started processing at %s", datetime.datetime.now())

        sandhi = Sandhi()
        # if neither split nor join is chosen, just demo both
        if not args.split and not args.join:
            print("Neither split nor join option chosen. Here's a demo of joining")
            args.join = True
        with outputctx(args.strict_io):
            if args.split:
                word_in = SanskritNormalizedString(args.word, encoding=ie, strict_io=args.strict_io)
                if args.all:
                    print("All possible splits for {}".format(args.word))
                    splits = sandhi.split_all(word_in)
                else:
                    pos = int(args.word_or_pos)
                    print("Splitting {0} at {1}".format(args.word, pos))
                    splits = sandhi.split_at(word_in, pos)
                print(splits)
            if args.join:
                print("Joining {0} {1}".format(args.word, args.word_or_pos))

# Path: sanskrit_parser/base/sanskrit_base.py
# class SanskritNormalizedString(SanskritString):
#     """ SanskritString plus Normalization of input
#     """
#     def __init__(self, thing=None, encoding=None, unicode_encoding='utf-8',
#                  strict_io=True, replace_ending_visarga='s'):
#         super().__init__(thing, encoding, unicode_encoding)
#         if not strict_io:
#             # Normalize
#             logger.debug("Before normalization: %s", self.thing)
#             tmp = normalization.normalize(self.thing)
#             if replace_ending_visarga == 's':
#                 self.thing = normalization.replace_ending_visarga_s(tmp)
#             elif replace_ending_visarga == 'r':
#                 self.thing = normalization.replace_ending_visarga_r(tmp)
#             else:
#                 self.thing = tmp
#             # Lazy Anusvaras (see issue #103)
#             try:
#                 self.thing = sanscript.SCHEMES[sanscript.SLP1].fix_lazy_anusvaara(self.thing)
#             except (NameError, AttributeError):
#                 print("Not fixing lazy anusvaras, you probably have an older version of indic_transliteration")
#             logger.debug("After normalization: %s", self.thing)
# 
# SCHEMES = {
#     'Bengali': BENGALI,
#     'Devanagari': DEVANAGARI,
#     'Gujarati': GUJARATI,
#     'Gurmukhi': GURMUKHI,
#     'Kannada': KANNADA,
#     'Malayalam': MALAYALAM,
#     'Oriya': ORIYA,
#     'Tamil': TAMIL,
#     'Telugu': TELUGU,
#     'HK': HK,
#     'IAST': IAST,
#     'ITRANS': ITRANS,
#     'Kolkata': KOLKATA,
#     'SLP1': SLP1,
#     'Velthuis': VELTHUIS,
#     'WX': WX
# }
# 
# @contextmanager
# def outputctx(strict_io):
#     global denormalize
#     save_denormalize = denormalize
#     denormalize = not strict_io
#     yield
#     denormalize = save_denormalize
# 
# Path: sanskrit_parser/util/data_manager.py
# def data_file_path(filename):
#     file_manager = ExitStack()
#     atexit.register(file_manager.close)
#     ref = importlib_resources.files('sanskrit_parser') / 'data' / filename
#     path = file_manager.enter_context(
#         importlib_resources.as_file(ref))
#     return str(path)


# Path: sanskrit_parser/parser/sandhi.py
import itertools
import pickle
import logging
import datetime
from zipfile import ZipFile
from sanskrit_parser.base.sanskrit_base import SanskritNormalizedString, SCHEMES, outputctx
from sanskrit_parser.util.data_manager import data_file_path
    from argparse import ArgumentParser

            ie = SCHEMES[args.input_encoding]

        # Setup logging
        if args.loglevel:
            numeric_level = getattr(logging, args.loglevel.upper(), None)
            if not isinstance(numeric_level, int):
                raise ValueError('Invalid log level: %s' % args.loglevel)
            logging.basicConfig(filename="sandhi.log", filemode="wb", level=numeric_level)

        logging.info("---------------------------------------------------")
        logging.info("Started processing at %s", datetime.datetime.now())

        sandhi = Sandhi()
        # if neither split nor join is chosen, just demo both
        if not args.split and not args.join:
            print("Neither split nor join option chosen. Here's a demo of joining")
            args.join = True
        with outputctx(args.strict_io):
            if args.split:
                word_in = SanskritNormalizedString(args.word, encoding=ie, strict_io=args.strict_io)
                if args.all:
                    print("All possible splits for {}".format(args.word))
                    splits = sandhi.split_all(word_in)
                else:
                    pos = int(args.word_or_pos)
                    print("Splitting {0} at {1}".format(args.word, pos))
                    splits = sandhi.split_at(word_in, pos)
                print(splits)
            if args.join:
                print("Joining {0} {1}".format(args.word, args.word_or_pos))

                first_in = SanskritNormalizedString(args.word, encoding=ie, strict_io=args.strict_io)