Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LibreTranslate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Riße, Matthias
LibreTranslate
Commits
d6ef04ba
Commit
d6ef04ba
authored
2 years ago
by
Piero Toffanin
Browse files
Options
Downloads
Patches
Plain Diff
Extract JSONL from suggestions.db script
parent
0136d880
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
suggestions-to-jsonl.py
+46
-0
46 additions, 0 deletions
suggestions-to-jsonl.py
with
46 additions
and
0 deletions
suggestions-to-jsonl.py
0 → 100755
+
46
−
0
View file @
d6ef04ba
#!/usr/bin/env python
import
argparse
import
time
import
sqlite3
import
json
if
__name__
==
"
__main__
"
:
parser
=
argparse
.
ArgumentParser
(
description
=
"
Program to generate JSONL files from a LibreTranslate
'
s suggestions.db
"
)
parser
.
add_argument
(
"
--db
"
,
type
=
str
,
nargs
=
1
,
help
=
"
Path to suggestions.db file
"
,
default
=
'
suggestions.db
'
)
parser
.
add_argument
(
"
--clear
"
,
action
=
'
store_true
'
,
help
=
"
Clear suggestions.db after generation
"
,
default
=
False
)
args
=
parser
.
parse_args
()
output_file
=
str
(
int
(
time
.
time
()))
+
"
.jsonl
"
con
=
sqlite3
.
connect
(
args
.
db
,
check_same_thread
=
False
)
cur
=
con
.
cursor
()
with
open
(
output_file
,
'
w
'
,
encoding
=
"
utf-8
"
)
as
f
:
for
row
in
cur
.
execute
(
'
SELECT q, s, source, target FROM suggestions WHERE source !=
"
auto
"
ORDER BY source
'
):
q
,
s
,
source
,
target
=
row
obj
=
{
'
q
'
:
q
,
'
s
'
:
s
,
'
source
'
:
source
,
'
target
'
:
target
}
json
.
dump
(
obj
,
f
,
ensure_ascii
=
False
)
f
.
write
(
'
\n
'
)
print
(
"
Wrote %s
"
%
output_file
)
if
args
.
clear
:
cur
.
execute
(
"
DELETE FROM suggestions
"
)
con
.
commit
()
print
(
"
Cleared
"
+
args
.
db
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment