~dhuggins/pycmusphinx/trunk

« back to all changes in this revision

Viewing changes to cmusphinx/evaluation.py

  • Committer: David Huggins-Daines
  • Date: 2011-01-20 03:47:09 UTC
  • Revision ID: dhuggins@cs.cmu.edu-20110120034709-yzwakriycq89d7qo
get times for separate search passes

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
output of the batch mode decoder and performing evaluation tasks.
11
11
"""
12
12
 
 
13
from collections import defaultdict
13
14
import re
14
15
import os
15
16
 
141
142
    x = []
142
143
    y = []
143
144
    for f in logfiles:
 
145
        fileid = xtransform(f)
144
146
        for spam in file(f):
145
147
            m = xrtre.match(spam)
146
148
            if m:
147
 
                x.append(xtransform(f))
 
149
                x.append(fileid)
148
150
                y.append((float(m.group(1)), float(m.group(2))))
149
151
                break
150
152
    return x, y
151
153
 
 
154
pxrtre = re.compile(r".*TOTAL (\S+) (\d+\.\d+) wall (\d+\.\d+) xRT")
 
155
def get_pass_xrts(logfiles, xtransform=os.path.basename):
 
156
    """
 
157
    Retrieve realtime factors for search passes from a sequence of
 
158
    multisphinx log files.
 
159
 
 
160
    Returns a dictionary of pass names mapped to a list of
 
161
    (fileid,wall) tuples for times
 
162
    """
 
163
    d = defaultdict(list)
 
164
    for f in logfiles:
 
165
        fileid = xtransform(f)
 
166
        for spam in file(f):
 
167
            m = pxrtre.match(spam)
 
168
            if m:
 
169
                pname, ptime, pxrt = m.groups()
 
170
                d[pname].append((fileid, float(pxrt)))
 
171
    return d
 
172
 
152
173
timere = re.compile(r".*TOTAL.* (\d+\.\d+) seconds CPU, (\d+\.\d+) seconds wall")
153
174
def get_times(logfiles, xtransform=os.path.basename):
154
175
    """