<commit_before>package org.ihtsdo.drools.helper;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ConceptHelper {
	
	public static boolean containsAnyConcept(List<String> conceptIdList, String... restrictConcepts){
		List<String> restrictList = new ArrayList<String>(Arrays.asList(restrictConcepts));		
		return conceptIdList.size() > 1 && conceptIdList.size() == restrictList.size() && conceptIdList.containsAll(restrictList);
	}
	
	public static boolean isMoreThanOneTopLevelHierarchy(List<String> conceptIdList, String... restrictConcepts){
		List<String> restrictList = new ArrayList<String>(Arrays.asList(restrictConcepts));
		
		if (conceptIdList.size() > 1) {
			if (conceptIdList.size() > restrictList.size()) {
				return true;
			} else if (conceptIdList.size() == restrictList.size()) {
				return !conceptIdList.containsAll(restrictList);
			} else {
				return false;
			}
		}
		
		return false;
	}
}<commit_msg>MAINT-938 Add utility method to check duplicate axioms<commit_after>package org.ihtsdo.drools.helper;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import org.ihtsdo.drools.domain.Concept;
import org.ihtsdo.drools.domain.Relationship;

public class ConceptHelper {
	
	public static boolean containsAnyConcept(List<String> conceptIdList, String... restrictConcepts){
		List<String> restrictList = new ArrayList<String>(Arrays.asList(restrictConcepts));		
		return conceptIdList.size() > 1 && conceptIdList.size() == restrictList.size() && conceptIdList.containsAll(restrictList);
	}
	
	public static boolean isMoreThanOneTopLevelHierarchy(List<String> conceptIdList, String... restrictConcepts){
		List<String> restrictList = new ArrayList<String>(Arrays.asList(restrictConcepts));
		
		if (conceptIdList.size() > 1) {
			if (conceptIdList.size() > restrictList.size()) {
				return true;
			} else if (conceptIdList.size() == restrictList.size()) {
				return !conceptIdList.containsAll(restrictList);
			} else {
				return false;
			}
		}
		
		return false;
	}

    public static boolean isAxiomEquivalent(Concept concept) {
        Map<String, List<Relationship>> axiomMap = new HashMap<>();
        concept.getRelationships().forEach(relationship -> {
            if (!relationship.isAxiomGCI()) {
                if (axiomMap.containsKey(relationship.getAxiomId())) {
                    axiomMap.get(relationship.getAxiomId()).add(relationship);
                } else {
                    List<Relationship> relationships = new ArrayList<>();
                    relationships.add(relationship);
                    axiomMap.put(relationship.getAxiomId(), relationships);
                }
            }
        });

        for (String key1 : axiomMap.keySet()) {
            for (String key2 : axiomMap.keySet()) {
                List<Relationship> relationships1 = axiomMap.get(key1);
                List<Relationship> relationships2 = axiomMap.get(key2);
                if (key1 != key2 && relationships1.size() == relationships2.size()) {
                    int count = 0;
                    for (Relationship relationship1 : relationships1) {
                        for (Relationship relationship2 : relationships2) {
                            //can not use 'equal' to compare 2 relationship objects as they always have different axiomId
                            if (relationship1.getTypeId() == relationship2.getTypeId()
                                    && relationship1.getDestinationId() == relationship2.getDestinationId()
                                    && relationship1.getRelationshipGroup() == relationship2.getRelationshipGroup()) {
                                count++;
                            }
                        }
                    }
                    if (count == relationships1.size()) {
                        return true;
                    }
                }
            }
        }

        return false;
    }
}
{'fraction_non_alphanumeric': 0.1099801390268123, 'fraction_numerical': 0.007447864945382324, 'mean_word_length': 2.4732758620689657, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6650500', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1074, 'n_words': 215}