# Path: sanskrit_parser/util/lexical_lookup_factory.py
# class LexicalLookupFactory(object):
# 
#     @staticmethod
#     def create(name):
#         if name == "inria":
#             return InriaXMLWrapper()
#         if name == "sanskrit_data":
#             return SanskritDataWrapper()
#         if name == "combined":
#             return CombinedWrapper()
#         raise Exception("invalid type", name)
# 
# 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
# 
# IAST = sanscript.IAST


import os
import time
import logging
import itertools
import argparse
import progressbar
from openpyxl import Workbook
from dcs_wrapper import DCS
from dcs_wrapper import DCSTagMapper
from sanskrit_parser.util.lexical_lookup_factory import LexicalLookupFactory
from sanskrit_parser.base.sanskrit_base import SanskritObject, IAST
from joblib import Parallel, delayed
            tag_list = self.lookup.get_tags(word)
            correct_root = False
            for (stem, tag_set) in tag_list:
                if(stem.split("#")[0]) == ref_root:
                    correct_root = True
                    break
            if correct_root:
                self.correct_root += 1
            else:
                logger.info("%s: Incorrect root for %s (ref = %s). Got %s",
                            self.name, word, ref_root, tag_list)
        self.count += 1
        return valid

    def metrics(self):
        return self.count, self.recognized, self.correct_root


def print_stats(lookup_scheme, stats):
    print("-"*50)
    print("Metrics for", lookup_scheme)
    print("-"*50)
    print("Recognized %d / %d words, accuracy = %.2f%%" %
          (stats['recognized'], stats['count'],
           percentage(stats['recognized'], stats['count']))
          )
    print("Correct root for %d / %d recognized words, accuracy = %.2f%%" %
          (stats['correct_root'], stats['recognized'],
           percentage(stats['correct_root'], stats['recognized']))
          )

# Path: sanskrit_parser/util/lexical_lookup_factory.py
# class LexicalLookupFactory(object):
# 
#     @staticmethod
#     def create(name):
#         if name == "inria":
#             return InriaXMLWrapper()
#         if name == "sanskrit_data":
#             return SanskritDataWrapper()
#         if name == "combined":
#             return CombinedWrapper()
#         raise Exception("invalid type", name)
# 
# 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
# 
# IAST = sanscript.IAST


# Path: metrics/word_accuracy_metrics.py
import os
import time
import logging
import itertools
import argparse
import progressbar
from openpyxl import Workbook
from dcs_wrapper import DCS
from dcs_wrapper import DCSTagMapper
from sanskrit_parser.util.lexical_lookup_factory import LexicalLookupFactory
from sanskrit_parser.base.sanskrit_base import SanskritObject, IAST
from joblib import Parallel, delayed

            tag_list = self.lookup.get_tags(word)
            correct_root = False
            for (stem, tag_set) in tag_list:
                if(stem.split("#")[0]) == ref_root:
                    correct_root = True
                    break
            if correct_root:
                self.correct_root += 1
            else:
                logger.info("%s: Incorrect root for %s (ref = %s). Got %s",
                            self.name, word, ref_root, tag_list)
        self.count += 1
        return valid

    def metrics(self):
        return self.count, self.recognized, self.correct_root


def print_stats(lookup_scheme, stats):
    print("-"*50)
    print("Metrics for", lookup_scheme)
    print("-"*50)
    print("Recognized %d / %d words, accuracy = %.2f%%" %
          (stats['recognized'], stats['count'],
           percentage(stats['recognized'], stats['count']))
          )
    print("Correct root for %d / %d recognized words, accuracy = %.2f%%" %
          (stats['correct_root'], stats['recognized'],
           percentage(stats['correct_root'], stats['recognized']))
          )

    print("="*50)