Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
outillage
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alice Brenon
outillage
Commits
210311e5
Commit
210311e5
authored
2 years ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
Add a progress bar to stanza annotator
parent
dddd3e0d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/stanza-txt-annotator.py
+3
-2
3 additions, 2 deletions
scripts/stanza-txt-annotator.py
with
3 additions
and
2 deletions
scripts/stanza-txt-annotator.py
+
3
−
2
View file @
210311e5
...
@@ -5,6 +5,7 @@ import os.path
...
@@ -5,6 +5,7 @@ import os.path
import
stanza
import
stanza
from
stanza.utils.conll
import
CoNLL
from
stanza.utils.conll
import
CoNLL
import
sys
import
sys
from
tqdm
import
tqdm
def
oneLine
(
sentence
):
def
oneLine
(
sentence
):
return
sentence
.
text
.
replace
(
'
\n
'
,
'
'
).
replace
(
'
\t
'
,
'
'
)
return
sentence
.
text
.
replace
(
'
\n
'
,
'
'
).
replace
(
'
\t
'
,
'
'
)
...
@@ -27,7 +28,7 @@ class Annotator:
...
@@ -27,7 +28,7 @@ class Annotator:
def
annotate_dir
(
self
,
directory
):
def
annotate_dir
(
self
,
directory
):
source_path
=
f
'
{
self
.
source
}
/
{
directory
}
'
source_path
=
f
'
{
self
.
source
}
/
{
directory
}
'
os
.
makedirs
(
f
'
{
self
.
target
}
/
{
directory
}
'
,
exist_ok
=
True
)
os
.
makedirs
(
f
'
{
self
.
target
}
/
{
directory
}
'
,
exist_ok
=
True
)
for
name
in
os
.
listdir
(
source_path
):
for
name
in
tqdm
(
os
.
listdir
(
source_path
)
)
:
path
=
f
'
{
source_path
}
/
{
name
}
'
path
=
f
'
{
source_path
}
/
{
name
}
'
relpath
=
f
'
{
directory
}
/
{
name
}
'
relpath
=
f
'
{
directory
}
/
{
name
}
'
if
os
.
path
.
isdir
(
path
):
if
os
.
path
.
isdir
(
path
):
...
@@ -40,13 +41,13 @@ class Annotator:
...
@@ -40,13 +41,13 @@ class Annotator:
if
not
os
.
path
.
isfile
(
outputFile
):
if
not
os
.
path
.
isfile
(
outputFile
):
with
open
(
f
'
{
self
.
source
}
/
{
file
}
'
,
'
r
'
)
as
source
:
with
open
(
f
'
{
self
.
source
}
/
{
file
}
'
,
'
r
'
)
as
source
:
document
=
source
.
read
()
document
=
source
.
read
()
print
(
"
trying
"
+
outputFile
)
try
:
try
:
with
open
(
outputFile
,
'
w
'
)
as
target
:
with
open
(
outputFile
,
'
w
'
)
as
target
:
for
paragraph
in
document
.
split
(
'
\n\n
'
):
for
paragraph
in
document
.
split
(
'
\n\n
'
):
# print(f'# newpar id = {self.newpar()}', file=target)
# print(f'# newpar id = {self.newpar()}', file=target)
self
.
annotate_paragraph
(
paragraph
,
target
)
self
.
annotate_paragraph
(
paragraph
,
target
)
except
Exception
:
except
Exception
:
print
(
"
Failed trying
"
+
outputFile
)
os
.
unlink
(
outputFile
)
os
.
unlink
(
outputFile
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
...
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