Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corpus2
Manage
Activity
Members
Labels
Plan
Issues
4
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
Container Registry
Operate
Environments
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
Analysers
corpus2
Commits
50043d34
There was an error fetching the commit references. Please try again later.
Commit
50043d34
authored
13 years ago
by
ilor
Browse files
Options
Downloads
Patches
Plain Diff
corpus-get upgrade: stop reading corpus after reading the last to-be-returned chunk/sentence
parent
80696f5a
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
corpus2tools/corpus-get
+5
-2
5 additions, 2 deletions
corpus2tools/corpus-get
with
5 additions
and
2 deletions
corpus2tools/corpus-get
+
5
−
2
View file @
50043d34
...
@@ -52,7 +52,7 @@ def chunks(rdr):
...
@@ -52,7 +52,7 @@ def chunks(rdr):
yield
chunk
yield
chunk
def
write_selected_sentences
(
sents
,
writer
,
selection
):
def
write_selected_sentences
(
sents
,
writer
,
selection
,
maxsel
=
None
):
sid
=
0
sid
=
0
for
sent
in
sents
:
for
sent
in
sents
:
if
sid
in
selection
:
if
sid
in
selection
:
...
@@ -65,6 +65,7 @@ def write_selected_sentences(sents, writer, selection):
...
@@ -65,6 +65,7 @@ def write_selected_sentences(sents, writer, selection):
writer
.
write_token
(
tok
)
writer
.
write_token
(
tok
)
tid
+=
1
tid
+=
1
sid
+=
1
sid
+=
1
if
maxsel
is
not
None
and
sid
>
maxsel
:
break
def
go
():
def
go
():
parser
=
OptionParser
(
usage
=
descr
)
parser
=
OptionParser
(
usage
=
descr
)
...
@@ -110,6 +111,7 @@ def go():
...
@@ -110,6 +111,7 @@ def go():
return
return
else
:
else
:
selection
.
update
(
izip
(
parse_range_info
(
arg
),
repeat
(())))
selection
.
update
(
izip
(
parse_range_info
(
arg
),
repeat
(())))
maxsel
=
max
(
selection
.
keys
())
if
selection
==
{}:
if
selection
==
{}:
if
options
.
chunks
:
if
options
.
chunks
:
for
chunk
in
chunks
(
reader
):
for
chunk
in
chunks
(
reader
):
...
@@ -127,8 +129,9 @@ def go():
...
@@ -127,8 +129,9 @@ def go():
else
:
else
:
write_selected_sentences
(
chunk
.
sentences
(),
writer
,
selection
[
cid
])
write_selected_sentences
(
chunk
.
sentences
(),
writer
,
selection
[
cid
])
cid
+=
1
cid
+=
1
if
cid
>
maxsel
:
break
else
:
else
:
write_selected_sentences
(
sentences
(
reader
),
writer
,
selection
)
write_selected_sentences
(
sentences
(
reader
),
writer
,
selection
,
maxsel
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
go
()
go
()
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