Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
winer
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
winer
Commits
c7b78af8
Commit
c7b78af8
authored
2 years ago
by
Wiktor Walentynowicz
Browse files
Options
Downloads
Patches
Plain Diff
Update library version to 0.4.0. Fix prediction.
parent
679a70c2
Branches
Branches containing commit
1 merge request
!5
Develop
Pipeline
#7053
passed with stage
in 29 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
requirements-gpu.txt
+1
-1
1 addition, 1 deletion
requirements-gpu.txt
requirements.txt
+1
-1
1 addition, 1 deletion
requirements.txt
src/winer_worker.py
+22
-9
22 additions, 9 deletions
src/winer_worker.py
with
24 additions
and
11 deletions
requirements-gpu.txt
+
1
−
1
View file @
c7b78af8
torch==1.13.0
--index-url https://pypi.clarin-pl.eu/simple/
nlp_ws
winer
[torch-gpu]
==0.
3.1
winer==0.
4.0
awscli==1.22.57
\ No newline at end of file
This diff is collapsed.
Click to expand it.
requirements.txt
+
1
−
1
View file @
c7b78af8
--index-url https://pypi.clarin-pl.eu/simple/
nlp_ws
winer
==0.
3.1
winer
==0.
4.0
awscli
==1.22.57
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/winer_worker.py
+
22
−
9
View file @
c7b78af8
"""
Implementation of punctuator service
"""
from
winer
.datafiles
import
read_clarin_json
,
write_clarin_json
from
winer
.document
import
create_document_from_clarin_json
,
\
create_entities_from_hf_outputs
from
winer
.winer
import
Winer
from
winer
import
Winer
from
winer
import
allign_into_entities
,
allign_into_words
from
winer
import
create_document_from_clarin_json
,
create_entities_from_hf_outputs
from
winer
import
read_clarin_json
,
write_clarin_json
import
logging
...
...
@@ -16,7 +16,7 @@ class WinerWorker:
):
logging
.
info
(
"
Loading models...
"
)
self
.
active
_model
=
Winer
(
models_location
)
self
.
_model
=
Winer
(
models_location
)
def
process
(
self
,
...
...
@@ -24,12 +24,25 @@ class WinerWorker:
task_options
:
dict
,
output_path
:
str
)
->
None
:
# Read inputs
documents
=
[
create_document_from_clarin_json
(
read_clarin_json
(
input_path
))]
outputs
=
self
.
active_model
.
predict
(
[
str
(
document
)
for
document
in
documents
]
)
tok_inputs
=
[
document
.
get_pretokenized_text
()
for
document
in
documents
]
plain_inputs
=
[
document
.
get_text
()
for
document
in
documents
]
# Predicion
encoded_inputs
=
self
.
_model
.
tokenize
(
tok_inputs
)
predictions_per_token
=
self
.
_model
.
predict
(
encoded_inputs
)
# Aggregation
aggregations
=
[
allign_into_words
(
tokens
,
labels
)
for
tokens
,
labels
in
zip
(
[
encoded_inputs
.
word_ids
(
index
)
for
index
in
range
(
len
(
predictions_per_token
))],
predictions_per_token
)]
entities
=
allign_into_entities
(
tok_inputs
,
aggregations
,
inputs_sentences
=
plain_inputs
)
for
idx
in
range
(
len
(
documents
)):
documents
[
idx
].
add_entites
(
create_entities_from_hf_outputs
(
output
s
[
idx
]))
documents
[
idx
].
add_entites
(
create_entities_from_hf_outputs
(
entitie
s
[
idx
]))
write_clarin_json
(
documents
[
0
].
as_clarin_json
(),
output_path
)
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