# Path: dsenser/nnbase.py
# MAX = 1e10
# INF = float('inf')
# UNK_PROB = lambda: np.random.binomial(1, 0.05)
# DIG_RE = re.compile(r"^[\d.]*\d[\d.]*$")
# def _norm_vec(a_x):
# def _norm_word(a_word):
#     def __init__(self, a_w2v=False, a_lstsq=False, a_max_iters=MAX_ITERS):
#     def train(self, a_train_data, a_dev_data=None, a_n_y=-1,
#               a_i=-1, a_train_out=None, a_dev_out=None):
#     def _init_nn(self):
#     def predict(self, a_rel, a_data, a_ret, a_i):
#     def _predict(self, a_args, a_ret, a_i):
#     def _free(self):
#     def _cleanup(self, a_vars):
#     def _generate_ts(self, a_data, a_get_w_emb_i, a_get_c_emb_i):
#     def _rel2x(self, a_rel, a_parses, a_get_w_emb_i, a_get_c_emb_i):
#     def _arg2emb_idx(self, a_parses, a_rel, a_arg, a_get_emb_i):
#     def _init_w_emb(self):
#     def _init_w2v_emb(self):
#     def _init_w2emb(self):
#     def _get_train_w_emb_i(self, a_word):
#     def _get_test_w_emb_i(self, a_word):
#     def _get_train_w2v_emb_i(self, a_word):
#     def _get_test_w2v_emb_i(self, a_word):
#     def _get_test_w2v_lstsq_emb_i(self, a_word):
#     def _init_conn_emb(self):
#     def get_train_c_emb_i(self, a_conn):
#     def get_test_c_emb_i(self, a_conn):
#     def _init_dropout(self, a_input):
#     def _init_funcs(self, a_grads=None):
#     def _init_wemb_funcs(self):
#     def _reset_funcs(self):
#     def _compute_w_stat(self, a_parses):
# class NNBaseSenser(BaseSenser):
# 
# Path: dsenser/constants.py
# CONNECTIVE = "Connective"
# 
# WORDS = "words"
# 
# SENTENCES = "sentences"
# 
# RAW_TEXT = "RawText"


from dsenser.nnbase import _norm_vec, _norm_word, NNBaseSenser, DFLT_VDIM
from dsenser.constants import CONNECTIVE, WORDS, SENTENCES, RAW_TEXT
from pytest import fixture
from mock import patch, MagicMock, Mock
from unittest import TestCase
import dsenser
import dsenser.nnbase
import numpy as np
import pytest
import theano
                 " borrowings only",
                 "TokenList": [[517, 519, 85, 2, 3], [520, 528, 86, 2, 4],
                               [529, 532, 87, 2, 5], [533, 536, 88, 2, 6],
                               [537, 539, 89, 2, 7], [540, 548, 90, 2, 8],
                               [549, 559, 91, 2, 9], [560, 564, 92, 2, 10]]},
        "Arg2": {"CharacterSpanList": [[573, 629]], "RawText": "the agency"
                 " receives specific congressional authorization",
                 "TokenList": [[573, 576, 95, 2, 13], [577, 583, 96, 2, 14],
                               [584, 592, 97, 2, 15], [593, 601, 98, 2, 16],
                               [602, 615, 99, 2, 17], [616, 629, 100, 2, 18]]},
        CONNECTIVE: {"CharacterSpanList": [[566, 572]], RAW_TEXT: "unless",
                     "TokenList": [[566, 572, 94, 2, 12]]},
        "Sense": [], "Type": "", "ID": 35709}

VEC0 = np.array([0, 0, 0, 0])
VEC1 = np.array([0, 1, 2, 3])
VEC2 = np.array([4, 5, 6, 7])
VEC3 = np.array([8, 9, 10, 11])


##################################################################
# Test Methods
def test_norm_vec():
    a = np.ones(10)
    b = _norm_vec(a)
    assert np.sqrt(np.sum(b**2)) == 1.


def test_norm_word():
    assert _norm_word("124345") == "1"

