Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Satini_pvduc
/
ocrpdf
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
tien_nemo
2025-08-13 21:46:21 +0700
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
c70391a4019043b475f25b9e337be552c6f7ddf0
c70391a4
1 parent
406ace5f
test load data
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
73 deletions
resources/views/ocr/index.blade.php
resources/views/ocr/index.blade.php
View file @
c70391a
...
...
@@ -104,7 +104,7 @@
<!-- Dropdown OCR -->
<select
v-if=
"selectingIndex !== null"
<select
v-if=
"selectingIndex !== null
&& ocrData[selectingIndex].isManual
"
:style=
"getSelectStyle(ocrData[selectingIndex])"
v-model=
"ocrData[selectingIndex].field"
@
change=
"applyMapping"
...
...
@@ -440,54 +440,6 @@
},
// Tìm box OCR phù hợp nhất để map với field
findBestMatchingBox
(
fieldName
,
fieldValue
)
{
let
bestMatchIndex
=
-
1
;
let
bestScore
=
0
;
this
.
ocrData
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
isDeleted
)
return
;
// Nếu box này đã được map field khác, bỏ qua
if
(
item
.
field
&&
item
.
field
!==
fieldName
)
return
;
// Tính điểm phù hợp dựa trên text
const
text
=
item
.
text
||
''
;
const
score
=
this
.
calculateTextSimilarity
(
text
,
fieldValue
);
if
(
score
>
bestScore
)
{
bestScore
=
score
;
bestMatchIndex
=
index
;
}
});
// Chỉ map nếu điểm phù hợp đủ cao (ví dụ > 0.5)
return
bestScore
>
0.5
?
bestMatchIndex
:
-
1
;
},
// Tính điểm tương đồng giữa 2 text
calculateTextSimilarity
(
text1
,
text2
)
{
if
(
!
text1
||
!
text2
)
return
0
;
const
t1
=
text1
.
toLowerCase
().
trim
();
const
t2
=
text2
.
toLowerCase
().
trim
();
// Nếu text giống hệt nhau
if
(
t1
===
t2
)
return
1.0
;
// Nếu một text là subset của text kia
if
(
t1
.
includes
(
t2
)
||
t2
.
includes
(
t1
))
return
0.8
;
// Tính điểm dựa trên số ký tự giống nhau
let
commonChars
=
0
;
const
minLength
=
Math
.
min
(
t1
.
length
,
t2
.
length
);
for
(
let
i
=
0
;
i
<
minLength
;
i
++
)
{
if
(
t1
[
i
]
===
t2
[
i
])
commonChars
++
;
}
return
commonChars
/
Math
.
max
(
t1
.
length
,
t2
.
length
);
},
onImageLoad
()
{
const
img
=
this
.
$refs
.
pdfImage
;
this
.
imageWidth
=
img
.
naturalWidth
;
...
...
@@ -529,32 +481,9 @@
zIndex
:
item
.
isManual
?
30
:
10
};
},
// highlightField(field) {
// let idx = -1;
// for (let i = this.ocrData.length - 1; i >= 0; i--) {
// const it = this.ocrData[i];
// if (!it.isDeleted && it.field === field) {
// idx = i;
// break;
// }
// }
//
// if (idx !== -1) {
// // Set active index (chuyển trạng thái active và màu xanh)
// this.activeIndex = idx;
// // Scroll đến box tương ứng
// this.scrollToBox(idx);
// // Focus vào box để người dùng thấy rõ
// this.focusOnBox(idx);
// } else {
// this.activeIndex = null;
// }
// },
highlightField
(
field
)
{
// Xóa tất cả manual box cũ trước khi tạo mới
//
this.ocrData = this.ocrData.filter(b => !b.isManual);
//
this.ocrData = this.ocrData.filter(b => !b.isManual);
let
coords
,
text
;
...
...
Please
register
or
sign in
to post a comment