<jupyter_start><jupyter_text>SENTIMENT ANALYSIS<jupyter_code>!pip install nltk
!pip install goslate
!pip install aiohttp
!pip install asyncio
import pandas as pd
import numpy as np
import time
from nltk.sentiment.vader import *
nltk.download('vader_lexicon')

sentanalyzer=SentimentIntensityAnalyzer()

def sentiment(sentence):
  sent_dict=sentanalyzer.polarity_scores(sentence)

  if sent_dict['compound'] >=0.05 :
    return "positive"
  elif sent_dict['compound'] <= -0.05:
    return "negative"
  else:
    return "neutral"

data=pd.read_json("/content/text-query-tweets2.json",lines=True)
data
import goslate
import aiohttp
import asyncio
gs=goslate.Goslate()
#print(gs.translate('வணக்கம் உலகம்','en'))


sentiment_list=[]

for i in data.index:
  sentiment_list.append(sentiment(str(data['content'][i])))
data['sentiments']=sentiment_list

data
#print(sentiment_list)

async def main():
  async with aiohttp.ClientSession() as session:
    tasks=[]
    translated=[]
    for i in data.index:
      sentiment_list.append(sentiment(str(data['content'][i])))
      if data['lang'][i] !='en':
        task = asyncio.ensure_future(gs.translate(str(data['content'][i]), 'en'))
      else:
        translated.append(str(data['content'][i]))
      translated.append(task)
      tasks.append(task)
    await asyncio(*tasks)
    data['content_translated']=translated

data[data['replyCount']>100]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.007037297677691766, 'mean_word_length': 5.405405405405405, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '404620', 'license': 'MIT', 'n_tokens_mistral': 518, 'n_tokens_neox': 509, 'n_words': 93, 'path': 'data/national_language.ipynb', 'repo_name': 'esh04/Twitter-Data-Analysis-LS', 'size': '1421'}