|
@@ -10,6 +10,9 @@ import java.util.regex.Pattern;
|
|
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.jsoup.Jsoup;
|
|
|
+import org.jsoup.nodes.Document;
|
|
|
+import org.jsoup.select.Elements;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -93,7 +96,7 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
|
getDecimalPlaces(request.getTotalScore()));
|
|
|
int stepCount = request.getStandardAnswer().size();
|
|
|
String scoreStr = null;
|
|
|
- scoreStr = fomatStrByRex(text);
|
|
|
+ scoreStr = getScores(text);
|
|
|
String[] scores = StringUtils.split(scoreStr, ",");
|
|
|
double[] scoreArray = new double[stepCount];
|
|
|
for (int i = 0; i < stepCount; i++) {
|
|
@@ -108,7 +111,7 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
|
scoreResult.setTotalScore(Arrays.stream(scoreArray).mapToObj(BigDecimal::new)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
} else if (PromptTemplate.TRANSLATION.equals(q.getPromptTemplate())) {
|
|
|
- String scoreStr = fomatStrByRex(text);
|
|
|
+ String scoreStr = getScores(text);
|
|
|
double[] scoreArray = new double[1];
|
|
|
// 根据得分率与步骤总分计算实际得分,按最大精度保留小数位数
|
|
|
double score = Double.valueOf(scoreStr);
|
|
@@ -125,17 +128,22 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private String fomatStrByRex(String scoreStr) {
|
|
|
- scoreStr = scoreStr.replaceAll("\\s", "");
|
|
|
- Pattern pattern = Pattern.compile("\\d+(\\.\\d+)*(,\\d+(\\.\\d+)*)*");
|
|
|
- String[] ss = scoreStr.split("\\\\n");
|
|
|
- for (String s : ss) {
|
|
|
- Matcher matcher = pattern.matcher(s);
|
|
|
- if (matcher.find()) {
|
|
|
- return matcher.group();
|
|
|
- }
|
|
|
- }
|
|
|
- throw new RuntimeException("解析出错");
|
|
|
+ // private String fomatStrByRex(String scoreStr) {
|
|
|
+ // scoreStr = scoreStr.replaceAll("\\s", "");
|
|
|
+ // Pattern pattern = Pattern.compile("\\d+(\\.\\d+)*(,\\d+(\\.\\d+)*)*");
|
|
|
+ // String[] ss = scoreStr.split("\\\\n");
|
|
|
+ // for (String s : ss) {
|
|
|
+ // Matcher matcher = pattern.matcher(s);
|
|
|
+ // if (matcher.find()) {
|
|
|
+ // return matcher.group();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // throw new RuntimeException("解析出错");
|
|
|
+ // }
|
|
|
+ private String getScores(String res) {
|
|
|
+ Document doc = Jsoup.parse(res);
|
|
|
+ Elements divs = doc.getElementsByTag("final-res-scores");
|
|
|
+ return divs.text();
|
|
|
}
|
|
|
// private String fomatStrByRex(String scoreStr) {
|
|
|
// int tag = scoreStr.lastIndexOf("</think>");
|