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
02d737a1
Commit
02d737a1
authored
2 years ago
by
piotrmp
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix.
parent
470059c6
1 merge request
!2
Multiword generation
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lambo/resources/languages.txt
+1
-1
1 addition, 1 deletion
src/lambo/resources/languages.txt
src/lambo/segmenter/lambo.py
+3
-3
3 additions, 3 deletions
src/lambo/segmenter/lambo.py
src/lambo/utils/printer.py
+3
-3
3 additions, 3 deletions
src/lambo/utils/printer.py
with
7 additions
and
7 deletions
src/lambo/resources/languages.txt
+
1
−
1
View file @
02d737a1
...
...
@@ -3,7 +3,7 @@ UD_Afrikaans-AfriBooms af Afrikaans
UD_Ancient_Greek-PROIEL ? Ancient_Greek *
UD_Ancient_Greek-Perseus ? Ancient_Greek
UD_Ancient_Hebrew-PTNK ? Ancient_Hebrew
UD_Arabic-NYUAD ar Arabic
#
UD_Arabic-NYUAD ar Arabic
UD_Arabic-PADT ar Arabic *
UD_Armenian-ArmTDP hy Armenian *
UD_Armenian-BSUT hy Armenian
...
...
This diff is collapsed.
Click to expand it.
src/lambo/segmenter/lambo.py
+
3
−
3
View file @
02d737a1
...
...
@@ -68,7 +68,7 @@ class Lambo():
return
model_name
@classmethod
def
from_path
(
cls
,
model_path
,
model_name
):
def
from_path
(
cls
,
model_path
,
model_name
,
with_splitter
=
True
):
"""
Obtain a LAMBO segmenter by reading a model from a given path.
...
...
@@ -79,7 +79,7 @@ class Lambo():
model
=
torch
.
load
(
model_path
/
(
model_name
+
'
.pth
'
),
map_location
=
torch
.
device
(
'
cpu
'
))
dict
=
Lambo
.
read_dict
(
model_path
/
(
model_name
+
'
.dict
'
))
splitter
=
None
if
(
model_path
/
(
model_name
+
'
_subwords.pth
'
)).
exists
():
if
with_splitter
and
(
model_path
/
(
model_name
+
'
_subwords.pth
'
)).
exists
():
from
lambo.subwords.splitter
import
LamboSplitter
splitter
=
LamboSplitter
.
from_path
(
model_path
,
model_name
)
return
cls
(
model
,
dict
,
splitter
)
...
...
@@ -229,7 +229,7 @@ class Lambo():
if
token_end
:
# End of token
token
=
Token
(
turn_offset
+
token_begin
,
turn_offset
+
i
+
1
,
text
[
token_begin
:(
i
+
1
)],
mwtoken_end
)
if
mwtoken_end
:
if
mwtoken_end
and
self
.
splitter
:
subwords
=
self
.
splitter
.
split
(
token
.
text
)
if
len
(
subwords
)
==
1
:
token
.
is_multi_word
=
False
...
...
This diff is collapsed.
Click to expand it.
src/lambo/utils/printer.py
+
3
−
3
View file @
02d737a1
...
...
@@ -48,11 +48,11 @@ def print_document_to_conll(document, path):
token_text
=
token_text_with_whitespace_for_conllu
(
token
,
document
,
turn
,
sentence
).
strip
()
if
token_text
==
''
:
continue
if
token
.
is_multi_word
and
len
(
token
.
words
)
>
1
:
if
token
.
is_multi_word
and
len
(
token
.
sub
words
)
>
1
:
file1
.
write
(
str
(
token_id
))
file1
.
write
(
'
-
'
+
str
(
token_id
+
len
(
token
.
words
)
-
1
))
file1
.
write
(
'
-
'
+
str
(
token_id
+
len
(
token
.
sub
words
)
-
1
))
file1
.
write
(
'
\t
'
+
token_text
+
'
\t
_
\t
_
\t
_
\t
_
\t
_
\t
_
\t
_
\t
_
\n
'
)
for
word
in
token
.
words
:
for
word
in
token
.
sub
words
:
file1
.
write
(
str
(
token_id
)
+
'
\t
'
+
word
+
'
\t
_
\t
_
\t
_
\t
_
\t
'
+
str
(
token_id
-
1
)
+
'
\t
_
\t
_
\t
_
\n
'
)
token_id
+=
1
else
:
...
...
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