<commit_before>"""
Name:        eLCS_Run.py
Authors:     <NAME> - Written at Dartmouth College, Hanover, NH, USA
Contact:     <EMAIL>
Created:     November 1, 2013
Description: To run e-LCS, run this module.  A properly formatted configuration file, including all run parameters must be included with the path to that 
             file given below.  In this example, the configuration file has been included locally, so only the file name is required.
             
---------------------------------------------------------------------------------------------------------------------------------------------------------
eLCS: Educational Learning Classifier System - A basic LCS coded for educational purposes.  This LCS algorithm uses supervised learning, and thus is most 
similar to "UCS", an LCS algorithm published by <NAME> and <NAME> (2003) which in turn is based heavily on "XCS", an LCS 
algorithm published by <NAME> (1995).  

Copyright (C) 2013 <NAME> 
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the 
Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABLILITY 
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, 
Inc., 51 Franklin Street, Fifth F   loor, Boston, MA 02110-1301 USA
---------------------------------------------------------------------------------------------------------------------------------------------------------
"""

# Import Required Modules------------------------------------
from eLCS.Timer import Timer
from eLCS.ConfigParser import ConfigParser
from eLCS.OfflineEnvironment import OfflineEnvironment
from eLCS.Algorithm import eLCS
from eLCS.Constants import cons

# -----------------------------------------------------------


if __name__ == "__main__":
    helpstr = """Failed attempt to run e-LCS.  Please ensure that a configuration file giving all run parameters has been specified."""

    # Specify the name and file path for the configuration file.
    configurationFile = "config.txt"

    # Obtain all run parameters from the configuration file and store them in the 'Constants' module.
    ConfigParser(configurationFile)

    # Initialize the 'Timer' module which tracks the run time of algorithm and it's different components.
    timer = Timer()
    cons.referenceTimer(timer)

    # Initialize the 'Environment' module which manages the data presented to the algorithm.  While e-LCS learns iteratively (one inistance at a time
    env = OfflineEnvironment()
    cons.referenceEnv(env)  # Passes the environment to 'Constants' (cons) so that it can be easily accessed from anywhere within the code.
    cons.parseIterations()  # Identify the maximum number of learning iterations as well as evaluation checkpoints.

    # Run the e-LCS algorithm.
    eLCS()
<commit_msg>Removed ConfigParser class, load config parameters from yaml file<commit_after>"""
Name:        eLCS_Run.py
Authors:     <NAME> - Written at Dartmouth College, Hanover, NH, USA
Contact:     <EMAIL>
Created:     November 1, 2013
Description: To run e-LCS, run this module.  A properly formatted configuration file, including all run parameters must be included with the path to that 
             file given below.  In this example, the configuration file has been included locally, so only the file name is required.
             
---------------------------------------------------------------------------------------------------------------------------------------------------------
eLCS: Educational Learning Classifier System - A basic LCS coded for educational purposes.  This LCS algorithm uses supervised learning, and thus is most 
similar to "UCS", an LCS algorithm published by <NAME> and <NAME> (2003) which in turn is based heavily on "XCS", an LCS 
algorithm published by <NAME> (1995).  

Copyright (C) 2013 <NAME> 
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the 
Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABLILITY 
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, 
Inc., 51 Franklin Street, Fifth F   loor, Boston, MA 02110-1301 USA
---------------------------------------------------------------------------------------------------------------------------------------------------------
"""

# Import Required Modules------------------------------------
from eLCS.Timer import Timer
from eLCS.OfflineEnvironment import OfflineEnvironment
from eLCS.Algorithm import eLCS
from eLCS.Constants import cons

# -----------------------------------------------------------


if __name__ == "__main__":
    helpstr = """Failed attempt to run e-LCS.  Please ensure that a configuration file giving all run parameters has been specified."""

    # Specify the name and file path for the configuration file.
    config_txt = "config.yaml"

    # Obtain all run parameters from the configuration file and store them in the 'Constants' module.
    cons.setConstants(config_txt)

    # Initialize the 'Timer' module which tracks the run time of algorithm and it's different components.
    timer = Timer()
    cons.referenceTimer(timer)

    # Initialize the 'Environment' module which manages the data presented to the algorithm.  While e-LCS learns iteratively (one inistance at a time
    env = OfflineEnvironment()
    cons.referenceEnv(env)  # Passes the environment to 'Constants' (cons) so that it can be easily accessed from anywhere within the code.
    cons.parseIterations()  # Identify the maximum number of learning iterations as well as evaluation checkpoints.

    # Run the e-LCS algorithm.
    eLCS()

{'fraction_non_alphanumeric': 0.17286858219500706, 'fraction_numerical': 0.009106610142879572, 'mean_word_length': 2.2750642673521853, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 15, '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': '147702', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1386, 'n_words': 764}