<commit_before>/*
 * Copyright 2002-2014 The Jamocha Team
 * 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.jamocha.org/
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package org.jamocha.filter;

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

import lombok.Getter;

import org.jamocha.dn.memory.CounterColumn;
import org.jamocha.dn.memory.FactAddress;
import org.jamocha.dn.nodes.SlotInFactAddress;
import org.jamocha.filter.fwa.PredicateWithArguments;

/**
 * @author <NAME> <<EMAIL>>
 */
public class AddressFilter extends Filter<AddressFilter.AddressFilterElement> {

	public static AddressFilter empty = new AddressFilter(new HashSet<FactAddress>(),
			new HashSet<FactAddress>(), new AddressFilterElement[] {});

	@Getter
	protected final Set<FactAddress> positiveExistentialAddresses, negativeExistentialAddresses;

	public AddressFilter(final Set<FactAddress> positiveExistentialAddresses,
			final Set<FactAddress> negativeExistentialAddresses,
			final AddressFilterElement[] filterElements) {
		super(filterElements);
		this.positiveExistentialAddresses = positiveExistentialAddresses;
		this.negativeExistentialAddresses = negativeExistentialAddresses;
	}

	@Getter
	public static class AddressFilterElement extends Filter.FilterElement {
		final SlotInFactAddress addressesInTarget[];

		public AddressFilterElement(final PredicateWithArguments function,
				final SlotInFactAddress[] addressesInTarget) {
			super(function);
			this.addressesInTarget = addressesInTarget;
		}

		public CounterColumn getCounterColumn() {
			return null;
		}
	}

	public static class ExistentialAddressFilterElement extends AddressFilterElement {
		@Getter(onMethod = @_({ @Override }))<commit_msg>AddressFilter: added helper function for existential fact addresses<commit_after>/*
 * Copyright 2002-2014 The Jamocha Team
 * 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.jamocha.org/
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package org.jamocha.filter;

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

import lombok.Getter;

import org.jamocha.dn.memory.CounterColumn;
import org.jamocha.dn.memory.FactAddress;
import org.jamocha.dn.nodes.SlotInFactAddress;
import org.jamocha.filter.fwa.PredicateWithArguments;

/**
 * @author <NAME> <<EMAIL>>
 */
public class AddressFilter extends Filter<AddressFilter.AddressFilterElement> {

	public static AddressFilter empty = new AddressFilter(new HashSet<FactAddress>(),
			new HashSet<FactAddress>(), new AddressFilterElement[] {});

	@Getter
	protected final Set<FactAddress> positiveExistentialAddresses, negativeExistentialAddresses;

	/**
	 * Checks whether the FactAddress is existential by calling the contains method on both sets
	 * (positive and negative).
	 * 
	 * @param factAddress
	 *            the fact address to check
	 * @return true iff the fact address passed is contained in one of the existential fact address
	 *         sets
	 */
	public boolean isExistential(final FactAddress factAddress) {
		return positiveExistentialAddresses.contains(factAddress)
				|| negativeExistentialAddresses.contains(factAddress);
	}

	public AddressFilter(final Set<FactAddress> positiveExistentialAddresses,
			final Set<FactAddress> negativeExistentialAddresses,
			final AddressFilterElement[] filterElements) {
		super(filterElements);
		this.positiveExistentialAddresses = positiveExistentialAddresses;
		this.negativeExistentialAddresses = negativeExistentialAddresses;
	}

	@Getter
	public static class AddressFilterElement extends Filter.FilterElement {
		final SlotInFactAddress addressesInTarget[];

		public AddressFilterElement(final PredicateWithArguments function,
				final SlotInFactAddress[] addressesInTarget) {
			super(function);
			this.addressesInTarget = addressesInTarget;
		}

		public CounterColumn getCounterColumn() {
			return null;
		}
	}

	public static class ExistentialAddressFilterElement extends AddressFilterElement {
		@Getter(onMethod = @_({ @Override }))
{'fraction_non_alphanumeric': 0.07674708818635607, 'fraction_numerical': 0.004159733777038269, 'mean_word_length': 5.213178294573644, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5313169', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1257, 'n_words': 402}