<commit_before>package de.stephanlindauer.criticalmaps.model;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.text.ParseException;
import java.util.ArrayList;

import de.stephanlindauer.criticalmaps.utils.TwitterUtils;
import de.stephanlindauer.criticalmaps.vo.twitter.Tweet;

public class TwitterModel {

    private ArrayList<Tweet> tweets = new ArrayList<>();

    //singleton
    private static TwitterModel instance;

    public static TwitterModel getInstance() {
        if (TwitterModel.instance == null) {
            TwitterModel.instance = new TwitterModel();
        }
        return TwitterModel.instance;
    }

    public void setTweetsFromJsonString(String tweetsString) throws JSONException, ParseException {
        tweets.clear();
        JSONObject jsonObject = new JSONObject(tweetsString);
        JSONArray statusesArray = jsonObject.getJSONArray("statuses");

        for (int i = 0, statusesArrayLength = statusesArray.length(); i < statusesArrayLength; i++) {
            JSONObject currentStatus = statusesArray.getJSONObject(i);
            Tweet tweet = new Tweet()
                    .setUserName(currentStatus.getJSONObject("user").getString("name"))
                    .setUserScreenName(currentStatus.getJSONObject("user").getString("screen_name"))
                    .setTweetId(currentStatus.getString("id_str"))
                    .setText(currentStatus.getString("text"))
                    .setTimestamp(TwitterUtils.getTwitterDate(currentStatus.getString("created_at")))
                    .setProfileImageUrl(currentStatus.getJSONObject("user").getString("profile_image_url_https"));

            tweets.add(tweet);
        }
    }

    public ArrayList<Tweet> getTweets() {
        return tweets;<commit_msg>Extract user first as it is used multiple times<commit_after>package de.stephanlindauer.criticalmaps.model;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.text.ParseException;
import java.util.ArrayList;

import de.stephanlindauer.criticalmaps.utils.TwitterUtils;
import de.stephanlindauer.criticalmaps.vo.twitter.Tweet;

public class TwitterModel {

    private ArrayList<Tweet> tweets = new ArrayList<>();

    //singleton
    private static TwitterModel instance;

    public static TwitterModel getInstance() {
        if (TwitterModel.instance == null) {
            TwitterModel.instance = new TwitterModel();
        }
        return TwitterModel.instance;
    }

    public void setTweetsFromJsonString(String tweetsString) throws JSONException, ParseException {
        tweets.clear();
        JSONObject jsonObject = new JSONObject(tweetsString);
        JSONArray statusesArray = jsonObject.getJSONArray("statuses");

        for (int i = 0, statusesArrayLength = statusesArray.length(); i < statusesArrayLength; i++) {
            JSONObject currentStatus = statusesArray.getJSONObject(i);
            final JSONObject user = currentStatus.getJSONObject("user");
            Tweet tweet = new Tweet()
                    .setUserName(user.getString("name"))
                    .setUserScreenName(user.getString("screen_name"))
                    .setTweetId(currentStatus.getString("id_str"))
                    .setText(currentStatus.getString("text"))
                    .setTimestamp(TwitterUtils.getTwitterDate(currentStatus.getString("created_at")))
                    .setProfileImageUrl(user.getString("profile_image_url_https"));

            tweets.add(tweet);
        }
    }

    public ArrayList<Tweet> getTweets() {
        return tweets;
{'fraction_non_alphanumeric': 0.09867695700110253, 'fraction_numerical': 0.0005512679162072767, 'mean_word_length': 3.068385650224215, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4334702', 'n_tokens_mistral': 984, 'n_tokens_neox': 937, 'n_words': 179}