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