Commit 2d2f3a5a authored by linpeiqin's avatar linpeiqin

修改评估详细结果

parent 69a41e43
......@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.github.pagehelper.page.PageMethod;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yice.common.core.annotation.MyRequestBody;
......@@ -206,18 +207,23 @@ public class ModelEstimateController {
Set<Long> datasetVersionIds = Arrays.stream(modelEstimate.getDatasetVersionIds().split(",")).mapToLong(Long::parseLong).boxed().collect(Collectors.toSet());
List<DatasetVersion> datasetVersions = datasetVersionService.getInList(datasetVersionIds);
List<String> dataList = new ArrayList<>();
int i = 0;
String url = this.pythonConfig.getModelEstimateFileBaseDir() + modelVersion.getVersionName() + File.separator + "evl_" + taskId + File.separator + "generated_predictions.jsonl";
log.info(url+"------------------------------------------------");
//获取评估输出详情
List<JSONObject> jsonObjects = this.getFileJsonArray(url);
ObjectMapper objectMapper = new ObjectMapper();
ArrayNode arrayNode = objectMapper.createArrayNode();
for (DatasetVersion datasetVersion : datasetVersions) {
ArrayNode arrayNode = (ArrayNode) new ObjectMapper().readTree(new File(datasetVersion.getFileUrl())); // 读取JSON文件内容并转换为ArrayNode对象
for (JSONObject jsonNode : jsonObjects) { // 遍历JSON数组并取出每个元素(ObjectNode)中的数据
jsonNode.put("datasetName",datasetVersion.getVersionName());
jsonNode.put("input", arrayNode.get(i).get("instruction").textValue() + arrayNode.get(i).get("input").textValue());
dataList.add(jsonNode.toJSONString());
i++;
arrayNode.addAll((ArrayNode) objectMapper.readTree(new File(datasetVersion.getFileUrl()))); // 读取JSON文件内容并转换为ArrayNode对象
}
int i = 0;
int j = 0;
for (JSONObject jsonNode : jsonObjects) { // 遍历JSON数组并取出每个元素(ObjectNode)中的数据
jsonNode.put("datasetName",datasetVersions.get(j).getVersionName());
jsonNode.put("input", arrayNode.get(i).get("instruction").textValue() + arrayNode.get(i).get("input").textValue());
dataList.add(jsonNode.toJSONString());
i++;
if (i == datasetVersions.get(j).getDataVolume()) {
j++;
}
}
int total = dataList.size(); // 获取总数据量
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment