convolutional_attention/token_naming_data.py
def __get_empirical_distribution(element_dict, elements, dirichlet_alpha=10.):
        """
        Retrive te empirical distribution of tokens
        :param element_dict: a dictionary that can convert the elements to their respective ids.
        :param elements: an iterable of all the elements
        :return:
        """
        targets = np.array([element_dict.get_id_or_unk(t) for t in elements])
        empirical_distribution = np.bincount(targets, minlength=len(element_dict)).astype(float)
        empirical_distribution += dirichlet_alpha / len(empirical_distribution)
        return empirical_distribution / (np.sum(empirical_distribution) + dirichlet_alpha)

        Retrive te empirical distribution of tokens
        :param element_dict: a dictionary that can convert the elements to their respective ids.
        :param elements: an iterable of all the elements
        :return:
        
Retrive te empirical distribution of tokens
Retrive te empirical distribution of tokens
def __get_empirical_distribution(element_dict, elements, dirichlet_alpha=10.):
        targets = np.array([element_dict.get_id_or_unk(t) for t in elements])
        empirical_distribution = np.bincount(targets, minlength=len(element_dict)).astype(float)
        empirical_distribution += dirichlet_alpha / len(empirical_distribution)
        return empirical_distribution / (np.sum(empirical_distribution) + dirichlet_alpha)
def __get_empirical_distribution ( element_dict , elements , dirichlet_alpha = 10. ) : targets = np . array ( [ element_dict . get_id_or_unk ( t ) for t in elements ] ) empirical_distribution = np . bincount ( targets , minlength = len ( element_dict ) ) . astype ( float ) empirical_distribution += dirichlet_alpha / len ( empirical_distribution ) return empirical_distribution / ( np . sum ( empirical_distribution ) + dirichlet_alpha )
Retrive te empirical distribution of tokens
Retrive te empirical distribution of tokens
"""
        Retrive te empirical distribution of tokens
        :param element_dict: a dictionary that can convert the elements to their respective ids.
        :param elements: an iterable of all the elements
        :return:
        """
None
element_dict
a dictionary that can convert the elements to their respective ids.
a dictionary that can convert the elements to their respective ids .
elements
an iterable of all the elements
an iterable of all the elements
dirichlet_alpha