Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

本地提交,返回json不全,无法解析 #754

Open
1 task done
Mie888 opened this issue Dec 27, 2024 · 3 comments
Open
1 task done

本地提交,返回json不全,无法解析 #754

Mie888 opened this issue Dec 27, 2024 · 3 comments

Comments

@Mie888
Copy link

Mie888 commented Dec 27, 2024

Issues

  • I have browsed through the Issues. 我已浏览过Issues,确定没有重复提问。

Umi-OCR version 程序版本

2.1.4

Windows version 系统版本

win10

OCR plugins Used 使用的OCR插件

No response

Reproduction steps 复现步骤

本地提交,返回json格式错误或者不全,无法解析,解析失败。

Problem screenshots or related files (optional) 问题截图或相关文件(可选)

No response

@hiroi-sora
Copy link
Owner

http接口吗?可否将返回结果的字符串原文放上来。

@Mie888
Copy link
Author

Mie888 commented Dec 27, 2024

{"code": 100, "data": [{"box": [[117, 1], [148, 1], [148, 12], [117, 12]], "score": 0.3190456286072731, "text": "找妍.补价", "end": "
"}, {"box": [[125, 10], [179, 8], [180, 22], [125, 24]], "score": 0.5121368856893646, "text": "西.确认无用此争徒", "end": "
"}, {"box": [[182, 27], [213, 27], [213, 38], [182, 38]], "score": 0.4127674177289009, "text": "¥.8 :3", "end": "
"}, {"box": [[147, 67], [249, 67], [249, 85], [147, 85]], "score": 0.9754958663667951, "text": "解除合同协议书", "end": ""}, {"box": [[157, 205], [241, 205], [241, 220], [157, 220]], "score": 0.9945186823606491, "text": "办公房屋租赁合同", "end": "
"}, {"box": [[405, 3], [442, 3], [442, 17], [405, 17]], "score": 0.6725110028471265, "text": "平方(公享):", "end": ""}, {"box": [[396, 15], [442, 15], [442, 29], [396, 29]], "score": 0.7321130782365799, "text": "适地代表人签宇:", "end": ""}, {"box": [[413, 27], [443, 27], [443, 41], [413, 41]], "score": 0.6564098358154297, "text": "整订日期:", "end": "
"}, {"box": [[496, 3], [534, 3], [534, 17], [496, 17]], "score": 0.673359077423811, "text": "乙方(公享)):", "end": ""}, {"box": [[496, 15], [542, 15], [542, 29], [496, 29]], "score": 0.7622329081807818, "text": "法定代表人整字", "end": ""}, {"box": [[496, 27], [526, 27], [526, 41], [496, 41]], "score": 0.6053625702857971, "text": "签可目期:", "end": "
"}, {"box": [[423, 67], [510, 67], [510, 85], [423, 85]], "score": 0.9848410884539286, "text": "合同补充协议", "end": "
"}, {"box": [[450, 152], [483, 152], [483, 167], [450, 167]], "score": 0.8035171031951904, "text": "补充协议", "end": "
"}, {"box": [[394, 199], [489, 199], [489, 210], [394, 210]], "score": 0.526596452508654, "text": "甲*乙月#TC", "end": "
"}, {"box": [[503, 199], [547, 199], [547, 210], [503, 210]], "score": 0.3792799141790186, "text": "_定Ci下用K", "end": "
"}, {"box": [[440, 206], [548, 206], [548, 220], [440, 220]], "score": 0.4281480312347412, "text": "甲,乙政市中管龙师、互为间,友导修,查", "end": "
"}, {"box": [[385, 209], [420, 209], [420, 219], [385, 219]], "score": 0.42265494018793104, "text": "护风"), 膜导为,", "end": "
"}, {"box": [[385, 216], [501, 216], [501, 229], [385, 229]], "score": 0.4155123677104712, "text": "务优基班上补完部少#,神打业下许定持让。", "end": ""}, {"box": [[397, 226], [441, 226], [441, 239], [397, 239]], "score": 0.3794233964549171, "text": ",地比补定部分为,", "end": "
"}, {"box": [[398, 236], [459, 236], [459, 246], [398, 246]], "score": 0.36992760518422496, "text": "h 养的s特. 自量.护批", "end": "
"}, {"box": [[661, 67], [806, 66], [806, 84], [661, 85]], "score": 0.9871445238590241, "text": "农村房屋租赁合同范本", "end": "
"}, {"box": [[694, 153], [774, 153], [774, 166], [694, 166]], "score": 0.911037415266037, "text": "公司房里租赁合同书范本", "end": "
"}, {"box": [[661, 171], [678, 171], [678, 183], [661, 183]], "score": 0.32746173441410065, "text": "生.", "end": "
"}, {"box": [[661, 183], [745, 183], [745, 196], [661, 196]], "score": 0.5837014745920897, "text": "统一性分核用代明/心民身价考略。", "end": "
"}, {"box": [[662, 196], [695, 196], [695, 208], [662, 208]], "score": 0.5353185646235943, "text": "激定代表人,", "end": ""}, {"box": [[660, 206], [695, 206], [695, 221], [660, 221]], "score": 0.6743078157305717, "text": "委托代票人,", "end": ""}, {"box": [[661, 219], [694, 219], [694, 233], [661, 233]], "score": 0.22364830846587816, "text": "年年区车点。", "end": ""}, {"box": [[660, 231], [689, 231], [689, 245], [660, 245]], "score": 0.28697921708226204, "text": "或式地量。", "end": ""}, {"box": [[659, 243], [688, 240], [690, 255], [660, 258]], "score": 0.13265388756990432, "text": "都现细响。", "end": ""}, {"box": [[660, 254], [689, 254], [689, 269], [660, 269]], "score": 0.443320506811142, "text": "联系电乐。", "end": ""}, {"box": [[661, 267], [678, 267], [678, 280], [661, 280]], "score": 0.48857330282529193, "text": "维号:", "end": " "}, {"box": [[660, 278], [689, 278], [689, 292], [660, 292]], "score": 0.40717069680492085, "text": "a.-e业.", "end": "
"}, {"box": [[703, 196], [728, 196], [728, 208], [703, 208]], "score": 0.4737740606069565, "text": "、联", "end": "
"}], "score": 0.5606347079182835, "time": 1.0747003555297852, "timestamp": 1735314002.1401577}

@hiroi-sora
Copy link
Owner

hiroi-sora commented Dec 27, 2024

返回值中,"end": "*" 的 "*" 有可能为字符串 \+n (表示这一句是段落的结尾)。大部分json解析器(或者HTTP库),比如python、js语言默认的,处理它没有任何问题。但可能有少数库会将 \+n 替换为换行符 \n ,从而破坏json结构。

从你的结果中看出,很可能是HTTP库将\+n转换为了 \n ,导致后续的json解析器报错。

你可以在拿到结果字符串原文后,先将字符串中全部的 "end": "\n" 替换为 "end": "\\n" 或者 "end": "自定义换行标记符" ,再交给json解析。以避免此问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants