Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lambo
Manage
Activity
Members
Labels
Plan
Issues
45
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
Syntactic Tools
lambo
Commits
bea72f56
Commit
bea72f56
authored
2 years ago
by
piotrmp
Browse files
Options
Downloads
Patches
Plain Diff
Reduced window size.
parent
51c310b1
1 merge request
!1
Migration to UD 2.11
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lambo/evaluation/evaluate.py
+10
-5
10 additions, 5 deletions
src/lambo/evaluation/evaluate.py
src/lambo/learning/train.py
+2
-2
2 additions, 2 deletions
src/lambo/learning/train.py
with
12 additions
and
7 deletions
src/lambo/evaluation/evaluate.py
+
10
−
5
View file @
bea72f56
from
lambo.evaluation.conll18_ud_eval
import
load_conllu
,
evaluate
from
lambo.evaluation.conll18_ud_eval
import
load_conllu
,
evaluate
,
UDError
from
lambo.utils.printer
import
print_document_to_conll
...
...
@@ -19,8 +19,13 @@ def evaluate_segmenter(segmenter, test_text, gold_path, tmp_path):
with
open
(
gold_path
)
as
fGold
:
pred
=
load_conllu
(
fPred
)
gold
=
load_conllu
(
fGold
)
conll_result
=
evaluate
(
gold
,
pred
)
for
category
in
[
'
Tokens
'
,
'
Words
'
,
'
Sentences
'
]:
result
[
category
]
=
{
'
F1
'
:
conll_result
[
category
].
f1
,
'
precision
'
:
conll_result
[
category
].
precision
,
'
recall
'
:
conll_result
[
category
].
recall
}
try
:
conll_result
=
evaluate
(
gold
,
pred
)
for
category
in
[
'
Tokens
'
,
'
Words
'
,
'
Sentences
'
]:
result
[
category
]
=
{
'
F1
'
:
conll_result
[
category
].
f1
,
'
precision
'
:
conll_result
[
category
].
precision
,
'
recall
'
:
conll_result
[
category
].
recall
}
except
UDError
as
e
:
for
category
in
[
'
Tokens
'
,
'
Words
'
,
'
Sentences
'
]:
result
[
category
]
=
{
'
F1
'
:
0.0
,
'
precision
'
:
0.0
,
'
recall
'
:
0.0
}
return
result
This diff is collapsed.
Click to expand it.
src/lambo/learning/train.py
+
2
−
2
View file @
bea72f56
...
...
@@ -121,7 +121,7 @@ def train_new_and_save(model_name, treebank_path, save_path, epochs=10, device='
BATCH_SIZE
=
32
print
(
"
Initiating the model.
"
)
MAX_LEN
=
1024
MAX_LEN
=
256
dict
,
train_dataloader
,
test_dataloader
=
prepare_dataloaders_withdict
([
train_doc
,
dev_doc
],
[
test_doc
],
MAX_LEN
,
BATCH_SIZE
)
...
...
@@ -168,7 +168,7 @@ def train_pretrained_and_save(language, treebank_path, save_path, pretrained_pat
train_doc
,
dev_doc
,
test_doc
=
read_treebank
(
treebank_path
,
True
)
print
(
"
Initiating the model.
"
)
MAX_LEN
=
1024
MAX_LEN
=
256
model
=
LamboNetwork
(
MAX_LEN
,
dict
,
len
(
utf_category_dictionary
),
pretrained
=
pretrained_model
)
print
(
"
Preparing data
"
)
...
...
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