Как я могу сделать этот код l oop (выполнить) через все предложения в моем фрейме данных?
def get_sentiment(review):
for text in review:
senti = nlp.annotate(text,
properties={
'annotators': 'sentiment',
'outputFormat': 'json',
'timeout': 40000,
})
#for i in senti["sentences"]:
return ("{}: '{}': {} (Sentiment Value) {} (Sentiment)".format(
s["index"],
" ".join([t["word"] for t in s["tokens"]]),
s["sentimentValue"], s["sentiment"]))
При выполнении вышеизложенного возвращается только первое предложение строки: Ниже ...
"0: 'you can see everything from thousands of years in human history it was an unforgettable and wonderful trip to paris for me': 3 (Sentiment Value) Positive (Sentiment)"
Я пробовал несколько вариантов для функции get_sentiment, но лучший результат, который я получаю, это показанный.
Мой фрейм данных называется «обзоры» и имеет один столбец (обзор). Это содержание:
Review
0 you can see everything from thousands of years in human history it was an unforgettable and wonderful trip to paris for me
1 buy your tickets in advance and consider investing in one of many reputable tour guides that you can find online for at least part of your visit to the louvre these 2 arrangements will absolutely maximize your time and enjoyment of th...
2 quite an interesting place and a must see for art lovers the museum is larger than i expected and has so many exhibition areas that a full day trip might be needed if one wants to visit the whole place
3 simply incredible do not forget to get a three day pass if you love architecture art and history it is a must
4 we got here about 45 minutes before opening time and we were very first in line to get into the museum make sure to buy tickets ahead of time to help get in faster this museum is massive and can easily take your entire day an incredi...