0

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}
  • 1
    [How do I ask and answer homework questions?](https://meta.stackoverflow.com/q/334822) and [Open letter to students with homework problems](https://softwareengineering.meta.stackexchange.com/questions/6166/open-letter-to-students-with-homework-problems) – Naeem Khan Feb 24 '22 at 04:03
  • In short, do your homework. Stackoverflow is a NOT a code writing service to cheat your homework on. Attempt to do your homework, and if you are stuck anywhere or encounter a problem, you can ask here and someone will definitely help you. – Naeem Khan Feb 24 '22 at 04:08

0 Answers0