|
@@ -93,11 +93,7 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
getDecimalPlaces(request.getTotalScore()));
|
|
getDecimalPlaces(request.getTotalScore()));
|
|
int stepCount = request.getStandardAnswer().size();
|
|
int stepCount = request.getStandardAnswer().size();
|
|
String scoreStr = null;
|
|
String scoreStr = null;
|
|
- if (stepCount > 1) {
|
|
|
|
- scoreStr = fomatStrByRex(text);
|
|
|
|
- } else {
|
|
|
|
- scoreStr = fomatStr(text);
|
|
|
|
- }
|
|
|
|
|
|
+ scoreStr = fomatStrByRex(text);
|
|
String[] scores = StringUtils.split(scoreStr, ",");
|
|
String[] scores = StringUtils.split(scoreStr, ",");
|
|
double[] scoreArray = new double[stepCount];
|
|
double[] scoreArray = new double[stepCount];
|
|
for (int i = 0; i < stepCount; i++) {
|
|
for (int i = 0; i < stepCount; i++) {
|
|
@@ -112,7 +108,7 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
scoreResult.setTotalScore(Arrays.stream(scoreArray).mapToObj(BigDecimal::new)
|
|
scoreResult.setTotalScore(Arrays.stream(scoreArray).mapToObj(BigDecimal::new)
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
} else if (PromptTemplate.TRANSLATION.equals(q.getPromptTemplate())) {
|
|
} else if (PromptTemplate.TRANSLATION.equals(q.getPromptTemplate())) {
|
|
- String scoreStr = fomatStr(text);
|
|
|
|
|
|
+ String scoreStr = fomatStrByRex(text);
|
|
double[] scoreArray = new double[1];
|
|
double[] scoreArray = new double[1];
|
|
// 根据得分率与步骤总分计算实际得分,按最大精度保留小数位数
|
|
// 根据得分率与步骤总分计算实际得分,按最大精度保留小数位数
|
|
double score = Double.valueOf(scoreStr);
|
|
double score = Double.valueOf(scoreStr);
|
|
@@ -130,26 +126,40 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
}
|
|
}
|
|
|
|
|
|
private String fomatStrByRex(String scoreStr) {
|
|
private String fomatStrByRex(String scoreStr) {
|
|
- int tag = scoreStr.lastIndexOf("</think>");
|
|
|
|
- if (tag != -1) {
|
|
|
|
- scoreStr = scoreStr.substring(tag).trim();
|
|
|
|
- }
|
|
|
|
- String ret = scoreStr.replaceAll(",", ",").replaceAll("。", "").replaceAll("[0-9]\\.", "");
|
|
|
|
- Pattern pattern = Pattern.compile("(\\d{1,3}\\s*,\\s*)+\\d{1,3}");
|
|
|
|
- Matcher matcher = pattern.matcher(ret);
|
|
|
|
- if (matcher.find()) {
|
|
|
|
- return matcher.group();
|
|
|
|
- } else {
|
|
|
|
- throw new RuntimeException("返回格式错误");
|
|
|
|
|
|
+ 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 fomatStr(String scoreStr) {
|
|
|
|
- scoreStr = scoreStr.substring(scoreStr.lastIndexOf("\n") + 1).trim();
|
|
|
|
- String ret = scoreStr.replaceAll(",", ",").replaceAll("。", "").replaceAll(":", ":");
|
|
|
|
- ret = ret.substring(ret.lastIndexOf(":") + 1).trim();
|
|
|
|
- return ret;
|
|
|
|
- }
|
|
|
|
|
|
+ // private String fomatStrByRex(String scoreStr) {
|
|
|
|
+ // int tag = scoreStr.lastIndexOf("</think>");
|
|
|
|
+ // if (tag != -1) {
|
|
|
|
+ // scoreStr = scoreStr.substring(tag).trim();
|
|
|
|
+ // }
|
|
|
|
+ // String ret = scoreStr.replaceAll(",", ",").replaceAll("。",
|
|
|
|
+ // "").replaceAll("[0-9]\\.", "");
|
|
|
|
+ // Pattern pattern = Pattern.compile("(\\d{1,3}\\s*,\\s*)+\\d{1,3}");
|
|
|
|
+ // Matcher matcher = pattern.matcher(ret);
|
|
|
|
+ // if (matcher.find()) {
|
|
|
|
+ // return matcher.group();
|
|
|
|
+ // } else {
|
|
|
|
+ // throw new RuntimeException("返回格式错误");
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //
|
|
|
|
+ // private String fomatStr(String scoreStr) {
|
|
|
|
+ // scoreStr = scoreStr.substring(scoreStr.lastIndexOf("\n") + 1).trim();
|
|
|
|
+ // String ret = scoreStr.replaceAll(",", ",").replaceAll("。",
|
|
|
|
+ // "").replaceAll(":", ":");
|
|
|
|
+ // ret = ret.substring(ret.lastIndexOf(":") + 1).trim();
|
|
|
|
+ // return ret;
|
|
|
|
+ // }
|
|
|
|
|
|
// private String fomatStrByRex(String scoreStr) {
|
|
// private String fomatStrByRex(String scoreStr) {
|
|
// int tag = scoreStr.lastIndexOf("</think>");
|
|
// int tag = scoreStr.lastIndexOf("</think>");
|