Back to SDS/2 Parametric Scripts

 

fname = r'H:\TEMP\temsys\atom_trace.txt'

 

def atomtraceParse(fn):

    fileList = [x[x.find(")', ")+4:].replace(', aspect', '').strip() for x in open(fn).readlines()]

    dd = {}

    cnt = 0

    for item in fileList:

        itemList = item.split('), ')

        a = itemList[0].split('(')

        a1 = a[1].split(', ')

        rangeList = [eval(x.strip('[]()').split('(')[1].replace('unknown', 'False').replace('true', 'True')) for x in itemList[1:]]

        dd['rec'+str(cnt)]=dict(seed=a[0], agent=a1[0], value=float(a1[1]), ranges=[x for x in rangeList])

        cnt += 1

    return dd

 

dataDict = atomtraceParse(fname)

 

keys = dataDict.keys()

keys.sort()

for key in keys:

    for item in dataDict[key]:

        print '%s: %s = %s' % (key, item, dataDict[key][item])

 

 

for key in dd:

    print '%s = %s' % (key, dataDict[key])       

       

''' Data file

atom_trace('emotion_response_level(a1, 1.56072)', emotion_response_level(a1, 1.56072), [range(49, 50, true), range(0, 49, unknown)])

atom_trace('emotion_response_level(a2, 1.81894)', emotion_response_level(a2, 1.81894), [range(49, 50, true), range(0, 49, unknown)])

atom_trace('emotion_response_level(a3, 1.51193)', emotion_response_level(a3, 1.51193), [range(49, 50, true), range(0, 49, unknown)])

atom_trace('emotion_response_level(a1, 1.85)', emotion_response_level(a1, 1.85), [range(1, 50, unknown), range(0, 1, true)])

atom_trace('emotion_response_level(a2, 1.2)', emotion_response_level(a2, 1.2), [range(1, 50, unknown), range(0, 1, true)])

atom_trace('emotion_response_level(a3, 0.7)', emotion_response_level(a3, 0.7), [range(1, 50, unknown), range(0, 1, true)])

atom_trace('emotion_response_level(a1, 1.84775)', emotion_response_level(a1, 1.84775), [range(2, 50, unknown), range(1, 2, true), range(0, 1, unknown)])

atom_trace('emotion_response_level(a2, 1.39275)', emotion_response_level(a2, 1.39275), [range(2, 50, unknown), range(1, 2, true), range(0, 1, unknown)])

atom_trace('emotion_response_level(a3, 1.04275)', emotion_response_level(a3, 1.04275), [range(2, 50, unknown), range(1, 2, true), range(0, 1, unknown)])

atom_trace('has_emotional_value(a1, aspect, 1.8)', has_emotional_value(a1, aspect, 1.8), [range(3, 50, unknown), range(0, 3, true)])

atom_trace('has_emotional_value(a3, aspect, 1.8)', has_emotional_value(a3, aspect, 1.8), [range(3, 50, unknown), range(0, 3, true)])

'''

''' Output

>>> rec0: ranges = [(49, 50, True), (0, 49, False)]

rec0: seed = emotion_response_level

rec0: value = 1.56072

rec0: agent = a1

rec1: ranges = [(49, 50, True), (0, 49, False)]

rec1: seed = emotion_response_level

rec1: value = 1.81894

rec1: agent = a2

rec10: ranges = [(3, 50, False), (0, 3, True)]

rec10: seed = has_emotional_value

rec10: value = 1.8

rec10: agent = a3

rec2: ranges = [(49, 50, True), (0, 49, False)]

rec2: seed = emotion_response_level

rec2: value = 1.51193

rec2: agent = a3

rec3: ranges = [(1, 50, False), (0, 1, True)]

rec3: seed = emotion_response_level

rec3: value = 1.85

rec3: agent = a1

rec4: ranges = [(1, 50, False), (0, 1, True)]

rec4: seed = emotion_response_level

rec4: value = 1.2

rec4: agent = a2

rec5: ranges = [(1, 50, False), (0, 1, True)]

rec5: seed = emotion_response_level

rec5: value = 0.7

rec5: agent = a3

rec6: ranges = [(2, 50, False), (1, 2, True), (0, 1, False)]

rec6: seed = emotion_response_level

rec6: value = 1.84775

rec6: agent = a1

rec7: ranges = [(2, 50, False), (1, 2, True), (0, 1, False)]

rec7: seed = emotion_response_level

rec7: value = 1.39275

rec7: agent = a2

rec8: ranges = [(2, 50, False), (1, 2, True), (0, 1, False)]

rec8: seed = emotion_response_level

rec8: value = 1.04275

rec8: agent = a3

rec9: ranges = [(3, 50, False), (0, 3, True)]

rec9: seed = has_emotional_value

rec9: value = 1.8

rec9: agent = a1

rec10 = {'ranges': [(3, 50, False), (0, 3, True)], 'seed': 'has_emotional_value', 'value': 1.8, 'agent': 'a3'}

rec8 = {'ranges': [(2, 50, False), (1, 2, True), (0, 1, False)], 'seed': 'emotion_response_level', 'value': 1.0427500000000001, 'agent': 'a3'}

rec9 = {'ranges': [(3, 50, False), (0, 3, True)], 'seed': 'has_emotional_value', 'value': 1.8, 'agent': 'a1'}

rec2 = {'ranges': [(49, 50, True), (0, 49, False)], 'seed': 'emotion_response_level', 'value': 1.51193, 'agent': 'a3'}

rec3 = {'ranges': [(1, 50, False), (0, 1, True)], 'seed': 'emotion_response_level', 'value': 1.8500000000000001, 'agent': 'a1'}

rec0 = {'ranges': [(49, 50, True), (0, 49, False)], 'seed': 'emotion_response_level', 'value': 1.5607200000000001, 'agent': 'a1'}

rec1 = {'ranges': [(49, 50, True), (0, 49, False)], 'seed': 'emotion_response_level', 'value': 1.81894, 'agent': 'a2'}

rec6 = {'ranges': [(2, 50, False), (1, 2, True), (0, 1, False)], 'seed': 'emotion_response_level', 'value': 1.84775, 'agent': 'a1'}

rec7 = {'ranges': [(2, 50, False), (1, 2, True), (0, 1, False)], 'seed': 'emotion_response_level', 'value': 1.3927499999999999, 'agent': 'a2'}

rec4 = {'ranges': [(1, 50, False), (0, 1, True)], 'seed': 'emotion_response_level', 'value': 1.2, 'agent': 'a2'}

rec5 = {'ranges': [(1, 50, False), (0, 1, True)], 'seed': 'emotion_response_level', 'value': 0.69999999999999996, 'agent': 'a3'}

>>>

'''