master
周文涛 2 years ago
parent 5c97997a69
commit d48bff334f

@ -148,8 +148,8 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
ocrIdentifyDetail.setMessage(message); ocrIdentifyDetail.setMessage(message);
ocrIdentifyDetail.setOcrTime(new BigDecimal(ocrTime).setScale(2, RoundingMode.HALF_UP).doubleValue()); ocrIdentifyDetail.setOcrTime(new BigDecimal(ocrTime).setScale(2, RoundingMode.HALF_UP).doubleValue());
ocrIdentifyDetail.setNluTime(new BigDecimal(nluTime).setScale(2, RoundingMode.HALF_UP).doubleValue()); ocrIdentifyDetail.setNluTime(new BigDecimal(nluTime).setScale(2, RoundingMode.HALF_UP).doubleValue());
if (semanticResult!=null && semanticResult.getJSONObject("semantic_result")!=null) { if (semanticResult!=null) {
ocrIdentifyDetail.setSemanticResult(semanticResult.getJSONObject("semantic_result").toJSONString()); ocrIdentifyDetail.setSemanticResult(semanticResult.toJSONString());
} }
ocrIdentifyDetailService.save(ocrIdentifyDetail); ocrIdentifyDetailService.save(ocrIdentifyDetail);
} }
@ -174,13 +174,13 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
String inputText = value.getInputText();//校验文本 ocr识别的文本如果不包含该内容则算作失败 String inputText = value.getInputText();//校验文本 ocr识别的文本如果不包含该内容则算作失败
List<String> fieldNameList = Arrays.asList(fieldName.split(",")); List<String> fieldNameList = Arrays.asList(fieldName.split(","));
text = null; text = null;
boolean b = ArrayOUtils.containsStringList(fieldNameList, semanticResult.getJSONObject("semantic_result").keySet().stream().collect(Collectors.toList())); boolean b = ArrayOUtils.containsStringList(fieldNameList, semanticResult.keySet().stream().collect(Collectors.toList()));
//查看ocr识别返回的字段名称中是否有当前这个字段名称 //查看ocr识别返回的字段名称中是否有当前这个字段名称
if (b) { if (b) {
//TODO 注意ocr 识别返回的 字段是多个结果(数组),有一个值匹配上即为正确 //TODO 注意ocr 识别返回的 字段是多个结果(数组),有一个值匹配上即为正确
List<JSONObject> ocrArray = new ArrayList<>(); List<JSONObject> ocrArray = new ArrayList<>();
for (String s : fieldNameList) { for (String s : fieldNameList) {
JSONArray jsonArray = semanticResult.getJSONObject("semantic_result").getJSONArray(s); JSONArray jsonArray = semanticResult.getJSONArray(s);
if (jsonArray != null && jsonArray.size() > 0) { if (jsonArray != null && jsonArray.size() > 0) {
ocrArray.addAll(jsonArray.toJavaList(JSONObject.class)); ocrArray.addAll(jsonArray.toJavaList(JSONObject.class));
} }
@ -224,15 +224,15 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
//不必校验,有识别到就行,通过 //不必校验,有识别到就行,通过
fieldRightMap.put(field, true); fieldRightMap.put(field, true);
ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, text, probability, imgPath, "", true,ruleInfo); ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, text, probability, imgPath, "", true,ruleInfo);
} else if (Double.valueOf(ruleInfo) >= 1 && Double.valueOf(ruleInfo) <= 99) { } else if (Double.parseDouble(ruleInfo) >= 1 && Double.parseDouble(ruleInfo) <= 99) {
//在1~99之间根据精准度匹配 //在1~99之间根据精准度匹配
double v = StrCharUtil.similarityRatio(inputText, text); double v = StrCharUtil.similarityRatio(inputText, text);
if (v >= Double.valueOf(ruleInfo)) { if (v >= Double.parseDouble(ruleInfo)) {
//准确度 可靠 //准确度 可靠
fieldRightMap.put(field, true); fieldRightMap.put(field, true);
ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, text, probability, imgPath, "", true, v,ruleInfo); ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, text, probability, imgPath, "", true, v,ruleInfo);
} else { } else {
rMessage.append(value.getFieldName() + "参数不匹配<br>"); rMessage.append(value.getFieldName()).append("参数不匹配<br>");
mapPutIfTrue(fieldRightMap, field, false); mapPutIfTrue(fieldRightMap, field, false);
ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, text, probability, imgPath, value.getFieldName() + "参数不匹配", false, v,ruleInfo); ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, text, probability, imgPath, value.getFieldName() + "参数不匹配", false, v,ruleInfo);
} }
@ -243,7 +243,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
fieldRightMap.put(field, true); fieldRightMap.put(field, true);
ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, text, probability, imgPath, "", true, v,ruleInfo); ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, text, probability, imgPath, "", true, v,ruleInfo);
} else { } else {
rMessage.append(value.getFieldName() + "参数不匹配<br>"); rMessage.append(value.getFieldName()).append("参数不匹配<br>");
mapPutIfTrue(fieldRightMap, field, false); mapPutIfTrue(fieldRightMap, field, false);
ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, text, probability, imgPath, value.getFieldName() + "参数不匹配", false, v,ruleInfo); ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, text, probability, imgPath, value.getFieldName() + "参数不匹配", false, v,ruleInfo);
} }
@ -251,12 +251,12 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
} }
} }
} else { } else {
rMessage.append(value.getFieldName() + "参数未获取到结果<br>"); rMessage.append(value.getFieldName()).append("参数未获取到结果<br>");
mapPutIfTrue(fieldRightMap, field, false); mapPutIfTrue(fieldRightMap, field, false);
ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, null, probability, imgPath, value.getFieldName() + "参数未获取到结果", false,ruleInfo); ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, null, probability, imgPath, value.getFieldName() + "参数未获取到结果", false,ruleInfo);
} }
} else { } else {
rMessage.append(value.getFieldName() + "参数未获取到结果<br>"); rMessage.append(value.getFieldName()).append("参数未获取到结果<br>");
ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, null, 0d, imgPath, value.getFieldName() + "参数未获取到结果", false,ruleInfo); ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, null, 0d, imgPath, value.getFieldName() + "参数未获取到结果", false,ruleInfo);
fieldRightMap.put(field, false); fieldRightMap.put(field, false);
} }

Loading…
Cancel
Save