# Path: dsenser/constants.py
# ARG1 = "Arg1"
# 
# ARG2 = "Arg2"
# 
# CHAR_SPAN = "CharacterSpanList"
# 
# CONNECTIVE = "Connective"
# 
# ENCODING = "utf-8"
# 
# RAW_TEXT = "RawText"
# 
# SENSE = "Sense"
# 
# TOK_LIST = "TokenList"
# 
# TOK_OFFS_IDX = 2
# 
# TYPE = "Type"
# 
# DFLT_MODEL_PATH = os.path.join(MODEL_DIR, "pdtb.sense.model")
# 
# DFLT_MODEL_TYPE = WANG
# 
# DFLT_ECONN_PATH = os.path.join(ECONN_DIR, "ExpConn.txt")
# 
# ALT_LEX = "AltLex"
# 
# EXPLICIT = "Explicit"
# 
# IMPLICIT = "Implicit"
# 
# SVD = 1
# 
# LSTM = 2
# 
# MJR = 4
# 
# WANG = 8
# 
# XGBOOST = 16
# 
# PARSE_TREE = "parsetree"
# 
# DEPS = "dependencies"
# 
# WORDS = "words"
# 
# SENTENCES = "sentences"
# 
# SHORT2FULL = {"Expansion": "Expansion.Conjunction",
#               "Comparison": "Comparison.Contrast",
#               "Comparison.COntrast": "Comparison.Contrast"}
# 
# Path: dsenser/utils.py
# class timeit(object):
#     """Decorator class for measuring time performance.
# 
#     Attributes:
#       msg (str): message to be printed on method invocation
# 
#     """
# 
#     def __init__(self, a_msg):
#         """Class constructor.
# 
#         Args:
#           a_msg (str): debug message to print
# 
#         """
#         self.msg = a_msg
# 
#     def __call__(self, a_func):
#         """Decorator function.
# 
#         Args:
#           a_func (method): decorated method
# 
#         Returns:
#           method: wrapped method
# 
#         """
#         def _wrapper(*args, **kwargs):
#             print(self.msg + " started", file=sys.stderr)
#             start_time = datetime.utcnow()
#             a_func(*args, **kwargs)
#             end_time = datetime.utcnow()
#             time_delta = (end_time - start_time).total_seconds()
#             print(self.msg + " finished ({:.2f} sec)".format(time_delta),
#                   file=sys.stderr)
#         return wraps(a_func)(_wrapper)


from dsenser.constants import ARG1, ARG2, CHAR_SPAN, CONNECTIVE, ENCODING, \
    RAW_TEXT, SENSE, TOK_LIST, TOK_OFFS_IDX, TYPE, DFLT_MODEL_PATH, \
    DFLT_MODEL_TYPE, DFLT_ECONN_PATH, ALT_LEX, EXPLICIT, IMPLICIT, SVD, \
    LSTM, MJR, WANG, XGBOOST, PARSE_TREE, DEPS, WORDS, SENTENCES, SHORT2FULL
from dsenser.utils import timeit
from collections import Iterable
from cPickle import dump, load
from itertools import chain
            from dsenser.major import MajorSenser
            from dsenser.wang import WangSenser
            from dsenser.xgboost import XGBoostSenser
            from dsenser.svd import SVDSenser
            from dsenser.lstm import LSTMSenser
                from dsenser.svd import SVDSenser
                from dsenser.lstm import LSTMSenser
