Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DAN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Automatic Text Recognition
DAN
Merge requests
!42
Fix dataset extraction offset
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Fix dataset extraction offset
fix-dataset-extraction-offset
into
main
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Solene Tarride
requested to merge
fix-dataset-extraction-offset
into
main
2 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
Closes
#25 (closed)
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
50815244
1 commit,
2 years ago
1 file
+
4
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
dan/datasets/extract/utils.py
+
4
−
1
Options
@@ -22,6 +22,7 @@ def save_json(path, dict):
def
insert_token
(
text
,
count
,
start_token
,
end_token
,
offset
,
length
):
"""
Insert the given tokens at the right position in the text
start_token or end_token can be empty strings
"""
text
=
(
# Text before entity
@@ -35,7 +36,9 @@ def insert_token(text, count, start_token, end_token, offset, length):
# Text after entity
+
text
[
count
+
1
+
offset
+
length
:]
)
return
text
,
count
+
2
token_offset
=
len
(
start_token
)
+
len
(
end_token
)
return
text
,
count
+
token_offset
def
parse_tokens
(
filename
):
Loading