<commit_before><commit_msg>begin implementing XMLHandler<commit_after>package mikesaelim.arxivoaiharvester;

import lombok.NonNull;
import mikesaelim.arxivoaiharvester.data.ArticleMetadata;
import mikesaelim.arxivoaiharvester.data.ArticleVersion;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;

import java.util.List;
import java.util.Stack;

/**
 * Created by <NAME> on 1/5/15.
 */
public class XMLHandler extends DefaultHandler {

    /**
     * This list of records gets appended as we parse the XML document.  This is the output of the parser.
     */
    private List<ArticleMetadata> records;

    /**
     * At any point of the parsing process, this is a Stack of the XML nodes we are inside - the ones we have entered
     * but not yet exited.  When we enter a node, we push the name of that node onto the Stack, and when we leave a
     * node, we demand that its name match the one we pop off the stack.
     */
    private Stack<String> nodeStack;

    /**
     * The builder for the ArticleMetadata object currently being created.  This is only non-null while inside a record
     * node.
     */
    private ArticleMetadata.ArticleMetadataBuilder currentRecord;
    /**
     * The builder for the ArticleVersion object currently being created.  This is only non-null while inside a version
     * node.
     */
    private ArticleVersion.ArticleVersionBuilder currentVersion;


    /**
     * @param records list of records to be appended by the records parsed with this handler
     */
    public XMLHandler (@NonNull List<ArticleMetadata> records) {
        this.records = records;
    }

    public void startElement(String uri, String localName, String qName, Attributes attributes) {
        // TODO: implement
    }

    public void endElement(String uri, String localName, String qName) {
        // TODO: implement
    }

    public void characters(char[] ch, int start, int length) {
        // TODO: implement
    }

    // TODO: handle warnings, errors, etc.
}
{'fraction_non_alphanumeric': 0.07554671968190854, 'fraction_numerical': 0.0019880715705765406, 'mean_word_length': 3.00996015936255, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6886721', 'n_tokens_mistral': 555, 'n_tokens_neox': 533, 'n_words': 215}