Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
combo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Syntactic Tools
combo
Commits
9c283e8c
Commit
9c283e8c
authored
Apr 7, 2021
by
Mateusz Klimaszewski
Browse files
Options
Downloads
Patches
Plain Diff
Fix embeddings mapping during the evaluation step.
parent
06efc043
No related branches found
No related tags found
2 merge requests
!37
Release 1.0.4.
,
!36
Release 1.0.4
Pipeline
#3640
passed
Sep 9, 2021
Stage: test
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
combo/data/api.py
+3
-2
3 additions, 2 deletions
combo/data/api.py
combo/predict.py
+3
-3
3 additions, 3 deletions
combo/predict.py
with
6 additions
and
5 deletions
combo/data/api.py
+
3
−
2
View file @
9c283e8c
...
...
@@ -55,6 +55,7 @@ def sentence2conllu(sentence: Sentence, keep_semrel: bool = True) -> conllu.Toke
# Remove semrel to have default conllu format.
if
not
keep_semrel
:
del
token_dict
[
"
semrel
"
]
del
token_dict
[
"
embeddings
"
]
tokens
.
append
(
token_dict
)
# Range tokens must be tuple not list, this is conllu library requirement
for
t
in
tokens
:
...
...
@@ -84,10 +85,10 @@ def conllu2sentence(conllu_sentence: conllu.TokenList,
if
sentence_embedding
is
None
:
sentence_embedding
=
[]
tokens
=
[]
for
idx
,
token
in
enumerate
(
conllu_sentence
.
tokens
)
:
for
token
in
conllu_sentence
.
tokens
:
tokens
.
append
(
Token
(
**
token
,
embeddings
=
embeddings
[
idx
]
**
token
,
embeddings
=
embeddings
[
token
[
"
id
"
]
]
)
)
return
Sentence
(
...
...
This diff is collapsed.
Click to expand it.
combo/predict.py
+
3
−
3
View file @
9c283e8c
...
...
@@ -141,7 +141,7 @@ class COMBO(predictor.Predictor):
tree
=
instance
.
fields
[
"
metadata
"
][
"
input
"
]
field_names
=
instance
.
fields
[
"
metadata
"
][
"
field_names
"
]
tree_tokens
=
[
t
for
t
in
tree
if
isinstance
(
t
[
"
id
"
],
int
)]
embeddings
=
[
{}
for
_
in
range
(
len
(
tree_tokens
))]
embeddings
=
{
t
[
"
id
"
]:
{}
for
t
in
tree
}
for
field_name
in
field_names
:
if
field_name
not
in
predictions
:
continue
...
...
@@ -150,7 +150,7 @@ class COMBO(predictor.Predictor):
if
field_name
in
{
"
xpostag
"
,
"
upostag
"
,
"
semrel
"
,
"
deprel
"
}:
value
=
self
.
vocab
.
get_token_from_index
(
field_predictions
[
idx
],
field_name
+
"
_labels
"
)
token
[
field_name
]
=
value
embeddings
[
idx
][
field_name
]
=
predictions
[
f
"
{
field_name
}
_token_embedding
"
][
idx
]
embeddings
[
token
[
"
id
"
]
][
field_name
]
=
predictions
[
f
"
{
field_name
}
_token_embedding
"
][
idx
]
elif
field_name
==
"
head
"
:
token
[
field_name
]
=
int
(
field_predictions
[
idx
])
elif
field_name
==
"
deps
"
:
...
...
@@ -176,7 +176,7 @@ class COMBO(predictor.Predictor):
field_value
=
"
|
"
.
join
(
np
.
array
(
features
)[
arg_indices
].
tolist
())
token
[
field_name
]
=
field_value
embeddings
[
idx
][
field_name
]
=
predictions
[
f
"
{
field_name
}
_token_embedding
"
][
idx
]
embeddings
[
token
[
"
id
"
]
][
field_name
]
=
predictions
[
f
"
{
field_name
}
_token_embedding
"
][
idx
]
elif
field_name
==
"
lemma
"
:
prediction
=
field_predictions
[
idx
]
word_chars
=
[]
...
...
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