I need help with the following code everywhere that says "YOUR CODE HERE". Any help is appreciated. Thank you!
#Use the lexicons to create two lexicon features. A feature 'POSLEX' whose value indicates how many tokens belong to the positive lexicon. A feature 'NEGLEX' whose value indicates how many tokens belong to the negative lexicon.
def two_lexicon_features(tokens):
feats = {'POSLEX': 0, 'NEGLEX': 0}
# YOUR CODE HERE
return feats
#If a word from the positive lexicon (e.g. 'like') appears N times in the document (e.g. 5 times), add a positive lexicon feature 'POSLEX_word' for that word that is associated that value (e.g. {'POSLEX_like' : 5}. Similarly, if a word from the negative lexicon (e.g. 'dislike') appears N times in the document (e.g. 5 times), add a negative lexicon feature 'NEGLEX_word' for that word that is associated that value (e.g. {'NEGLEX_dislike' : 5}
def lexicon_features(tokens):
feats = {}
# YOUR CODE HERE
# Assume the positive and negative lexicons are available in poslex and neglex, respectively.
return feats
#Add a feature 'DOC_LEN' whose value is the natural logarithm of the document length (use math.log to compute logarithms)
import math
def len_feature(tokens):
feat = {'DOC_LEN': 'YOUR CODE HERE'}
return feat
#Add a feature 'DEICTIC_COUNT' that counts the number of 1st and 2nd person pronouns in the document.
def deictic_feature(tokens):
pronouns = set(('i', 'my', 'me', 'we', 'us', 'our', 'you', 'your'))
count = 0
# YOUR CODE HERE
return {'DEICTIC_COUNT': count}