# Path: dsenser/nnbase.py
# MAX = 1e10
# INF = float('inf')
# UNK_PROB = lambda: np.random.binomial(1, 0.05)
# DIG_RE = re.compile(r"^[\d.]*\d[\d.]*$")
# def _norm_vec(a_x):
# def _norm_word(a_word):
#     def __init__(self, a_w2v=False, a_lstsq=False, a_max_iters=MAX_ITERS):
#     def train(self, a_train_data, a_dev_data=None, a_n_y=-1,
#               a_i=-1, a_train_out=None, a_dev_out=None):
#     def _init_nn(self):
#     def predict(self, a_rel, a_data, a_ret, a_i):
#     def _predict(self, a_args, a_ret, a_i):
#     def _free(self):
#     def _cleanup(self, a_vars):
#     def _generate_ts(self, a_data, a_get_w_emb_i, a_get_c_emb_i):
#     def _rel2x(self, a_rel, a_parses, a_get_w_emb_i, a_get_c_emb_i):
#     def _arg2emb_idx(self, a_parses, a_rel, a_arg, a_get_emb_i):
#     def _init_w_emb(self):
#     def _init_w2v_emb(self):
#     def _init_w2emb(self):
#     def _get_train_w_emb_i(self, a_word):
#     def _get_test_w_emb_i(self, a_word):
#     def _get_train_w2v_emb_i(self, a_word):
#     def _get_test_w2v_emb_i(self, a_word):
#     def _get_test_w2v_lstsq_emb_i(self, a_word):
#     def _init_conn_emb(self):
#     def get_train_c_emb_i(self, a_conn):
#     def get_test_c_emb_i(self, a_conn):
#     def _init_dropout(self, a_input):
#     def _init_funcs(self, a_grads=None):
#     def _init_wemb_funcs(self):
#     def _reset_funcs(self):
#     def _compute_w_stat(self, a_parses):
# class NNBaseSenser(BaseSenser):
# 
# Path: dsenser/constants.py
# CONNECTIVE = "Connective"
# 
# WORDS = "words"
# 
# SENTENCES = "sentences"
# 
# RAW_TEXT = "RawText"


# Path: tests/test_nnbase.py
from dsenser.nnbase import _norm_vec, _norm_word, NNBaseSenser, DFLT_VDIM
from dsenser.constants import CONNECTIVE, WORDS, SENTENCES, RAW_TEXT
from pytest import fixture
from mock import patch, MagicMock, Mock
from unittest import TestCase
import dsenser
import dsenser.nnbase
import numpy as np
import pytest
import theano

                 " borrowings only",
                 "TokenList": [[517, 519, 85, 2, 3], [520, 528, 86, 2, 4],
                               [529, 532, 87, 2, 5], [533, 536, 88, 2, 6],
                               [537, 539, 89, 2, 7], [540, 548, 90, 2, 8],
                               [549, 559, 91, 2, 9], [560, 564, 92, 2, 10]]},
        "Arg2": {"CharacterSpanList": [[573, 629]], "RawText": "the agency"
                 " receives specific congressional authorization",
                 "TokenList": [[573, 576, 95, 2, 13], [577, 583, 96, 2, 14],
                               [584, 592, 97, 2, 15], [593, 601, 98, 2, 16],
                               [602, 615, 99, 2, 17], [616, 629, 100, 2, 18]]},
        CONNECTIVE: {"CharacterSpanList": [[566, 572]], RAW_TEXT: "unless",
                     "TokenList": [[566, 572, 94, 2, 12]]},
        "Sense": [], "Type": "", "ID": 35709}

VEC0 = np.array([0, 0, 0, 0])
VEC1 = np.array([0, 1, 2, 3])
VEC2 = np.array([4, 5, 6, 7])
VEC3 = np.array([8, 9, 10, 11])


##################################################################
# Test Methods
def test_norm_vec():
    a = np.ones(10)
    b = _norm_vec(a)
    assert np.sqrt(np.sum(b**2)) == 1.


def test_norm_word():
    assert _norm_word("124345") == "1"

    assert _norm_word("ABCDEF") == "abcdef"