<commit_before># -*- coding: utf-8 -*-
#
# Copyright (c) 2017, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

"""Parser for Psi4 output files."""

import numpy

from cclib.parser import data
from cclib.parser import logfileparser
from cclib.parser import utils


class Psi4(logfileparser.Logfile):
    """A Psi4 log file."""

    def __init__(self, *args, **kwargs):

        # Call the __init__ method of the superclass
        super(Psi4, self).__init__(logname="Psi4", *args, **kwargs)

    # Match the number of skipped lines required based on the type
    # of gradient present (determined from the header), as
    # otherwise the parsing is identical.
    GRADIENT_HEADERS = {
        '-Total Gradient:': 'analytic',
        '## F-D gradient (Symmetry 0) ##': 'numerical',
    }
    GRADIENT_SKIP_LINES = {
        'analytic': ['header', 'dash header'],
        'numerical': ['Irrep num and total size', 'b', '123', 'b'],
    }

    def __str__(self):
        """Return a string representation of the object."""
        return "Psi4 log file %s" % (self.filename)

    def __repr__(self):
        """Return a representation of the object."""
        return 'Psi4("%s")' % (self.filename)

    def before_parsing(self):

        # Early beta versions of Psi4 normalize basis function
        # coefficients when printing.
        self.version_4_beta = False

        # This is just used to track which part of the output we are in for Psi4,
        # with changes triggered by ==> things like this <== (Psi3 does not have this)
        self.section = None

    def after_parsing(self):

        # Newer versions of Psi4 don't explicitly print the number of atoms.
        if not hasattr(self, 'natom'):
            if hasattr(self, 'atomnos'):
                self.set_attribute('natom', len(self.atomnos))

    def normalisesym(self, label):
        """Psi4 does not require normalizing symmetry labels."""
        return label

    def extract(self, inputfile, line):
        """Extract information from the file object inputfile."""
<commit_msg>Psi4: move class constants to before extract()<commit_after># -*- coding: utf-8 -*-
#
# Copyright (c) 2017, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

"""Parser for Psi4 output files."""

import numpy

from cclib.parser import data
from cclib.parser import logfileparser
from cclib.parser import utils


class Psi4(logfileparser.Logfile):
    """A Psi4 log file."""

    def __init__(self, *args, **kwargs):

        # Call the __init__ method of the superclass
        super(Psi4, self).__init__(logname="Psi4", *args, **kwargs)

    def __str__(self):
        """Return a string representation of the object."""
        return "Psi4 log file %s" % (self.filename)

    def __repr__(self):
        """Return a representation of the object."""
        return 'Psi4("%s")' % (self.filename)

    def before_parsing(self):

        # Early beta versions of Psi4 normalize basis function
        # coefficients when printing.
        self.version_4_beta = False

        # This is just used to track which part of the output we are in for Psi4,
        # with changes triggered by ==> things like this <== (Psi3 does not have this)
        self.section = None

    def after_parsing(self):

        # Newer versions of Psi4 don't explicitly print the number of atoms.
        if not hasattr(self, 'natom'):
            if hasattr(self, 'atomnos'):
                self.set_attribute('natom', len(self.atomnos))

    def normalisesym(self, label):
        """Psi4 does not require normalizing symmetry labels."""
        return label

    # Match the number of skipped lines required based on the type
    # of gradient present (determined from the header), as
    # otherwise the parsing is identical.
    GRADIENT_HEADERS = {
        '-Total Gradient:': 'analytic',
        '## F-D gradient (Symmetry 0) ##': 'numerical',
    }
    GRADIENT_SKIP_LINES = {
        'analytic': ['header', 'dash header'],
        'numerical': ['Irrep num and total size', 'b', '123', 'b'],
    }

    def extract(self, inputfile, line):
        """Extract information from the file object inputfile."""

{'fraction_non_alphanumeric': 0.11300345224395858, 'fraction_numerical': 0.010817031070195627, 'mean_word_length': 2.8089395267309376, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7289017', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1233, 'n_words': 468}