<commit_before>package solver.collections3;

import java.util.*;
import java.util.stream.Collectors;

public class Predicate {

    private final String name;
    private final int arity;
    private final List<List<String>> values;

    public static void main(String[] args) {
        Predicate node = new Predicate("node", 1);
        node.add("a");
        node.add("b");
        node.add("c");
        System.out.println(node);
        System.out.println(node.get("b"));
        System.out.println(node.get("X"));
        System.out.println();

        Predicate edge = new Predicate("edge", 3);
        edge.add("a", "b", "ab");
        edge.add("a", "c", "ac");
        edge.add("b", "c", "bc");
        System.out.println(edge);
        System.out.println();

        System.out.println(edge.get("a", "X", "E"));
        System.out.println(edge.get("N1", "N2", "E"));
        System.out.println(edge.get("X", "b", "ab"));
        System.out.println(edge.get("a", "c", "ac"));
        System.out.println();
    }

    public Predicate(String name, int arity) {
        this(name, arity, new ArrayList<>());
    }

    public Predicate(String name, int arity, List<List<String>> values) {
        assert arity > 0;
        this.name = name;
        this.arity = arity;
        this.values = values;
    }

    public String getName() {
        return name;
    }

    public int getArity() {
        return arity;
    }

    public void add(String... args) {
        add(Arrays.stream(args).collect(Collectors.toList()));
    }

    public void add(List<String> args) {
        assert args.size() == arity;
        values.add(args);
    }

    public void addAll(Collection<List<String>> argsCollection) {
        argsCollection.forEach(this::add);
    }

    public List<Map<String, String>> get(String... args) {
        return get(Arrays.stream(args).collect(Collectors.toList()));
    }

    public List<Map<String, String>> get(List<String> args) {
        assert args.size() == arity;
        return values.stream().filter(value -> {
            for (int i = 0; i < arity; i++) {
                String argTerm = args.get(i);
                String valueTerm = value.get(i);
                if (isAtom(argTerm) && !argTerm.equals(valueTerm)) {
                    return false;
                }
            }
            return true;
        }).map(value -> {
            Map<String, String> result = new LinkedHashMap<>(); // Insertion order
            for (int i = 0; i < arity; i++) {
                result.put(args.get(i), value.get(i));
            }
            return result;
        }).collect(Collectors.toList());
    }

    @Override
    public String toString() {
        return values.toString();
    }<commit_msg>Add comment about the implementation<commit_after>package solver.collections3;

import java.util.*;
import java.util.stream.Collectors;

public class Predicate {

    private final String name;
    private final int arity;
    private final List<List<String>> values;

    public static void main(String[] args) {
        Predicate node = new Predicate("node", 1);
        node.add("a");
        node.add("b");
        node.add("c");
        System.out.println(node);
        System.out.println(node.get("b"));
        System.out.println(node.get("X"));
        System.out.println();

        Predicate edge = new Predicate("edge", 3);
        edge.add("a", "b", "ab");
        edge.add("a", "c", "ac");
        edge.add("b", "c", "bc");
        System.out.println(edge);
        System.out.println();

        System.out.println(edge.get("a", "X", "E"));
        System.out.println(edge.get("N1", "N2", "E"));
        System.out.println(edge.get("X", "b", "ab"));
        System.out.println(edge.get("a", "c", "ac"));
        System.out.println();
    }

    public Predicate(String name, int arity) {
        this(name, arity, new ArrayList<>());
    }

    public Predicate(String name, int arity, List<List<String>> values) {
        assert arity > 0;
        this.name = name;
        this.arity = arity;
        this.values = values;
    }

    public String getName() {
        return name;
    }

    public int getArity() {
        return arity;
    }

    public void add(String... args) {
        add(Arrays.stream(args).collect(Collectors.toList()));
    }

    public void add(List<String> args) {
        assert args.size() == arity;
        values.add(args);
    }

    public void addAll(Collection<List<String>> argsCollection) {
        argsCollection.forEach(this::add);
    }

    public List<Map<String, String>> get(String... args) {
        return get(Arrays.stream(args).collect(Collectors.toList()));
    }

    public List<Map<String, String>> get(List<String> args) {
        assert args.size() == arity;
        return values.stream().filter(value -> {
            for (int i = 0; i < arity; i++) {
                String argTerm = args.get(i);
                String valueTerm = value.get(i);
                /*  Arg  - Value
                  Implemented cases:
                    Atom - Atom
                    Var  - Atom
                  Unimplemented cases:
                    Atom - Var
                    Var  - Var
                  Reasons:
                    The value of a graph can't be a variable
                */
                if (isAtom(argTerm) && !argTerm.equals(valueTerm)) {
                    return false;
                }
            }
            return true;
        }).map(value -> {
            Map<String, String> result = new LinkedHashMap<>(); // Insertion order
            for (int i = 0; i < arity; i++) {
                result.put(args.get(i), value.get(i));
            }
            return result;
        }).collect(Collectors.toList());
    }

    @Override
    public String toString() {
        return values.toString();
    }
{'fraction_non_alphanumeric': 0.15233373226192512, 'fraction_numerical': 0.002735510343648487, 'mean_word_length': 1.8803545051698671, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 39, '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': '6808816', 'n_tokens_mistral': 1767, 'n_tokens_neox': 1710, 'n_words': 394}