|
@@ -5,6 +5,8 @@ import java.math.RoundingMode;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -74,7 +76,12 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
|
getDecimalPlaces(request.getTotalScore()));
|
|
|
int stepCount = request.getStandardAnswer().size();
|
|
|
String scoreStr = text.substring(text.lastIndexOf("\n") + 1).trim();
|
|
|
- String[] scores = StringUtils.split(fomatStr(scoreStr), ",");
|
|
|
+ if (stepCount > 1) {
|
|
|
+ scoreStr = fomatStrByRex(scoreStr);
|
|
|
+ } else {
|
|
|
+ scoreStr = fomatStr(scoreStr);
|
|
|
+ }
|
|
|
+ String[] scores = StringUtils.split(scoreStr, ",");
|
|
|
double[] scoreArray = new double[stepCount];
|
|
|
for (int i = 0; i < stepCount; i++) {
|
|
|
// 根据得分率与步骤总分计算实际得分,按最大精度保留小数位数
|
|
@@ -100,10 +107,31 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ private String fomatStrByRex(String scoreStr) {
|
|
|
+ String ret = scoreStr.replaceAll(",", ",").replaceAll("。", "").replaceAll(":", ":").replaceAll("[0-9]\\.", "");
|
|
|
+ Pattern pattern = Pattern.compile("(\\d{1,3},)+\\d{1,3}");
|
|
|
+ Matcher matcher = pattern.matcher(ret);
|
|
|
+ if (matcher.find()) {
|
|
|
+ return matcher.group();
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("返回格式错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private int getDecimalPlaces(double value) {
|
|
|
return Math.max(0, BigDecimal.valueOf(value).stripTrailingZeros().scale());
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String scoreStr = "2个3,29,110\\n\\n考生的回答完全覆盖了所有的关键内容,逻辑清晰,术语使用准确";
|
|
|
+ String ret = scoreStr.replaceAll(",", ",").replaceAll("。", "").replaceAll(":", ":").replaceAll("[0-9]\\.", "");
|
|
|
+ Pattern pattern = Pattern.compile("(\\d{1,3},)+\\d{1,3}");
|
|
|
+ Matcher matcher = pattern.matcher(ret);
|
|
|
+ if (matcher.find()) {
|
|
|
+ System.out.println(matcher.group());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@SuppressWarnings("deprecation")
|
|
|
private String chat(ReqMessages dreq) {
|
|
|
|