<commit_before>/**
 * 
 */
package org.jdata.timeseries.processing;

/**
 * @author Hunter
 *
 */
public class Rule {

	int id;
	int refCount;
	Symbol head;

	public Rule(int aId) {

		this.id = aId;
		refCount = 0;
		head = new Symbol(0);
		head.setNext(head);
		head.setPrev(head);

	}

	public int getRefCount() {
		return refCount;
	}

	public void setRefCount(int refCount) {
		this.refCount = refCount;
	}

	public int getId() {
		return id;
	}

}
<commit_msg>Basic Rule functionality<commit_after>package org.jdata.timeseries.processing;

/**
 * @author Hunter
 *
 */
public class Rule {

    private int id;
    private int refCount;
    private Symbol head;

    public Rule(int aId) {

        this.id = aId;
        refCount = 0;
        head = new Symbol(0);
        head.setNext(head);                 
        head.setPrev(head);

    }

    public void addReference() {

        this.refCount = refCount + 1;

    }

    public void removeReference() {

        this.refCount = refCount - 1;

    }

    public void append(Symbol last) {

        last = head.getPrev();

    }

    public void reduce(Symbol firstInPair, Rule replacement) {

        Symbol sip = firstInPair.getNext();

        Symbol prev = firstInPair.getPrev();

        Symbol next = sip.getNext();

        Symbol newSymbol = new Symbol(replacement.getId());

        prev.setNext(newSymbol);

        next.setPrev(newSymbol);

        newSymbol.setNext(next);

        newSymbol.setPrev(prev);

        firstInPair.setNext(null);

        firstInPair.setPrev(null);

        sip.setNext(null);

        sip.setPrev(null);

    }

    public void expand(Symbol ruleSymbol, Rule replacement) {

        Symbol prev = ruleSymbol.getPrev();

        Symbol next = ruleSymbol.getNext();

        Symbol left = replacement.head.getNext();

        Symbol right = replacement.head.getPrev();

        prev.setNext(left);

        left.setNext(prev);

        next.setPrev(right);

        right.setPrev(next);

        ruleSymbol.setNext(null);

        ruleSymbol.setPrev(null);

        replacement.head.setNext(null);

        replacement.head.setPrev(null);

    }

    public int getRefCount() {
        return refCount;
    }

    public int getId() {
        return id;
    }

}

{'fraction_non_alphanumeric': 0.11468901632112924, 'fraction_numerical': 0.002646669607410675, 'mean_word_length': 2.1587743732590527, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3135755', 'n_tokens_mistral': 750, 'n_tokens_neox': 690, 'n_words': 153}