# 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 sys
import logging
    import sentencepiece as spm
    import gensim
from sanskrit_parser.util.data_manager import data_file_path
    from argparse import ArgumentParser
passed through sentencepiece first to handle possibly unseen words

Requires sentencepiece to be installed

@author: avinashvarna
'''



try:
    gensim_enabled = True
except ImportError:
    msg = 'gensim and/or sentencepiece not found. '
    msg += 'Lexical scoring will be disabled\n'
    msg += 'To enable scoring please install gensim and sentencepiece'
    logging.warning(msg)
    gensim_enabled = False


class Scorer(object):

    sentencepiece_file = "sentencepiece.model"
    word2vec_file = "word2vec_model.dat"

    def __init__(self):
        self.logger = logging.getLogger(__name__)
        if gensim_enabled:
            self.sentencepiece_file = data_file_path(self.sentencepiece_file)
            self.sp = spm.SentencePieceProcessor()
            self.sp.Load(self.sentencepiece_file)

# 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/util/lexical_scorer.py
import sys
import logging
    import sentencepiece as spm
    import gensim
from sanskrit_parser.util.data_manager import data_file_path
    from argparse import ArgumentParser

passed through sentencepiece first to handle possibly unseen words

Requires sentencepiece to be installed

@author: avinashvarna
'''



try:
    gensim_enabled = True
except ImportError:
    msg = 'gensim and/or sentencepiece not found. '
    msg += 'Lexical scoring will be disabled\n'
    msg += 'To enable scoring please install gensim and sentencepiece'
    logging.warning(msg)
    gensim_enabled = False


class Scorer(object):

    sentencepiece_file = "sentencepiece.model"
    word2vec_file = "word2vec_model.dat"

    def __init__(self):
        self.logger = logging.getLogger(__name__)
        if gensim_enabled:
            self.sentencepiece_file = data_file_path(self.sentencepiece_file)
            self.sp = spm.SentencePieceProcessor()
            self.sp.Load(self.sentencepiece_file)

            self.word2vec_file = data_file_path(self.word2vec_file)