runCRescal.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:sictf 作者: malllabiisc 项目源码 文件源码
def RelationReport(Tensor,RelationTensor,matrixA,dictIndextoVP,dictVPtoIndex,lambdaFolderName,runDir,num_cores_for_fit_computation):
    numVP = len(RelationTensor)
    # dummy code to help parallelize
    RelIndexFitReport = [] # List of index to fit, indices to be sorted based on fit [(verbPhrase, relNum, tensorSliceNorm, normResidueSlice, Fit), tuples]
    # for relIndex in range(0,numVP):
    #   verbPhrase,relNum,tensorSliceNorm, normResidueSlice, Fit = computeSliceFit(Tensor[relIndex],RelationTensor[relIndex],matrixA,dictIndextoVP,relIndex)
    #   RelIndexFitReport.append((verbPhrase,relNum,tensorSliceNorm, normResidueSlice, Fit))
    RelIndexFitReport = Parallel(n_jobs=num_cores_for_rescal, verbose=1)(delayed(cheaplyComputeSliceFit)(Tensor[relIndex],RelationTensor[relIndex],matrixA,dictIndextoVP,dictIndextoNP,relIndex) for relIndex in range(0,numVP))
    RelIndexFitReport.sort(key = lambda x:x[4],reverse=True) # sort based on fit of relations
    # print(RelIndexFitReport) # check whether sorted.
    # print('Printing Path')
    # print(os.path.join(lambdaFolderName,runDir,'RelationReport.txt'))
    # Writing old relation Report to a file
    RelationReportHandle = open(os.path.join(os.getcwd(),lambdaFolderName,runDir,'RelationReport.txt'),'w')
    for lineInfo in RelIndexFitReport:
        line = 'Relation: '+ str(lineInfo[0])+'\t' +' Relation Number: '+ str(lineInfo[1])+'\t' +' sliceNorm: '+str(lineInfo[2])+'\t' +'errorNorm: '+str(lineInfo[3])+'\t'+' SlicewiseFit: '+str(lineInfo[4])+'\n'
        print(line)
        RelationReportHandle.write(line)
    RelationReportHandle.close()
    return RelIndexFitReport
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号