<commit_before># 
# Copyright (C) 2008, <NAME>
# 
#http://rl-glue-ext.googlecode.com/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import sys

from rlglue.utils import TaskSpecVRLGLUE3
from glue_test import glue_test
tester =glue_test("test_taskspec")

def processTaskSpec(ts):
# you can cut the taskspec by the main words with new line
#ts= """VERSION RL-Glue-3.0 PROBLEMTYPE episodic DISCOUNTFACTOR 1 OBSERVATIONS INTS (3 0 1) DOUBLES (2 -1.2 0.5) (-.07 .07) CHARCOUNT 1024
#     ACTIONS INTS (2 0 4) CHARCOUNT 1024 REWARDS (-5.0 UNSPEC) EXTRA some other stuff goes here"""
	print ts
	print
	print
	TaskSpec = TaskSpecVRLGLUE3.TaskSpecParser(ts)
	print "Version: ["+TaskSpec.getVersion()+"]"
	print "ProblemType: ["+TaskSpec.getProblemType()+"]"
	print "DiscountFactor: ["+TaskSpec.getDiscountFactor()+"]"
	print "======================================================================================================="
	print "\t \t \t \t Observations"
	print "======================================================================================================="
	#print "Observations: ["+TaskSpec.getObservations()+"]"
	print "Integers:",TaskSpec.getIntObservations()
	print "Doubles: ",TaskSpec.getDoubleObservations()
	print "Chars:   ",TaskSpec.getCharCountObservations()
	print "======================================================================================================="
	print "======================================================================================================="
	print "\t \t \t \t Actions"
	print "======================================================================================================"
	#print "Observations: ["+TaskSpec.getActions()+"]"
	print "Integers:",TaskSpec.getIntActions()
	print "Doubles: ",TaskSpec.getDoubleActions()
	print "Chars:   ",TaskSpec.getCharCountActions()
	print "======================================================================================================="
	#print "Actions: ["+TaskSpec.getActions()+"]"
	#print "Reward :["+TaskSpec.getReward()+"]")
	print "Extra: ["+TaskSpec.getExtra()+"]"
	print "Reward Range:",TaskSpec.getRewardRange()


f=open('sample_task_specs.txt', 'r')

for ts in f:
      processTaskSpec(ts)

f.close()

# task_spec=RLGlue.RL_init();
# 
# RLGlue.RL_start();
# 
# roat=RLGlue.RL_step();
# 
# 
# 
# tester.check_fail(len(roat.o.intArray)!=1);
# tester.check_fail(len(roat.o. doubleArray)!=0);
# tester.check_fail(len(roat.o. charArray)!=0);
# tester.check_fail(roat.o.intArray[0]!=0);
# tester.check_fail("one|1.|one"!=RLGlue.RL_env_message("one"));
# tester.check_fail("one|1.|one"!=RLGlue.RL_agent_message("one"));
# 
# tester.check_fail(roat.terminal!=0);
# 
# 
# roat=RLGlue.RL_step();
# 
# tester.check_fail("two|2.2.|two"!=RLGlue.RL_env_message("two"));
# tester.check_fail("two|2.2.|two"!=RLGlue.RL_agent_message("two"));
# tester.check_fail(roat.terminal!=0);
# tester.check_fail(len(roat.o.intArray)!=1);
# tester.check_fail(len(roat.o. doubleArray)!=0);
# tester.check_fail(len(roat.o. charArray)!=0);
# tester.check_fail(roat.o.intArray[0]!=1);
# 
# roat=RLGlue.RL_step();
# 
# tester.check_fail("three||three"!=RLGlue.RL_env_message("three"));
# tester.check_fail("three||three"!=RLGlue.RL_agent_message("three"));
# tester.check_fail(roat.terminal!=0);
# tester.check_fail(len(roat.o.intArray)!=1);
# tester.check_fail(len(roat.o. doubleArray)!=0);
# tester.check_fail(len(roat.o. charArray)!=0);	
# tester.check_fail(roat.o.intArray[0]!=2);
# 
# roat=RLGlue.RL_step();
# tester.check_fail("four|4.|four"!=RLGlue.RL_env_message("four"));
# tester.check_fail("four|4.|four"!=RLGlue.RL_agent_message("four"));<commit_msg>some improvements to the testing function<commit_after># 
# Copyright (C) 2008, <NAME>
# 
#http://rl-glue-ext.googlecode.com/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Last modifed 22-1-2009 by <NAME>.
# Improving the test processTaskSpec 

import sys

from rlglue.utils import TaskSpecVRLGLUE3
from glue_test import glue_test
tester =glue_test("test_taskspec")

def processTaskSpec(ts):
# you can cut the taskspec by the main words with new line
#ts= """VERSION RL-Glue-3.0 PROBLEMTYPE episodic DISCOUNTFACTOR 1 OBSERVATIONS INTS (3 0 1) DOUBLES (2 -1.2 0.5) (-.07 .07) CHARCOUNT 1024
#     ACTIONS INTS (2 0 4) CHARCOUNT 1024 REWARDS (-5.0 UNSPEC) EXTRA some other stuff goes here"""
        print ts
        print
        print
        TaskSpec = TaskSpecVRLGLUE3.TaskSpecParser(ts)
        if TaskSpec.valid:                
                print "======================================================================================================="
                print "Version: ["+TaskSpec.getVersion()+"]"
                print "ProblemType: ["+TaskSpec.getProblemType()+"]"
                print "DiscountFactor: ["+TaskSpec.getDiscountFactor()+"]"
                print "======================================================================================================="
                print "\t \t \t \t Observations"
                print "======================================================================================================="
                #print "Observations: ["+TaskSpec.getObservations()+"]"
                print "Integers:",TaskSpec.getIntObservations()
                print "Doubles: ",TaskSpec.getDoubleObservations()
                print "Chars:   ",TaskSpec.getCharCountObservations()
                print "======================================================================================================="
                print "\t \t \t \t Actions"
                print "======================================================================================================"
                #print "Actions: ["+TaskSpec.getActions()+"]"
                print "Integers:",TaskSpec.getIntActions()
                print "Doubles: ",TaskSpec.getDoubleActions()
                print "Chars:   ",TaskSpec.getCharCountActions()
                print "======================================================================================================="        
                #print "Reward :["+TaskSpec.getReward()+"]")
                print "Reward Range:",TaskSpec.getRewardRange()
                print "Extra: ["+TaskSpec.getExtra()+"]"
                print "remeber that by using len() you get the cardinality of lists!"
                print "Thus:"
                print "len(",TaskSpec.getDoubleObservations(),") ==> ",len(TaskSpec.getDoubleObservations())," Double Observations"



f=open('sample_task_specs.txt', 'r')

for ts in f:
                processTaskSpec(ts)

f.close()

# task_spec=RLGlue.RL_init();
# 
# RLGlue.RL_start();
# 
# roat=RLGlue.RL_step();
# 
# 
# 
# tester.check_fail(len(roat.o.intArray)!=1);
# tester.check_fail(len(roat.o. doubleArray)!=0);
# tester.check_fail(len(roat.o. charArray)!=0);
# tester.check_fail(roat.o.intArray[0]!=0);
# tester.check_fail("one|1.|one"!=RLGlue.RL_env_message("one"));
# tester.check_fail("one|1.|one"!=RLGlue.RL_agent_message("one"));
# 
# tester.check_fail(roat.terminal!=0);
# 
# 
# roat=RLGlue.RL_step();
# 
# tester.check_fail("two|2.2.|two"!=RLGlue.RL_env_message("two"));
# tester.check_fail("two|2.2.|two"!=RLGlue.RL_agent_message("two"));
# tester.check_fail(roat.terminal!=0);
# tester.check_fail(len(roat.o.intArray)!=1);
# tester.check_fail(len(roat.o. doubleArray)!=0);
# tester.check_fail(len(roat.o. charArray)!=0);
# tester.check_fail(roat.o.intArray[0]!=1);
# 
# roat=RLGlue.RL_step();
# 
# tester.check_fail("three||three"!=RLGlue.RL_env_message("three"));
# tester.check_fail("three||three"!=RLGlue.RL_agent_message("three"));
# tester.check_fail(roat.terminal!=0);
# tester.check_fail(len(roat.o.intArray)!=1);
# tester.check_fail(len(roat.o. doubleArray)!=0);
# tester.check_fail(len(roat.o. charArray)!=0); 
# tester.check_fail(roat.o.intArray[0]!=2);
# 
# roat=RLGlue.RL_step();
# tester.check_fail("four|4.|four"!=RLGlue.RL_env_message("four"));
# tester.check_fail("four|4.|four"!=RLGlue.RL_agent_message("four"));
{'fraction_non_alphanumeric': 0.27877379371403277, 'fraction_numerical': 0.014940239043824702, 'mean_word_length': 4.929790026246719, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2006496', 'n_tokens_mistral': 3044, 'n_tokens_neox': 2805, 'n_words': 543}