# Q1c · Sentiment feature extraction

Subject: Natural Language Processing

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/nlp/#tee/papers/legacy-f23/q1c

Canonical: https://deep-learning-study-room.vercel.app/read/nlp/tee/papers/legacy-f23--q1c/

Previous examination · complete worked answers

**Question. Extract x₁ = log₁₀(word count), x₂ = count of positive lexicon words and x₃ = count of negative lexicon words from: “I was amazed at how the product quickly it arrived. The customer service was exceptional. The support team responded promptly and professionally. I was not sad with my decision. Overall, my experience with them was outstanding.” Positive lexicon={amazed,promptly,outstanding,great}; negative={horrible,sad,disgusting}.** [5 marks]

### Answer

### Given

I was amazed at how the product quickly it arrived. The customer service was exceptional. The support team responded promptly and professionally. I was not sad with my decision. Overall, my experience with them was outstanding.

### To find

The three numerical features.

### Formula: which one and why

Use word tokens after stripping punctuation, keep stopwords, and match only the supplied lexicons. Raw lexicon counting does not automatically reverse a word under negation.

### Step 1. List and count every word

| Position | Word |
| --- | --- |
| 1 | i |
| 2 | was |
| 3 | amazed |
| 4 | at |
| 5 | how |
| 6 | the |
| 7 | product |
| 8 | quickly |
| 9 | it |
| 10 | arrived |
| 11 | the |
| 12 | customer |
| 13 | service |
| 14 | was |
| 15 | exceptional |
| 16 | the |
| 17 | support |
| 18 | team |
| 19 | responded |
| 20 | promptly |
| 21 | and |
| 22 | professionally |
| 23 | i |
| 24 | was |
| 25 | not |
| 26 | sad |
| 27 | with |
| 28 | my |
| 29 | decision |
| 30 | overall |
| 31 | my |
| 32 | experience |
| 33 | with |
| 34 | them |
| 35 | was |
| 36 | outstanding |

### Step 2. Apply the logarithm



$$
x_1=\log_{10}36=1.556302501
$$



### Step 3. Count positive matches

amazed, promptly, outstanding each occur once. great does not occur. x₂=3. exceptional is not in the supplied lexicon, so it is not counted.

### Step 4. Count negative matches

sad occurs once; horrible and disgusting do not. x₃=1. The phrase “not sad” remains one raw negative-lexicon occurrence under the specified feature definition.

### Final answer

**(x₁,x₂,x₃)=(1.556302501,3,1).**
