Skip to content

Latest commit

 

History

History
87 lines (68 loc) · 3.03 KB

evaluation.md

File metadata and controls

87 lines (68 loc) · 3.03 KB

使用eval

我们提供了一个模块eval和一些测试样例test_examples/用于演示如何评测你的结果以及最终提交评测结果的文件格式。

文件格式

详细的文件格式可以参考目录test_examples/中的文件,prediction.json即最终提交的评测结果。

Track1和Track2类似,需要包括id(对应测试集中的id)、sentence(对应测试集中的sentence)和prediction表示你的预测结果。

其中,Track1的prediction包括rhetoricalform两个字段,分别表示修辞粗粒度分类和形式细粒度分类。Track2的prediction包括rhetoricalcontent两个字段,分别表示修辞粗粒度分类和内容细粒度分类。

请注意,如果该句包括多种修辞手法,需要全部在prediction字段中列出;如果该句不包括任何修辞手法,则prediction字段应当置空(null)。

下面是Track1的一个例子,Track2的例子请参考test_examples/track2/prediction.json

[
  {
    "id": 1,
    "sentence": "这是第一个测试样例,用于测试track1的评测。",
    "prediction": [
      {
        "rhetorical": "比喻",
        "form": "明喻"
      }
    ]
  },
  {
    "id": 2,
    "sentence": "这是第二个测试样例,用于测试track1的评测。",
    "prediction": null
  }
]

对于Track3,idsentence同上,prediction字段包括conjunctionBeginIdxconjunctionEndIdxtenorBeginIdxtenorEndIdxvehicleBeginIdxvehicleEndIdx六个字段,分别表示连接词的起始和结束位置、描写对象的起始和结束位置、描写内容的起始和结束位置。

请注意,如果该句包括多个修辞成分,需要全部在prediction字段中列出;如果该句不包括任何修辞成分,则prediction字段应当置空(null)。

[
  {
    "id": 1,
    "sentence": "这是第一个测试样例,用于测试track3的评测。",
    "prediction": [
      {
        "conjunctionBeginIdx": 1,
        "conjunctionEndIdx": 2,
        "tenorBeginIdx": null,
        "tenorEndIdx": null,
        "vehicleBeginIdx": 5,
        "vehicleEndIdx": 8
      }
    ]
  },
  {
    "id": 2,
    "sentence": "这是第二个测试样例,用于测试track3的评测。",
    "prediction": null
  }
]

eval使用方法

eval模块提供一个命令行工具来评测结果,使用方法如下:

python -m eval --track 1 --prediction test_examples/track1/prediction.json --truth test_examples/track1/ground_truth.json
  • --track参数指定评测任务的赛道,可选值为123
  • --prediction参数指定你的预测结果文件
  • --truth参数指定真实结果的文件

此外,eval也可以作为一个模块直接在代码中使用:

from eval.eval_track1 import EvaluateTrack1

prediction_file_path = 'test_examples/track1/prediction.json'
ground_truth_file_path = 'test_examples/track1/ground_truth.json'

evaluator = EvaluateTrack1(prediction_file_path, ground_truth_file_path)
f1 = evaluator.evaluate()