def main(goldFile, predFile, outCSVFile, description, fieldName1, fieldValue1): (goldRoot, goldNodes) = evaluate.getCoarseGrainedTreeLabelsFile(goldFile) (predRoot, predNodes) = evaluate.getCoarseGrainedTreeLabelsFile(predFile) rootData = evaluate.printStatsCoarseInt(goldRoot, predRoot, prefix='root') nodeData = evaluate.printStatsCoarseInt(goldNodes, predNodes) nodeData.update(rootData) if description: nodeData = evaluate.ins(['Description'], [description], nodeData) if fieldName1 and fieldValue1: nodeData = evaluate.ins([fieldName1], [fieldValue1], nodeData) evaluate.statsToFile(nodeData, outCSVFile, delim=';')
def test_tree_reading(self): (root, node) = evaluate.getCoarseGrainedTreeLabelsFile( 'tests/ptb/small_treebank.ptb') expectedRoot = [NEU, NEG, NEU, NEU] expectedLabels = [NEU, NEG, POS, POS, POS, NEG, POS] expectedLabels += [NEG, NEU, POS, POS, POS, NEU, NEG] expectedLabels += [NEU, NEG, POS, POS, POS, NEG, POS] expectedLabels += [NEU, NEG, POS, POS, POS, NEG, POS] self.assertSequenceEqual(root, expectedRoot) self.assertSequenceEqual(node, expectedLabels)