Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
easymatcher
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nlpworkers
easymatcher
Commits
6a94b42e
There was an error fetching the commit references. Please try again later.
Commit
6a94b42e
authored
2 years ago
by
Konrad Wojtasik
Browse files
Options
Downloads
Patches
Plain Diff
Update easymatcher_worker.py
parent
3130c89d
1 merge request
!4
Resolve "Read not only .txt files"
Pipeline
#11438
failed with stages
in 3 minutes and 8 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/easymatcher_worker.py
+6
-4
6 additions, 4 deletions
src/easymatcher_worker.py
with
6 additions
and
4 deletions
src/easymatcher_worker.py
+
6
−
4
View file @
6a94b42e
...
@@ -47,9 +47,9 @@ class EasymatcherWorker(nlp_ws.NLPWorker):
...
@@ -47,9 +47,9 @@ class EasymatcherWorker(nlp_ws.NLPWorker):
with
open
(
document_path
,
"
r
"
,
encoding
=
"
utf-8
"
)
as
_df
:
with
open
(
document_path
,
"
r
"
,
encoding
=
"
utf-8
"
)
as
_df
:
for
line
in
_df
:
for
line
in
_df
:
line_data
=
json
.
loads
(
line
)
line_data
=
json
.
loads
(
line
)
document
[
'
text
'
]
=
line_data
[
'
text
'
]
#
document['text'] = line_data['text']
# document['label'] = []
# document['label'] = []
_f
.
write
(
json
.
dumps
(
document
)
+
"
\n
"
)
_f
.
write
(
json
.
dumps
(
line_data
)
+
"
\n
"
)
else
:
else
:
with
open
(
document_path
,
"
r
"
,
encoding
=
"
utf-8
"
)
as
_df
:
with
open
(
document_path
,
"
r
"
,
encoding
=
"
utf-8
"
)
as
_df
:
document
[
"
text
"
]
=
_df
.
read
()
document
[
"
text
"
]
=
_df
.
read
()
...
@@ -107,5 +107,7 @@ class EasymatcherWorker(nlp_ws.NLPWorker):
...
@@ -107,5 +107,7 @@ class EasymatcherWorker(nlp_ws.NLPWorker):
os
.
unlink
(
tmpf
.
name
)
os
.
unlink
(
tmpf
.
name
)
with
open
(
output_path
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
_f
:
with
open
(
output_path
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
_f
:
for
out_document
in
out_documents
:
for
out_document
,
document
in
zip
(
out_documents
,
documents
):
_f
.
write
(
json
.
dumps
(
out_document
)
+
"
\n
"
)
# We want to keep content of the original labeled documents
document
[
'
label
'
]
=
out_document
[
'
label
'
]
_f
.
write
(
json
.
dumps
(
document
)
+
"
\n
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
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