コード例 #1
0
def print_option_matches(option, logfiles, print_text=True, print_matches=True):
    """
         >>> for option in [o for o in dir(Options.Options) if type(getattr(Options.Options,o)) == bool]:
         ...		print_option_matches(option, 'MarcoLogs/Statistics/Statistics-2007-03-18-02-49*.txt', False)
         """
    n = 4
    DefaultFiles =  lstail('MarcoLogs', re.compile('Follower-Results-%s-200.*-Col.txt'%'Default'), n)
    OptionFiles =  lstail('MarcoLogs', re.compile('Follower-Results-%s-200.*-Col.txt'%option), n)
    Sums = {'With' : 0, 'Without' : 0, 'All' : 0, 'Gains':0, 'Losses':0}
    Last = {}
    for instructID in get_option_matches(option, logfiles):
        instructID = instructID.strip()
        if print_matches: print instructID,
        Sums['All'] += 1
        for label, files in [('With',DefaultFiles),('Without',OptionFiles)]:
            pipe = os.popen('grep -c -h "%s\tSuccess" %s' %
                            (instructID, ' '.join(['MarcoLogs/'+f for f in files])))
            matches = pipe.read()
            pipe.close()
            successes = sum([int(m) for m in matches.split('\n') if m])
            Sums[label] += successes
            Last[label] = successes
            if print_matches: print label, option, successes, '\t',
        if print_matches: print
        if Last['With'] > Last['Without']: Sums['Gains'] +=1
        elif Last['With'] < Last['Without']: Sums['Losses'] +=1
        if print_text:
            match_file = open('Directions/CleanDirs/Cleaned-'+instructID)
            print match_file.read()
            match_file.close()
    n = float(n)
    print '\tTotals:', option, '\t with', Sums['With']/n, '\t without', Sums['Without']/n, 'of', Sums['All'],
    print '\t+'+str(Sums['Gains']),'-'+str(Sums['Losses'])
コード例 #2
0
ファイル: Sense.py プロジェクト: ronaldahmed/robot-navigation
def genUncorrContentFrames(Directors):
    import re

    Corpus = DirectionCorpusReader(constructItemRegexp(Directors, mapversions="[01]"))
    for filename in lstail("Directions/FullTrees", re.compile("^FullTree-.*.txt$")):
        try:
            genCorrContentFrame(filename, TreePath="FullTrees/")
        except ValueError:
            pass
コード例 #3
0
        (False, True): 0,
        (False, False): 0,
    }
    Discrepancy = {}
    RouteGroups = (('Followers', followerRoutes), ('Director', directorRoutes),
                   ('Marco', marcoRoutes))
    routeGenerator = generateRoutesFile

    for (Director, Map, Start, Target, Num) in routeGenerator():
        key = '%s_%s[01]_%s_%s_Dirs_%s.txt' % (Director, Map, Start, Target,
                                               Num)
        print key,
        Routes = []
        for Follower in Followers:
            for Directory in lstail(
                    'SubjectLogs',
                    re.compile(Follower + '_DirectionAll0_\d$')):
                Routes.append(
                    createRoute(Directory, Director, Map, Start, Target, Num,
                                followerRoutes))
        Routes = [route for route in Routes if route]
        if Routes:
            mode_term_place = mode([route.term_place for route in Routes], 3)
            try:
                mean_rating = pylab.mean(DirRtng(Routes))
                mean_navconf = pylab.mean(NavConf(Routes))
            except ZeroDivisionError:
                mean_rating = mean_navconf = 0.0
        for Directory in lstail(
                'SubjectLogs',
                re.compile('%s_Direction%s[01]_\d$' % (Director, Map))):