#########################################################
"""
RegexSemI_TSBplayer.py - regular expression based TSBplayer SemI decoder
=========================================================================


HELPFUL: http://regexr.com

"""

import RegexSemI
import re, os
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.sys.path.insert(0, parentdir)
import ContextLogger
logger = ContextLogger.getLogger('')
import DomainUtils
import Settings


class RegexSemI_TSBplayer(RegexSemI.RegexParser):
    """
    """
    def __init__(self, repoIn=None):
        RegexSemI.RegexParser.__init__(
            self, repoIn
        )  #better than super() here - wont need to be changed for other domains
        self.domainTag = "TSBplayer"  #FIXME
        self.create_domain_dependent_regex()

    def create_domain_dependent_regex(self):
.. warning::
        Documentation not done.


************************

'''

import copy

import Policy
import DMUtils
import SummaryMapping
import Settings
import ContextLogger
logger = ContextLogger.getLogger(__name__)

MAX_NUM_ACCEPTED = 10


"""
Notes on proposed changes:
    this module only needs the list of system_requestable slots 
    - perhaps rather than passing a whole instance of DomainUtils.DomainUtils() - we could just pass the list ?

"""


class HDCPolicy(Policy.Policy):
    """Handcrafted policy overrides Policy base class.
    import :class:`DiaAct` |.|
    import :class:`DomainUtils` |.|
    import :class:`Settings` |.|
    import :class:`ContextLogger`

************************

''' 
__author__='donghokim, davidvandyke'
import copy

import Settings
import DiaAct
import DomainUtils
import ContextLogger
logger = ContextLogger.getLogger('')


class EMConfusionModel(object):
    '''Base class for EMRandomConfusionModel. 

        .. Note:: 
            Used through derived class only. 
    '''
    def create_wrong_hyp(self, a_u):
        '''Create a wrong hypothesis for a_u

        :param a_u: (instance) of :class:`DiaAct`
        :returns: (instance) of :class:`DiaAct` - modified input act
        '''
        confact_is_same = True
import numpy as np
import random
import math
import copy
from collections import deque
from collections import OrderedDict
from scipy import linalg, mat, dot

import GPPolicy
import DMUtils
import DomainUtils
import Policy
import SummaryAction
import Settings
import ContextLogger
logger = ContextLogger.getLogger(__name__)

import itertools

class DataPoint(object):
    def __init__(self, b, a):
        self.b = b  # belief point
        self.a = a  # action

    def __eq__(self, other):
        return (self.b  == other.b  and
                self.a  == other.a)

class DataPointValue(object):
    def __init__(self, Q, N):
        self.Q = Q  # Q value
'''

__author__="donghokim, davidvandyke"

from collections import defaultdict
import math
import pprint
import copy

import Settings
import SummaryMapping
import dact
import agentutils
import ContextLogger
from practical1_dst.scripts import baseline   #module in belieftracking dir that actually implements the Baseline and Focus trackers (DSTC names)
logger = ContextLogger.getLogger(__name__)  #'belieftracking.BeliefTracker') 


class BeliefTracker(object):
    '''Belief Tracker base class that implements most of the functionality within the dialogue system. The actual inference
    problem of belief tracking (ASR/SLU --> belief state update) is implemented by individual trackers in baseline.py. 
    Hence this class will never be instantiated, it just implements common functionality.'''
    def __init__(self, domainUtil):
        self.prevbelief = None
        self.informedVenueSinceNone = None
        self.turn = 0
        self.domainUtil = domainUtil
        self.CONDITIONAL_BELIEF_PROB = 0.8 # give 0.8 prob mass to slot-vals that occured in prev domains. #TODO config? 

    def str(self):
        return pprint.pformat(agentutils.simplify_belief(self.domainUtil.ontology, self.prevbelief))
.. warning::
        Documentation not done.

************************

"""

__author__ = "milicagasic"

import SummaryMapping
import Settings
import DMUtils
import ContextLogger

logger = ContextLogger.getLogger("")

MAX_NUM_ACCEPTED = 10


class SummaryAction:
    """
    :param domainUtil: (instance) of :class:`DomainUtils.DomainUtils`
    """

    def __init__(self, domainUtil):
        self.domainUtil = domainUtil
        self.action_names = []
        for slot in self.domainUtil.ontology["system_requestable"]:
            self.action_names.append("request_" + slot)
            self.action_names.append("confirm_" + slot)
__author__ = "donghokim, davidvandyke"

from collections import defaultdict
import math
import pprint
import copy

import Settings
import SummaryMapping
import dact
import agentutils
import ContextLogger
from practical1_dst.scripts import baseline  #module in belieftracking dir that actually implements the Baseline and Focus trackers (DSTC names)

logger = ContextLogger.getLogger(__name__)  #'belieftracking.BeliefTracker')


class BeliefTracker(object):
    '''Belief Tracker base class that implements most of the functionality within the dialogue system. The actual inference
    problem of belief tracking (ASR/SLU --> belief state update) is implemented by individual trackers in baseline.py. 
    Hence this class will never be instantiated, it just implements common functionality.'''
    def __init__(self, domainUtil):
        self.prevbelief = None
        self.informedVenueSinceNone = None
        self.turn = 0
        self.domainUtil = domainUtil
        self.CONDITIONAL_BELIEF_PROB = 0.8  # give 0.8 prob mass to slot-vals that occured in prev domains. #TODO config?

    def str(self):
        return pprint.pformat(