<commit_before>package jp.cordea.switter.realm;

import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
import io.realm.annotations.Required;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * Created by <NAME> on 16/04/05.
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class LocalTweet extends RealmObject {

    @PrimaryKey
    private long id;

    private long tweetId;

    private long epoch;

    @Required
    private String text;

    private String profileImageUrl;

    private long userId;

    private String userName;

    private String userScreenName;

    private boolean isReply;

    private boolean isFavorite;

    private boolean isRetweet;

    private long replyTweetId;

    private int favoriteCount;

    private int retweetCount;

    private RealmList<LocalEntity> entities;

    public String getProfileBiggerImageUrl() {
        return profileImageUrl.replace("normal.png", "bigger.png");
    }
}<commit_msg>fix local tweet model, add util methods<commit_after>package jp.cordea.switter.realm;

import com.twitter.sdk.android.core.models.MediaEntity;
import com.twitter.sdk.android.core.models.Tweet;
import com.twitter.sdk.android.core.models.TweetEntities;
import com.twitter.sdk.android.core.models.UrlEntity;
import com.twitter.sdk.android.core.models.User;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Objects;

import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
import io.realm.annotations.Required;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * Created by <NAME> on 16/04/05.
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class LocalTweet extends RealmObject {

    @PrimaryKey
    private long id;

    private long tweetId;

    private String createdAt;

    @Required
    private String text;

    private String profileImageUrl;

    private long userId;

    private String userName;

    private String userScreenName;

    private boolean isReply;

    private boolean isFavorite;

    private boolean isRetweet;

    private long replyTweetId;

    private int favoriteCount;

    private int retweetCount;

    private RealmList<LocalEntity> entities;

    public String getProfileBiggerImageUrl() {
        return profileImageUrl.replace("normal.png", "bigger.png");
    }

    public static Tweet toTweet(LocalTweet localTweet) {
        RealmList<LocalEntity> entities = localTweet.getEntities();
        List<UrlEntity> urlEntities = new ArrayList<>();
        List<MediaEntity> mediaEntities = new ArrayList<>();
        for (int i = 0; i < entities.size(); i++) {
            LocalEntity entity = entities.get(i);
            if (entity.getType().equals("url")) {
                urlEntities.add(new UrlEntity(entity.getMediaUrl(), null, entity.getDisplayUrl(), 0, 0));
            } else {
                mediaEntities.add(
                        new MediaEntity(null, null, entity.getDisplayUrl(), 0, 0, 0, null, entity.getMediaUrl(), null, null, 0, null, null, null));
            }
        }

        return new Tweet(
                null,
                localTweet.getCreatedAt(),
                null,
                new TweetEntities(urlEntities, null, mediaEntities, null),
                null,
                localTweet.getFavoriteCount(),
                localTweet.isFavorite(),
                null,
                localTweet.getTweetId(),
                null,
                null,
                0,
                null,
                0,
                null,
                null,
                null,
                false,
                null,
                localTweet.getRetweetCount(),
                localTweet.isRetweet(),
                null,
                null,
                localTweet.getText(),
                false,
                new User(false, null, false, false, null, null, null, 0, false, 0, 0, false, localTweet.getUserId(), null, false, null, 0, null, localTweet.getUserName(),
                        null, null, null, false, null, localTweet.getProfileImageUrl(), null, null, null, null, null, false,
                        false, localTweet.getUserScreenName(), false, null, 0, null, null, 0 , false, null, null),
                false,
                null,
                null);
    }

    public static String epochToString(long epoch) {
        SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.US);
        return format.format(new Date(epoch));
    }

    public static long twitterDateToEpoch(String twitterDate) {
        return DateTime.parse(twitterDate, DateTimeFormat.forPattern("EEE MMM dd HH:mm:ss Z yyyy").withLocale(Locale.ENGLISH)).getMillis();
    }
}
{'fraction_non_alphanumeric': 0.09568214068518142, 'fraction_numerical': 0.0054733427934319885, 'mean_word_length': 2.43115438108484, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 12, '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': '3432451', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1375, 'n_words': 352}