<commit_before>import re


class qasm_loader:

    """
    QASM File Loder
    """

    # Description of lines that should be replace one or multiple lines.
    _replacements = {
        "init_all": {
            "start": ".c{counter}",
            "qloop": "prepz q{qubit}"
        },
        "RO": {
            "qloop": "measure q{qubit}"
        },
        "(x|X)180 q[0-9]+": 'rx180 q{qubit}',
        "(x|X)90 q[0-9]+": 'rx90 q{qubit}',
        "(y|Y)180 q[0-9]+": 'ry180 q{qubit}',
        "(y|Y)90 q[0-9]+": 'ry90 q{qubit}',

    }
    _circuit_counter = 0

    def __init__(self, file_name, qubits=2):
        # print("[+] pyqx : qasm_loader : loading file '%s' ..." % file_name)
        self.qubits = qubits
        with open(file_name) as f:
            file_lines = f.readlines()
        # lines pre-processing
        self.lines = []

        for i in range(0, len(file_lines)):
            file_lines[i] = file_lines[i].strip()
            # remove empty lines
            if len(file_lines[i]) == 0:
                continue
            self.lines.append(file_lines[i])
            c = file_lines[i].find("#")                     # remove comments
            if c != -1:
                self.lines[-1] = file_lines[:c]

            # replace line if line matches _replacement
            replacement_lines = self.replaceLine(file_lines[i])
            if replacement_lines:
                self.lines[-1:] = replacement_lines

    def load_circuits(self):
        n = len(self.lines)
        # print("[+] lines : ", n)
        i = 0
        self.circuits = []

        # load circuits
        while i < n:
            l = self.lines[i]
            i = i + 1
            if len(l) == 0:
                continue
            if l[0] != '.':
                continue
            # process a new subcircuit
            l = l.replace(" ", "")
            # print("[+] new circuit : ",l);
            cn = l[1:]  # circuit name
            # cr = ""     # circuit
            cr = []     # circuit
            # p = [cn,""]<commit_msg>the | operations is now suported by the qasm_loader<commit_after>import re


class qasm_loader:

    """
    QASM File Loder
    """

    # Description of lines that should be replace one or multiple lines.
    _replacements = {
        "init_all": {
            "start": ".c{counter}",
            "qloop": "prepz q{qubit}"
        },
        "RO": {
            "qloop": "measure q{qubit}"
        },
        "(x|X)180 q[0-9]+": 'rx180 q{qubit}',
        "(x|X)90 q[0-9]+": 'rx90 q{qubit}',
        "(y|Y)180 q[0-9]+": 'ry180 q{qubit}',
        "(y|Y)90 q[0-9]+": 'ry90 q{qubit}',

    }
    _circuit_counter = 0

    def __init__(self, file_name, qubits=2):
        # print("[+] pyqx : qasm_loader : loading file '%s' ..." % file_name)
        self.qubits = qubits
        with open(file_name) as f:
            file_lines = f.readlines()
        # lines pre-processing
        self.lines = []

        for i in range(0, len(file_lines)):
            file_lines[i] = file_lines[i].strip()
            # remove empty lines
            if len(file_lines[i]) == 0:
                continue
            seperated_file_lines = file_lines[i].split("|")
            for line in seperated_file_lines:
                line = line.strip()
                self.lines.append(line)
                c = line.find("#")              # remove comments
                if c != -1:
                    self.lines[-1] = line[:c]

                # replace line if line matches _replacement
                replacement_lines = self.replaceLine(line)
                if replacement_lines:
                    self.lines[-1:] = replacement_lines

    def load_circuits(self):
        n = len(self.lines)
        # print("[+] lines : ", n)
        i = 0
        self.circuits = []

        # load circuits
        while i < n:
            l = self.lines[i]
            i = i + 1
            if len(l) == 0:
                continue
            if l[0] != '.':
                continue
            # process a new subcircuit
            l = l.replace(" ", "")
            # print("[+] new circuit : ",l);
            cn = l[1:]  # circuit name
            # cr = ""     # circuit
            cr = []     # circuit
            # p = [cn,""]
{'fraction_non_alphanumeric': 0.14242139840450493, 'fraction_numerical': 0.018770530267480056, 'mean_word_length': 1.400337837837838, 'pattern_counts': {'":': 18, '<': 5, '<?xml version=': 0, '>': 3, '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': '4626996', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1311, 'n_words': 318}