algorithm – Create tweet threads from String in Java

I recently got this question in an exam, this is how I implemented, it is working fine. However, I would like to know if the code can be improved, as I think it for sure needs to be improved. The question was:

In the past, Twitter had a 140 characters limitation per tweet. If you wanted to enter longer tweets, you had to split it into several. We want to create a function that receives a String, which is the content of the tweet, that returns all the tweets with numbered prefixes (a List). It does not matter if the words are splitted. Something like this: (Tweet 1/5)tweetcontent…. (Tweet 2/5)tweetcontent…

public class Exercise {

static int MAX_CHARACTERS_OF_MESSAGE_IN_TWEET = 129;

public List<String> tweets(String message) {
    List<String> tweetsToReturn = new ArrayList<>();
    //calculate numberOfTweets needed to tweet
    int numberOfTweets = message.length() / MAX_CHARACTERS_OF_MESSAGE_IN_TWEET;
    //check if we need to add another tweet for the latest characters of the message
    int restOfTWeet = message.length() % MAX_CHARACTERS_OF_MESSAGE_IN_TWEET;
    if (restOfTWeet != 0) {
        numberOfTweets++;
    }
    //if there is only one tweet
    if (numberOfTweets == 1) {
        tweetsToReturn.add(message);
    } else { //if there is more than one tweet
        for (int i = 0; i < numberOfTweets - 1; i++) {
            tweetsToReturn.add("(Tweet " + (i + 1) + "/" + numberOfTweets + ")" + message.substring(i * MAX_CHARACTERS_OF_MESSAGE_IN_TWEET, (i+1) * MAX_CHARACTERS_OF_MESSAGE_IN_TWEET));
        }
        //create the latest tweet
        if (restOfTWeet != 0) {
            tweetsToReturn.add("(Tweet " + numberOfTweets + "/" + numberOfTweets + ")" + message.substring((numberOfTweets - 1) * MAX_CHARACTERS_OF_MESSAGE_IN_TWEET));
        }
    }
    return tweetsToReturn;
}}

Bonus point: Do it now but without the words being splitted. (This one I did not manage to do it).

Thank you!!!

❕NEWS – Nigeria bans Twitter after the president’s tweet got removed | Proxies-free

Muhammadu Buhari, the Nigerian president, has decided to ban the popular social media platform after they removed one of his tweet that sternly warns secessionist groups that operate in the southeast region of the country. Shortly later, the country’s ministry of information posted the ban announcement on the platform. This move enrages many Nigerian citizens who are no longer able to access the platform.

twitter – Changing the language that tweets are translated to when you hit “Translate tweet” button in Tweetdeck

I use Tweetdeck at home and at work to manipulate Twitter. I work in English but deal with many tweets in Catalan, Spanish, French and other languages. Tweetdeck has a one-touch “Translate tweet” button which appears below most tweets and provide a machine translation of the tweet – which is done by Microsoft Translator (see image) but in my case it is set to Spanish and I can’t find the way to alter this. What I want is for the result of the translation to be in English, but above all, I would like to have the option of changing it!

Tweet translated from Catalan to Spanish using Microsoft Translator embedded in Tweetdeck

I have attempted to ask Twitter Support if they know how I can fix this but they initially provided irrelevant information, and haven’t yet responded to my follow up.

I can’t find the way to ask Microsoft Support about it.

Other information which may be relevant: In my Microsoft account I have my default language set to English. The browser I work with is Chrome. In my Google account the default language is also set to English. However I am located in Spain (well, Catalonia). Also although I enter Twitter through my personal account, in Tweetdeck I also use a work account, and any default settings set at my work will tend to be in Spanish or Catalan. I am running a 2019 version of Tweetdeck on my home PC.

Any help would be brilliant.

❕NEWS – Elon Musk vague tweet about Bitcoin shook the market | Proxies-free

After the not so clear tweet of elon Musk about Bitcoin, the price of this digital currency increased by about $ 2,000. “I spoke with Bitcoin miners in North America,” Musk wrote on Twitter. They pledged to announce their current and future energy consumption from renewable sources and to ask other miners around the world to do the same. They made this promise on account.
do you think this tweet was the main reason for increasing the price of BTC?

twitter – Youtube video link doesn’t appear as embedded in tweet

Till yesterday, whenever I retweeted a YouTube link, it appeared with its thumbnail and title in the tweet itself. Video auto-plays if someone opens that tweet.

However today, when I tweeted/retweeted link of my new youtube video, it just remains a link and doesn’t convert into embedded video in that tweet.

Here are 2 such tweets, one with embedded video and one without.

Old tweet, with video – https://twitter.com/PolKholYouTube/status/1347938969711996928?s=20

New tweet, without video – https://twitter.com/PolKholYouTube/status/1349879126535057408?s=20

I am not sure what different I did when I wrote those 2 tweets.

I want my video to appear as embedded in my tweet, same as old video.

Any help please

Twitter Broadcast link embedded in tweet vs periscope link

Pretty simple, when I tweet going live, the link which comes up within the tweet is pscp.tv/w/

I have seen other tweets going live which instead have a twitter.com/i/broadcasts/ link within the tweet.

https://twitter.com/ActionNetworkHQ/status/1345761962307637248?s=20
Tweet with periscope link as live
SEMrush

https://twitter.com/FDSportsbook/status/1347226625243553794?s=20
Tweet with twitter broadcast link as live

Use restream to coordinate across multiple social platforms. Went live directly through twitter instead and still got a periscope link. Anyone know how to get the broadcast link?

 

Dogecoin's Price Rise AGAIN After Elon Musk Tweet!

Dogecoin’s price went up after Elon Musk posted a tweet saying that Dogecoin is his favorite crypto. Prices went up to $0.0037 which is an almost 8% increase, but it’s still worthless! Musk had previously posted tweets saying that Dogecoin is the king of all crypto, but I don’t know why he has such high hopes for Dogecoin. What do you think about this?

machine learning – Tweet Classification into topics- What to do with data

Good evening,
First of all, I want to apologize if the title is misleading.
I have a dataset made of around 60000 tweets, their date and time as well as the username. I need to classify them into topics. I am working on topic modelling with LDA getting the right number of topics (I guess) thanks to this R package, which calculates the value of three metrics(“CaoJuan2009”, “Arun2010”, “Deveaud2014”). Since I am very new to this, I just thought about a few questions that might be obvious for some of you, but I can’t find online.

  1. I have removed, before cleaning the data (removing mentions, stopwords, weird characters, numbers etc), all duplicate instances (having all three columns in common), in order to avoid them influencing the results of topic modelling. Is this right?

  2. Should I, for the same reason mentioned before, remove also all retweets?

  3. Until now, I thought about classifing using the “per-document-per-topic” probability. If I get rid of so many instances, do I have to classify them based on the “per-word-per-topic” probability?

  4. Do I have to divide the dataset into testing and training? I thought that is a thing only in supervised training, since I cannot really use the testing dataset to measure quality of classification.

  5. Antoher goal would be to classify twitterers based the topic they most are passionate about. Do you have any idea about how to implement this?

Thank you all very much in advance.