<commit_before>package com.nsharmon.jpro.engine;

import java.util.HashSet;
import java.util.Set;

import com.nsharmon.jpro.engine.statements.Expression;
import com.nsharmon.jpro.engine.statements.FactStatement;

public class MatchResult {
	private final Set<VariableSubstitution> substitutions = new HashSet<VariableSubstitution>();
	private final Set<FactStatement> relatedFacts = new HashSet<FactStatement>();
	private boolean found;

	public MatchResult(final boolean found) {
		this.found = found;
	}

	public void addVariableSubstitution(final Expression<?> varExpr, final Expression<?> atomExpr) {
		substitutions.add(new VariableSubstitution(varExpr, atomExpr));
	}

	public void addFactStatement(final FactStatement stmt) {
		relatedFacts.add(stmt);
	}

	public boolean hasMatches() {
		return found;
	}

	public void setMatches(final boolean found) {
		this.found = found;
	}

	public Set<VariableSubstitution> getSubstitutions() {
		return substitutions;
	}

	public Set<FactStatement> getRelatedFacts() {
		return relatedFacts;
	}

	@Override
	public String toString() {
		return found ? "yes." : "no.";
	}

	public void accumulate(final MatchResult matches) {
		found = found || matches.found;
		substitutions.addAll(matches.substitutions);
		relatedFacts.addAll(relatedFacts);
	}

	public void clear() {
		substitutions.clear();
		relatedFacts.clear();
	}

	public class VariableSubstitution {
		private final Expression<?> varExpr;
		private final Expression<?> atomExpr;

		public VariableSubstitution(final Expression<?> varExpr, final Expression<?> atomExpr) {
			this.varExpr = varExpr;
			this.atomExpr = atomExpr;
		}

		@Override
		public String toString() {
			return varExpr + "=" + atomExpr;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + ((atomExpr == null) ? 0 : atomExpr.hashCode());
			result = prime * result + ((varExpr == null) ? 0 : varExpr.hashCode());
			return result;<commit_msg>Fixed minor error when porting fact information to other MatchResult instances using accumulate.<commit_after>package com.nsharmon.jpro.engine;

import java.util.HashSet;
import java.util.Set;

import com.nsharmon.jpro.engine.statements.Expression;
import com.nsharmon.jpro.engine.statements.FactStatement;

public class MatchResult {
	private final Set<VariableSubstitution> substitutions = new HashSet<VariableSubstitution>();
	private final Set<FactStatement> relatedFacts = new HashSet<FactStatement>();
	private boolean found;

	public MatchResult(final boolean found) {
		this.found = found;
	}

	public void addVariableSubstitution(final Expression<?> varExpr, final Expression<?> atomExpr) {
		substitutions.add(new VariableSubstitution(varExpr, atomExpr));
	}

	public void addFactStatement(final FactStatement stmt) {
		relatedFacts.add(stmt);
	}

	public boolean hasMatches() {
		return found;
	}

	public void setMatches(final boolean found) {
		this.found = found;
	}

	public Set<VariableSubstitution> getSubstitutions() {
		return substitutions;
	}

	public Set<FactStatement> getRelatedFacts() {
		return relatedFacts;
	}

	@Override
	public String toString() {
		return found ? "yes." : "no.";
	}

	public void accumulate(final MatchResult matches) {
		found = found || matches.found;
		substitutions.addAll(matches.substitutions);
		relatedFacts.addAll(matches.relatedFacts);
	}

	public void clear() {
		substitutions.clear();
		relatedFacts.clear();
	}

	public class VariableSubstitution {
		private final Expression<?> varExpr;
		private final Expression<?> atomExpr;

		public VariableSubstitution(final Expression<?> varExpr, final Expression<?> atomExpr) {
			this.varExpr = varExpr;
			this.atomExpr = atomExpr;
		}

		@Override
		public String toString() {
			return varExpr + "=" + atomExpr;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + ((atomExpr == null) ? 0 : atomExpr.hashCode());
			result = prime * result + ((varExpr == null) ? 0 : varExpr.hashCode());
			return result;
{'fraction_non_alphanumeric': 0.11119098969566259, 'fraction_numerical': 0.0023963575365444525, 'mean_word_length': 4.694406548431105, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '5316387', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1243, 'n_words': 323}