import codecs
import gc
import numpy as np
import os
import sys
          updates ``a_rels`` in place

        """
        n_senses = len(self.cls2idx)
        isense = isenses = vsense = None
        for irel in a_rels:
            isenses = irel[SENSE]
            vsense = np.zeros(n_senses)
            for isense in isenses:
                isense = SHORT2FULL.get(isense, isense)
                vsense[self.cls2idx[isense]] = 1
            irel[SENSE] = vsense / sum(vsense)

    def _get_type(self, a_rel):
        """Determine type of discourse relation.

        Args:
        a_rel (dict):
          relation in question

        Returns:
        (void)

        """
        conn = a_rel[CONNECTIVE]
        conn_txt = conn.get(RAW_TEXT, None)
        if conn_txt is not None:
            if not conn.get(TOK_LIST, None):
                rel = IMPLICIT
            elif self._normalize_conn(conn_txt) in self.econn:

# Path: dsenser/constants.py
# ARG1 = "Arg1"
# 
# ARG2 = "Arg2"
# 
# CHAR_SPAN = "CharacterSpanList"
# 
# CONNECTIVE = "Connective"
# 
# ENCODING = "utf-8"
# 
# RAW_TEXT = "RawText"
# 
# SENSE = "Sense"
# 
# TOK_LIST = "TokenList"
# 
# TOK_OFFS_IDX = 2
# 
# TYPE = "Type"
# 
# DFLT_MODEL_PATH = os.path.join(MODEL_DIR, "pdtb.sense.model")
# 
# DFLT_MODEL_TYPE = WANG
# 
# DFLT_ECONN_PATH = os.path.join(ECONN_DIR, "ExpConn.txt")
# 
# ALT_LEX = "AltLex"
# 
# EXPLICIT = "Explicit"
# 
# IMPLICIT = "Implicit"
# 
# SVD = 1
# 
# LSTM = 2
# 
# MJR = 4
# 
# WANG = 8
# 
# XGBOOST = 16
# 
# PARSE_TREE = "parsetree"
# 
# DEPS = "dependencies"
# 
# WORDS = "words"
# 
# SENTENCES = "sentences"
# 
# SHORT2FULL = {"Expansion": "Expansion.Conjunction",
#               "Comparison": "Comparison.Contrast",
#               "Comparison.COntrast": "Comparison.Contrast"}
# 
# Path: dsenser/utils.py
# class timeit(object):
#     """Decorator class for measuring time performance.
# 
#     Attributes:
#       msg (str): message to be printed on method invocation
# 
#     """
# 
#     def __init__(self, a_msg):
#         """Class constructor.
# 
#         Args:
#           a_msg (str): debug message to print
# 
#         """
#         self.msg = a_msg
# 
#     def __call__(self, a_func):
#         """Decorator function.
# 
#         Args:
#           a_func (method): decorated method
# 
#         Returns:
#           method: wrapped method
# 
#         """
#         def _wrapper(*args, **kwargs):
#             print(self.msg + " started", file=sys.stderr)
#             start_time = datetime.utcnow()
#             a_func(*args, **kwargs)
#             end_time = datetime.utcnow()
#             time_delta = (end_time - start_time).total_seconds()
#             print(self.msg + " finished ({:.2f} sec)".format(time_delta),
#                   file=sys.stderr)
#         return wraps(a_func)(_wrapper)


# Path: dsenser/dsenser.py
from dsenser.constants import ARG1, ARG2, CHAR_SPAN, CONNECTIVE, ENCODING, \
    RAW_TEXT, SENSE, TOK_LIST, TOK_OFFS_IDX, TYPE, DFLT_MODEL_PATH, \
    DFLT_MODEL_TYPE, DFLT_ECONN_PATH, ALT_LEX, EXPLICIT, IMPLICIT, SVD, \
    LSTM, MJR, WANG, XGBOOST, PARSE_TREE, DEPS, WORDS, SENTENCES, SHORT2FULL
from dsenser.utils import timeit
from collections import Iterable
from cPickle import dump, load
from itertools import chain
            from dsenser.major import MajorSenser
            from dsenser.wang import WangSenser
            from dsenser.xgboost import XGBoostSenser
            from dsenser.svd import SVDSenser
            from dsenser.lstm import LSTMSenser
                from dsenser.svd import SVDSenser
                from dsenser.lstm import LSTMSenser
import codecs
import gc
import numpy as np
import os
import sys

          updates ``a_rels`` in place

        """
        n_senses = len(self.cls2idx)
        isense = isenses = vsense = None
        for irel in a_rels:
            isenses = irel[SENSE]
            vsense = np.zeros(n_senses)
            for isense in isenses:
                isense = SHORT2FULL.get(isense, isense)
                vsense[self.cls2idx[isense]] = 1
            irel[SENSE] = vsense / sum(vsense)

    def _get_type(self, a_rel):
        """Determine type of discourse relation.

        Args:
        a_rel (dict):
          relation in question

        Returns:
        (void)

        """
        conn = a_rel[CONNECTIVE]
        conn_txt = conn.get(RAW_TEXT, None)
        if conn_txt is not None:
            if not conn.get(TOK_LIST, None):
                rel = IMPLICIT
            elif self._normalize_conn(conn_txt) in self.econn:

                rel = EXPLICIT