Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cclutils
Manage
Activity
Members
Labels
Plan
Issues
1
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
cclutils
Commits
f18a0312
Commit
f18a0312
authored
5 years ago
by
Arkadiusz Janz
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' into 'master'
Sentence/chunk generators See merge request ajanz/cclutils!1
parents
212a8e4a
72657010
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!2
Master merged
,
!1
Sentence/chunk generators
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cclutils/_base.py
+49
-0
49 additions, 0 deletions
cclutils/_base.py
with
49 additions
and
0 deletions
cclutils/_base.py
+
49
−
0
View file @
f18a0312
...
...
@@ -159,3 +159,52 @@ def get_tagset(tagset):
if
isinstance
(
tagset
,
str
):
tagset
=
corpus2
.
get_named_tagset
(
tagset
)
return
tagset
def
read_chunks_it
(
filepath
,
tagset
=
'
nkjp
'
):
"""
Returns a iterable chunk generator.
Args:
filepath: a path to CCL file
tagset: the name of the tagset that is used in the document or a tagset object itself.
Returns:
a iterable chunk generator.
"""
tagset
=
get_tagset
(
tagset
)
reader
=
corpus2
.
TokenReader_create_path_reader
(
'
ccl
'
,
tagset
,
filepath
)
while
True
:
chunk
=
reader
.
get_next_chunk
()
if
not
chunk
:
break
yield
chunk
del
reader
def
read_sentences_it
(
filepath
,
tagset
=
'
nkjp
'
):
"""
Returns a iterable sentence generator.
Args:
filepath: a path to CCL file
tagset: the name of the tagset that is used in the document or a tagset object itself.
Returns:
a iterable sentence generator.
"""
tagset
=
get_tagset
(
tagset
)
reader
=
corpus2
.
TokenReader_create_path_reader
(
'
ccl
'
,
tagset
,
filepath
)
while
True
:
sentence
=
reader
.
get_next_sentence
()
if
not
sentence
:
break
yield
sentence
del
reader
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