I am doing sentiment analysis on given documents. My goal is to find out the closest or surrounding adjective words with respect to the target phrase in my sentences. I do have an idea how to extract surrounding words with respect to target phrases. But how do I find out relatively close or closest adjective or NNP
or VBN
or other POS tag with respect to target phrase ?
Here is the sketch idea of how I may get surrounding words with respect to my target phrase.
sentence_List = {
"Obviously one of the most important features of any computer is the human interface.",
"Good for everyday computing and web browsing.",
"My problem was with DELL Customer Service",
"I play a lot of casual games online[comma] and the touchpad is very responsive"
}
target_phraseList = {
"human interface",
"everyday computing",
"DELL Customer Service",
"touchpad"
}
Note that my original dataset was given as DataFrame where the list of the sentences and respective target phrases were given. Here I just simulated data as follows:
import pandas as pd
df=pd.Series(sentence_List, target_phraseList)
df=pd.DataFrame(df)
Here, I tokenize the sentence as follow:
from nltk.tokenize import word_tokenize
tokenized_sents = [word_tokenize(i) for i in sentence_List]
tokenized=[i for i in tokenized_sents]
Then I try to find out surrounding words with respect to my target phrases by using this loot at here. However, I want to find out relatively closer or closest adjective
, or verbs
or VBN
with respect to my target phrase.
How can I make this happen? Any idea to get this done? Thanks