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
!11
Implement extraction command
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Implement extraction command
implement-extraction-command
into
main
Overview
1
Commits
12
Pipelines
0
Changes
22
Merged
Yoann Schneider
requested to merge
implement-extraction-command
into
main
2 years ago
Overview
1
Commits
12
Pipelines
0
Changes
22
Expand
Requires
!9 (merged)
Closes
#9 (closed)
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
dbc99d48
12 commits,
2 years ago
22 files
+
799
−
310
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
22
Search (e.g. *.vue) (Ctrl+P)
dan/datasets/extract/__init__.py
+
115
−
0
Options
# -*- coding: utf-8 -*-
"""
Extract dataset from Arkindex using API.
"""
import
pathlib
import
uuid
from
dan.datasets.extract.extract_from_arkindex
import
run
MANUAL_SOURCE
=
"
manual
"
def
parse_worker_version
(
worker_version_id
):
if
worker_version_id
==
MANUAL_SOURCE
:
return
False
return
worker_version_id
def
add_extract_parser
(
subcommands
)
->
None
:
parser
=
subcommands
.
add_parser
(
"
extract
"
,
description
=
__doc__
,
help
=
__doc__
,
)
# Required arguments.
parser
.
add_argument
(
"
--parent
"
,
type
=
uuid
.
UUID
,
nargs
=
"
+
"
,
help
=
"
ID of the parent folder to import from Arkindex.
"
,
required
=
False
,
)
parser
.
add_argument
(
"
--element-type
"
,
nargs
=
"
+
"
,
type
=
str
,
help
=
"
Type of elements to retrieve
"
,
required
=
True
,
)
parser
.
add_argument
(
"
--parent-element-type
"
,
type
=
str
,
help
=
"
Type of the parent element containing the data.
"
,
required
=
False
,
default
=
"
page
"
,
)
parser
.
add_argument
(
"
--output
"
,
type
=
pathlib
.
Path
,
help
=
"
Path where the data will be generated.
"
,
required
=
True
,
)
# Optional arguments.
parser
.
add_argument
(
"
--load-entities
"
,
action
=
"
store_true
"
,
help
=
"
Extract text with their entities
"
)
parser
.
add_argument
(
"
--tokens
"
,
type
=
pathlib
.
Path
,
help
=
"
Mapping between starting tokens and end tokens. Needed for entities.
"
,
required
=
False
,
)
parser
.
add_argument
(
"
--use-existing-split
"
,
action
=
"
store_true
"
,
help
=
"
Use the specified folder IDs for the dataset split.
"
,
)
parser
.
add_argument
(
"
--train-folder
"
,
type
=
uuid
.
UUID
,
help
=
"
ID of the training folder to import from Arkindex.
"
,
required
=
False
,
)
parser
.
add_argument
(
"
--val-folder
"
,
type
=
uuid
.
UUID
,
help
=
"
ID of the validation folder to import from Arkindex.
"
,
required
=
False
,
)
parser
.
add_argument
(
"
--test-folder
"
,
type
=
uuid
.
UUID
,
help
=
"
ID of the testing folder to import from Arkindex.
"
,
required
=
False
,
)
parser
.
add_argument
(
"
--transcription-worker-version
"
,
type
=
parse_worker_version
,
help
=
f
"
Filter transcriptions by worker_version. Use
{
MANUAL_SOURCE
}
for manual filtering.
"
,
required
=
False
,
default
=
MANUAL_SOURCE
,
)
parser
.
add_argument
(
"
--entity-worker-version
"
,
type
=
parse_worker_version
,
help
=
f
"
Filter transcriptions entities by worker_version. Use
{
MANUAL_SOURCE
}
for manual filtering.
"
,
required
=
False
,
default
=
MANUAL_SOURCE
,
)
parser
.
add_argument
(
"
--train-prob
"
,
type
=
float
,
default
=
0.7
,
help
=
"
Training set split size.
"
)
parser
.
add_argument
(
"
--val-prob
"
,
type
=
float
,
default
=
0.15
,
help
=
"
Validation set split size
"
)
parser
.
set_defaults
(
func
=
run
)
Loading