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
d46fe12a
Project 'ajanz/cclutils' was moved to 'analysers/cclutils'. Please update any links and bookmarks that may still have the old path.
Commit
d46fe12a
authored
5 years ago
by
Piotr Wątorski
Browse files
Options
Downloads
Patches
Plain Diff
Sentence/chunk generators
parent
212a8e4a
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1
Sentence/chunk generators
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cclutils/_base.py
+50
-0
50 additions, 0 deletions
cclutils/_base.py
with
50 additions
and
0 deletions
cclutils/_base.py
+
50
−
0
View file @
d46fe12a
...
...
@@ -159,3 +159,53 @@ 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 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
:
chunk
=
reader
.
get_next_chunk
()
if
chunk
:
yield
chunk
else
:
break
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
sentence
:
yield
sentence
else
:
break
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