|
@@ -93,11 +93,11 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
|
getDecimalPlaces(request.getTotalScore()));
|
|
|
int stepCount = request.getStandardAnswer().size();
|
|
|
String scoreStr = null;
|
|
|
- if (stepCount > 1) {
|
|
|
- scoreStr = fomatStrByRex(text);
|
|
|
- } else {
|
|
|
- scoreStr = fomatStr(text);
|
|
|
- }
|
|
|
+ // if (stepCount > 1) {
|
|
|
+ scoreStr = fomatStrByRex(text);
|
|
|
+ // } else {
|
|
|
+ // scoreStr = fomatStr(text);
|
|
|
+ // }
|
|
|
String[] scores = StringUtils.split(scoreStr, ",");
|
|
|
double[] scoreArray = new double[stepCount];
|
|
|
for (int i = 0; i < stepCount; i++) {
|
|
@@ -112,7 +112,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 = fomatStr(text);
|
|
|
+ String scoreStr = fomatStrByRex(text);
|
|
|
double[] scoreArray = new double[1];
|
|
|
// 根据得分率与步骤总分计算实际得分,按最大精度保留小数位数
|
|
|
double score = Double.valueOf(scoreStr);
|
|
@@ -132,26 +132,25 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
|
}
|
|
|
|
|
|
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 fomatStr(String scoreStr) {
|
|
|
+ // scoreStr = scoreStr.substring(0, scoreStr.indexOf("\\n")).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>");
|
|
@@ -173,14 +172,17 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- String scoreStr = "</think>。\\n\\n\\n70,70,60\\n\\n评分结果2个3,29,110 \\n\\n考生的回答完全覆盖了所有的关键内容,逻辑清晰,术语使用准确";
|
|
|
- scoreStr = scoreStr.substring(scoreStr.lastIndexOf("</think>") + 1).trim();
|
|
|
- System.out.println(Runtime.getRuntime().availableProcessors());
|
|
|
- String ret = scoreStr.replaceAll(",", ",").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()) {
|
|
|
- System.out.println(matcher.group());
|
|
|
+ String scoreStr = "</think>。\\n\\n\\n 70 \\n\\n评分结果2个3,29,110 \\n\\n考生的回答完全覆盖了所有的关键内容,逻辑清晰,术语使用准确";
|
|
|
+ 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()) {
|
|
|
+
|
|
|
+ System.out.println(matcher.group());
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|