def word_moral_values(word): """Returns a dict that gives the association strength between word and every moral trait, as rated by annotators. Value ranges from 1 to 9. 1: words closely associated to harm, cheating, betrayal, subversion, degradation 9: words closely associated to care, fairness, loyalty, authority, purity/sanctity If the word is not in the lexicon of that moral trait, returns -1.""" return { moral: lexicon_use.moral_value(word=word, moral=moral) for moral in moral_options_lexicon }
def word_moral_annotations(word, normalized=False): """Returns a dict that gives the association strength between word and every moral trait, as rated by annotators. Value ranges from 1 to 9. 1: words closely associated to harm, cheating, betrayal, subversion, degradation 9: words closely associated to care, fairness, loyalty, authority, purity/sanctity normalized=True will normalize each annotation in the range -1 (vice) to +1 (virtue) If the word is not in the lexicon of that moral trait, returns NaN.""" return { moral: lexicon_use.moral_value(word=word, moral=moral, normalized=normalized) for moral in moral_options_lexicon }
def word_moral_value(word, moral): """Returns the association strength between word and moral trait, as rated by annotators. Value ranges from 1 to 9. 1: words closely associated to harm, cheating, betrayal, subversion, degradation 9: words closely associated to care, fairness, loyalty, authority, sanctity If the word is not in the lexicon of that moral trait, returns -1. For a list of available traits, get_available_lexicon_traits() """ if moral not in moral_options_lexicon: raise ValueError( 'Invalid moral trait "{}" specified. Valid traits are: {}'.format( moral, moral_options_lexicon)) return lexicon_use.moral_value(word=word, moral=moral)