# 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
           percentage(stats['correct_root'], stats['recognized']))
          )
    print("="*50)


def percentage(a, b):
    return (a * 100.0 / b)


def process(sentences, tag_mapper, ws):
    inria_metrics = WordLevelMetrics("inria")
    sdata_metrics = WordLevelMetrics("sanskrit_data")
    comb_metrics = WordLevelMetrics("combined")

    stats = {'inria': (0, 0, 0), 'sdata': (0, 0, 0), 'combo': (0, 0, 0)}
    missing = []
    for sent in sentences:
        if sent is None:
            continue
        text_obj = SanskritObject(sent.text, encoding=IAST,
                                  strict_io=False)
        words = text_obj.canonical().strip().split(" ")
        if len(words) != len(sent.dcsAnalysisDecomposition):
            continue
        for w, analysis in zip(words, sent.dcsAnalysisDecomposition):
            if len(analysis) != 1:
                continue
            word_analysis = analysis[0]
            if word_analysis.dcsGrammarHint == []:
                continue

# 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

           percentage(stats['correct_root'], stats['recognized']))
          )
    print("="*50)


def percentage(a, b):
    return (a * 100.0 / b)


def process(sentences, tag_mapper, ws):
    inria_metrics = WordLevelMetrics("inria")
    sdata_metrics = WordLevelMetrics("sanskrit_data")
    comb_metrics = WordLevelMetrics("combined")

    stats = {'inria': (0, 0, 0), 'sdata': (0, 0, 0), 'combo': (0, 0, 0)}
    missing = []
    for sent in sentences:
        if sent is None:
            continue
        text_obj = SanskritObject(sent.text, encoding=IAST,
                                  strict_io=False)
        words = text_obj.canonical().strip().split(" ")
        if len(words) != len(sent.dcsAnalysisDecomposition):
            continue
        for w, analysis in zip(words, sent.dcsAnalysisDecomposition):
            if len(analysis) != 1:
                continue
            word_analysis = analysis[0]
            if word_analysis.dcsGrammarHint == []:
                continue

            word_slp = SanskritObject(w, encoding=IAST,