<commit_before>package org.atlasapi.equivalence;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;

import org.atlasapi.entity.Id;
import org.atlasapi.entity.Identifiable;
import org.atlasapi.entity.Identifiables;
import org.atlasapi.entity.ResourceRef;
import org.atlasapi.entity.Sourced;
import org.atlasapi.media.entity.Publisher;

import com.metabroadcast.common.collect.MoreSets;
import com.metabroadcast.common.stream.MoreCollectors;
import com.metabroadcast.common.time.DateTimeZones;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
import com.google.common.collect.Sets.SetView;
import org.joda.time.DateTime;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

/**
 * <p> Represents a set of equivalent resources and how they link together through an adjacency
 * list. </p>
 */
public final class EquivalenceGraph implements Identifiable {

    /**
     * <p> An entry in an equivalence adjacency list. A subject resource reference and sets of
     * references: <ul> <li><i>efferent</i> - resources asserted as equivalent to the subject.</li>
     * <li><i>afferent</i> - resources which asserted the subject as equivalent.</li> </p>
     */
    public static final class Adjacents implements Identifiable, Sourced {

        public static final Adjacents valueOf(ResourceRef subject) {
            ImmutableSet<ResourceRef> adjacents = ImmutableSet.of(subject);
            DateTime now = new DateTime(DateTimeZones.UTC);
            return new Adjacents(subject, now, adjacents, adjacents);
        }

        private final ResourceRef subject;
        private final DateTime created;
        private final ImmutableMap<Id, ResourceRef> efferent;
        private final ImmutableMap<Id, ResourceRef> afferent;

        public Adjacents(ResourceRef subject, DateTime created, Set<ResourceRef> efferent,
                Set<ResourceRef> afferent) {
            this.subject = checkNotNull(subject);
            this.created = checkNotNull(created);
            checkArgument(efferent.contains(subject));
            checkArgument(afferent.contains(subject));
            Map<Id, ResourceRef> efferentMap = new HashMap<>();
            for (ResourceRef resourceRef : efferent) {
                efferentMap.put(resourceRef.getId(), resourceRef);
            }
            this.efferent = ImmutableMap.copyOf(efferentMap);
            Map<Id, ResourceRef> afferentMap = new HashMap<>();
            for (ResourceRef resourceRef : afferent) {
                afferentMap.put(resourceRef.getId(), resourceRef);
            }
            this.afferent = ImmutableMap.copyOf(afferentMap);
        }
<commit_msg>Fixing checks<commit_after>package org.atlasapi.equivalence;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;

import org.atlasapi.entity.Id;
import org.atlasapi.entity.Identifiable;
import org.atlasapi.entity.Identifiables;
import org.atlasapi.entity.ResourceRef;
import org.atlasapi.entity.Sourced;
import org.atlasapi.media.entity.Publisher;

import com.metabroadcast.common.collect.MoreSets;
import com.metabroadcast.common.stream.MoreCollectors;
import com.metabroadcast.common.time.DateTimeZones;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
import com.google.common.collect.Sets.SetView;
import org.joda.time.DateTime;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

/**
 * <p> Represents a set of equivalent resources and how they link together through an adjacency
 * list. </p>
 */
public final class EquivalenceGraph implements Identifiable {

    /**
     * <p> An entry in an equivalence adjacency list. A subject resource reference and sets of
     * references: <ul> <li><i>efferent</i> - resources asserted as equivalent to the subject.</li>
     * <li><i>afferent</i> - resources which asserted the subject as equivalent.</li> </p>
     */
    public static final class Adjacents implements Identifiable, Sourced {

        public static final Adjacents valueOf(ResourceRef subject) {
            ImmutableSet<ResourceRef> adjacents = ImmutableSet.of(subject);
            DateTime now = new DateTime(DateTimeZones.UTC);
            return new Adjacents(subject, now, adjacents, adjacents);
        }

        private final ResourceRef subject;
        private final DateTime created;
        private final ImmutableMap<Id, ResourceRef> efferent;
        private final ImmutableMap<Id, ResourceRef> afferent;

        public Adjacents(ResourceRef subject, DateTime created, Set<ResourceRef> efferent,
                Set<ResourceRef> afferent) {
            this.subject = checkNotNull(subject);
            this.created = checkNotNull(created);
            Map<Id, ResourceRef> efferentMap = new HashMap<>();
            for (ResourceRef resourceRef : efferent) {
                efferentMap.put(resourceRef.getId(), resourceRef);
            }
            this.efferent = ImmutableMap.copyOf(efferentMap);
            Map<Id, ResourceRef> afferentMap = new HashMap<>();
            for (ResourceRef resourceRef : afferent) {
                afferentMap.put(resourceRef.getId(), resourceRef);
            }
            this.afferent = ImmutableMap.copyOf(afferentMap);
            checkArgument(this.efferent.containsKey(subject.getId()));
            checkArgument(this.afferent.containsKey(subject.getId()));
        }

{'fraction_non_alphanumeric': 0.0985093972780298, 'fraction_numerical': 0.0, 'mean_word_length': 3.4861918604651163, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, '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': '3141765', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1682, 'n_words': 399}