0

Q) How to solve the following errors

1)Unexpected parameter: Lang

2)Unexpected parameter: tweet_node

3)line 25, in tweets = [tweet.full_text for tweet in tweet_cursor ]

AttributeError: 'Status' object has no attribute 'full_text'

CODE

import tweepy
import textblob
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import re


api_key = 'xxxxx'
api_key_secret = 'xxxxxxx'
access_token = 'xxxxxxxxxxxxxxxx'
access_token_secret = 'xxxxxxxxxxxxxxxxxxxxxx'

authenticator = tweepy.OAuthHandler(api_key, api_key_secret)
authenticator.set_access_token(access_token, access_token_secret)

api= tweepy.API (authenticator, wait_on_rate_limit=True)

crypto_currency= "Dogecoin"

search= f'#(crypto currency) -filter: retweets'

tweet_cursor = tweepy.Cursor(api.search_tweets, q=search, Lang='en', `tweet_node='extended').items (100)`

tweets = [tweet.full_text for tweet in tweet_cursor ]

tweets_df = pd.DataFrame(tweets , columns = ['Tweets'])

for _, row in tweets_df.iterrows():
    row ['tweets'] = re.sub('https\S+','' , row['Tweets'])
    row['tweets'] = re.sub('#\S+', '', row['Tweets'])
    row['tweets'] = re.sub('@\S+', '', row['Tweets'])
    row['tweets'] = re.sub('\\n', '', row['Tweets'])

tweets_df['Polarity'] = tweets_df['Tweets'].map(lambda tweet:textblob.TextBlob(tweet).sentiment.polarity)
tweets_df['Result'] = tweets_df['Polarity'].map(lambda pol:'+' if pol > 0 else '-')

positive = tweets_df[tweets_df.Result == '+'].count()['Tweets']
negative = tweets_df[tweets_df.Result == '-'].count()['Tweets']

plt.bar([0,1], [positive,negative], label=['Positive', 'Negative'], color=['green', 'red'])
plt.legend

plt.show()

1 Answer 1

0
  1. lang=en should be inside of the value of search.
  2. tweet_node should be tweet_mode
  3. The full_text will only exist if the tweet_mode=extended parameter is correct, and the Tweet is more than 140 characters in text length.
Sign up to request clarification or add additional context in comments.

6 Comments

thanks ,can you please explain the 1 point again
search= f'#(crypto currency) -filter:retweets lang:en', and remove the Lang='en' from the following line.
wait, also, you cannot use #(crypto currency) you mean #crypto_currency I guess
Can you please help in solving the following issues 1)I am getting the same output for all types of inputs pls suggest some way to solve this issue. 2)I am not able to extract tweets for a particular date since ,from attributes not working.
You should mark this question as solved if the answer was helpful. I would suggest that you create a new question with specific information about what these new issues are. It is impossible to tell what might not be working without having more detail.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.