<commit_before>package com.czbix.v2ex.parser;

import com.czbix.v2ex.model.Avatar;
import com.google.common.base.Preconditions;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.xml.sax.SAXException;

import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MyselfParser extends Parser {
    private static final Pattern PATTERN_UNREAD_NUM = Pattern.compile("\\d+");

    public static Avatar parseAvatarOnly(Document doc) throws IOException, SAXException {
        final Elements elements = doc.select("#Rightbar > div:nth-child(2)");
        Preconditions.checkState(elements.size() == 1);

        Element ele = elements.get(0);
        final String url = ele.select(".avatar").get(0).attr("src");
        return new Avatar.Builder().setUrl(url).createAvatar();
    }

    /**
     * @return null if user signed out
     */
    public static MySelfInfo parseDoc(Document doc) {
        final Elements elements = doc.select("#Rightbar > div:nth-child(2)");
        Preconditions.checkState(elements.size() == 1);

        Element ele = elements.get(0);
        final Elements children = ele.children();
        if (children.size() <= 2) {
            // user signed out
            return null;
        }

        final String text = ele.select(".inner > strong > a").get(0).text();
        final Matcher matcher = PATTERN_UNREAD_NUM.matcher(text);
        Preconditions.checkState(matcher.find());
        final int num = Integer.parseInt(matcher.group());

        return new MySelfInfo(num);
    }

    public static class MySelfInfo {
        public final int mUnread;

        public MySelfInfo(int unread) {
            mUnread = unread;
        }
    }
}<commit_msg>fix bug for parse notifications count<commit_after>package com.czbix.v2ex.parser;

import com.czbix.v2ex.model.Avatar;
import com.google.common.base.Preconditions;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.xml.sax.SAXException;

import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MyselfParser extends Parser {
    private static final Pattern PATTERN_UNREAD_NUM = Pattern.compile("\\d+");

    public static Avatar parseAvatarOnly(Document doc) throws IOException, SAXException {
        final Elements elements = doc.select("#Rightbar > div:nth-child(2)");
        Preconditions.checkState(elements.size() == 1);

        Element ele = elements.get(0);
        final String url = ele.select(".avatar").get(0).attr("src");
        return new Avatar.Builder().setUrl(url).createAvatar();
    }

    /**
     * @return null if user signed out
     */
    public static MySelfInfo parseDoc(Document doc) {
        final Elements elements = doc.select("#Rightbar > div:nth-child(2)");
        Preconditions.checkState(elements.size() == 1);

        Element ele = elements.get(0);
        final Elements children = ele.children();
        if (children.size() <= 2) {
            // user signed out
            return null;
        }

        final String text = ele.select(".inner a[href=/notifications]").get(0).text();
        final Matcher matcher = PATTERN_UNREAD_NUM.matcher(text);
        Preconditions.checkState(matcher.find());
        final int num = Integer.parseInt(matcher.group());

        return new MySelfInfo(num);
    }

    public static class MySelfInfo {
        public final int mUnread;

        public MySelfInfo(int unread) {
            mUnread = unread;
        }
    }
}
{'fraction_non_alphanumeric': 0.12097669256381798, 'fraction_numerical': 0.006104328523862375, 'mean_word_length': 2.8930885529157666, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '933674', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1047, 'n_words': 244}