# Path: sanskrit_parser/base/sanskrit_base.py
# class SanskritObject(SanskritNormalizedString):
#     """ Sanskrit Object Class: Derived From SanskritString
# 
#         Attributes:
# 
#     """
#     def __init__(self, thing=None, encoding=None, unicode_encoding='utf-8',
#                  strict_io=True, replace_ending_visarga='s'):
#         super().__init__(thing, encoding, unicode_encoding, strict_io, replace_ending_visarga)
#         # Tags will go here as
#         self.tags = []
# 
#     def setMorphologicalTags(self, t):
#         """ Set Morphological Tags on Sanskrit Object
# 
#             Params:
#                t (list): List of morphological tags
#         """
#         self.tags.extend(t)
#         return self.tags
# 
#     def getMorphologicalTags(self):
#         """ Morphological Tags on object """
#         return self.tags


import logging
import os
import codecs
from tinydb import TinyDB
from sanskrit_parser.base.sanskrit_base import SanskritObject
'''
Convert dhAtu-pATha-kRShNAchArya.tsv to json

'''

from __future__ import print_function




logger = logging.getLogger(__name__)
logging.basicConfig(
    level=logging.INFO,
    format="%(levelname)s: {%(filename)s:%(lineno)d}: %(message)s "
)


def generate_db(tsv_file, db_file):
        """ Create db from tsv file """
        logger.info("Converting tsv %s to db file %s", tsv_file, db_file)
        if os.path.exists(db_file):
            os.remove(db_file)
        db = TinyDB(db_file)
        with codecs.open(tsv_file, "rb", encoding="utf-8") as f:
            row = f.readline().split("\t")
            headers = [SanskritObject(x).canonical() for x in row[0:8]]
            logger.info("Found dhatu tsv headers: {}".format(str(headers)))
            # FIXME - Rewrite from here
            for row in f:
                entries = row.split("\t")[:len(headers)]

# Path: sanskrit_parser/base/sanskrit_base.py
# class SanskritObject(SanskritNormalizedString):
#     """ Sanskrit Object Class: Derived From SanskritString
# 
#         Attributes:
# 
#     """
#     def __init__(self, thing=None, encoding=None, unicode_encoding='utf-8',
#                  strict_io=True, replace_ending_visarga='s'):
#         super().__init__(thing, encoding, unicode_encoding, strict_io, replace_ending_visarga)
#         # Tags will go here as
#         self.tags = []
# 
#     def setMorphologicalTags(self, t):
#         """ Set Morphological Tags on Sanskrit Object
# 
#             Params:
#                t (list): List of morphological tags
#         """
#         self.tags.extend(t)
#         return self.tags
# 
#     def getMorphologicalTags(self):
#         """ Morphological Tags on object """
#         return self.tags


# Path: data/convert_dhAtu_pATha.py
import logging
import os
import codecs
from tinydb import TinyDB
from sanskrit_parser.base.sanskrit_base import SanskritObject

'''
Convert dhAtu-pATha-kRShNAchArya.tsv to json

'''

from __future__ import print_function




logger = logging.getLogger(__name__)
logging.basicConfig(
    level=logging.INFO,
    format="%(levelname)s: {%(filename)s:%(lineno)d}: %(message)s "
)


def generate_db(tsv_file, db_file):
        """ Create db from tsv file """
        logger.info("Converting tsv %s to db file %s", tsv_file, db_file)
        if os.path.exists(db_file):
            os.remove(db_file)
        db = TinyDB(db_file)
        with codecs.open(tsv_file, "rb", encoding="utf-8") as f:
            row = f.readline().split("\t")
            headers = [SanskritObject(x).canonical() for x in row[0:8]]
            logger.info("Found dhatu tsv headers: {}".format(str(headers)))
            # FIXME - Rewrite from here
            for row in f:
                entries = row.split("\t")[:len(headers)]

                entries = [SanskritObject(e).canonical() for e in entries]