bins[binNum].append(n)

    for i, bin in enumerate(bins):
        if bin is None:
            bins[i] = []

    # Render
    print('Rendering webpages...')
    print('Rendering index...')
    outputFolder = params['outputFolder']

    if not os.path.exists(outputFolder):
        os.makedirs(outputFolder)
    with open(os.path.join(outputFolder, 'index.html'), 'w') as f:
        f.write(renderIndex(
            ir.getModelNames(params['models']), numCategories, bins))

    for i in range(numBins):
        if bins[i] is not None:
            print 'Rendering %s...' % names[i]
            outputSubFolder = os.path.join(outputFolder, names[i])
            idx = np.array(bins[i], dtype='int')
            inputTestSubset = inputTest[idx]
            targetTestSubset = targetTest[idx]
            modelOutputsSubset = []
            for j in range(numModels):
                modelOutputsSubset.append(modelOutputs[j][idx])
            if not os.path.exists(outputSubFolder):
                os.makedirs(outputSubFolder)
            htmlHyperLink = '%d.html'
            pages = ir.renderHtml(
示例#2
0
                        params['dataFolder'])

    # Render
    if not os.path.exists(params['outputFolder']):
        os.makedirs(params['outputFolder'])
    if params['format'] == 'html':
        print('Rendering HTML...')
        pages = ir.renderHtml(
                    inputTest,
                    targetTest,
                    data['questionIdict'],
                    data['ansIdict'],
                    urlDict,
                    topK=params['topK'],
                    modelOutputs=modelOutputs,
                    modelNames=ir.getModelNames(params['models']),
                    questionIds=idx)
        for i, page in enumerate(pages):
            with open(os.path.join(params['outputFolder'],
                '%s-%d.html' % (params['outputFilename'], i)), 'w') as f:
                f.write(page)
    elif params['format'] == 'latex':
        # For LaTeX only, replace underscore in vocabulary.
        data['questionIdict'] = ir.escapeLatexIdict(data['questionIdict'])
        data['ansIdict'] = ir.escapeLatexIdict(data['ansIdict'])
        ir.renderLatex(
                inputTest,
                targetTest,
                data['questionIdict'],
                data['ansIdict'],
                urlDict, 
            bins[binNum].append(n)

    for i, bin in enumerate(bins):
        if bin is None:
            bins[i] = []

    # Render
    print('Rendering webpages...')
    print('Rendering index...')
    outputFolder = params['outputFolder']

    if not os.path.exists(outputFolder):
        os.makedirs(outputFolder)
    with open(os.path.join(outputFolder, 'index.html'), 'w') as f:
        f.write(
            renderIndex(ir.getModelNames(params['models']), numCategories,
                        bins))

    for i in range(numBins):
        if bins[i] is not None:
            print 'Rendering %s...' % names[i]
            outputSubFolder = os.path.join(outputFolder, names[i])
            idx = np.array(bins[i], dtype='int')
            inputTestSubset = inputTest[idx]
            targetTestSubset = targetTest[idx]
            modelOutputsSubset = []
            for j in range(numModels):
                modelOutputsSubset.append(modelOutputs[j][idx])
            if not os.path.exists(outputSubFolder):
                os.makedirs(outputSubFolder)
            htmlHyperLink = '%d.html'