本文整理汇总了Python中nltk.corpus.reader.util.concat函数的典型用法代码示例。如果您正苦于以下问题:Python concat函数的具体用法?Python concat怎么用?Python concat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了concat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: words
def words(self, fileids=None, **kwargs):
return concat(
[
self._view(fileid, tags=False, **kwargs)
for fileid in self._list_morph_files(fileids)
]
)
示例2: raw
def raw(self, fileids=None, **kwargs):
"""
Returns words in specified fileids.
"""
return concat([self._view(self.add_root(fileid),
mode=NKJPCorpusReader.RAW_MODE, **kwargs).handle_query()
for fileid in fileids])
示例3: header
def header(self, fileids=None, **kwargs):
"""
Returns header(s) of specified fileids.
"""
return concat([self._view(self.add_root(fileid),
mode=NKJPCorpusReader.HEADER_MODE, **kwargs).handle_query()
for fileid in fileids])
示例4: sents
def sents(self, fileids=None, **kwargs):
"""
Returns sentences in specified fileids.
"""
return concat([self._view(self.add_root(fileid),
mode=NKJPCorpusReader.SENTS_MODE, **kwargs).handle_query()
for fileid in fileids])
示例5: tagged_paras
def tagged_paras(self, fileids=None, **kwargs):
return concat(
[
self._view(fileid, mode=IPIPANCorpusView.PARAS_MODE, **kwargs)
for fileid in self._list_morph_files(fileids)
]
)
示例6: raw
def raw(self, fileids=None):
"""
:return: the given file(s) as a single string.
:rtype: str
"""
if fileids is None: fileids = self._fileids
elif isinstance(fileids, basestring): fileids = [fileids]
return concat([self.open(f).read() for f in fileids])
示例7: parsed_sents2
def parsed_sents2(self, fileids=None):
return concat([JapaneseCorpusView(fileid, enc,
False, False, False, True,
self._syntax_parser,
self._word_tokenizer,
self._sent_tokenizer,
self._case_parser)
for (fileid, enc) in self.abspaths(fileids, True)])
示例8: fixed_parsed_sents
def fixed_parsed_sents(self, fileids=None, top_label="root"):
from nltk.corpus.reader.util import concat
from nltk.corpus.reader.dependency import DependencyCorpusView
from nltk.parse import DependencyGraph
sents=concat([DependencyCorpusView(fileid, False, True, True, encoding=enc)
for fileid, enc in self.abspaths(fileids, include_encoding=True)])
return [DependencyGraph(sent, top_relation_label=top_label, cell_separator="\t") for sent in sents]
示例9: tagged_words
def tagged_words(self, fileids=None, **kwargs):
"""
Call with specified tags as a list, e.g. tags=['subst', 'comp'].
Returns tagged words in specified fileids.
"""
tags = kwargs.pop('tags', [])
return concat([self._view(self.add_root(fileid),
mode=NKJPCorpusReader.WORDS_MODE, tags=tags, **kwargs).handle_query()
for fileid in fileids])
示例10: _views
def _views(self, fileids=None, sent=False, tag=False, strip_space=True, stem=False):
"""A helper function that instantiates BNCWordViews or the list of words/sentences."""
f = BNCWordView if self._lazy else self._words
return concat(
[
f(fileid, sent, tag, strip_space, stem)
for fileid in self.abspaths(fileids)
]
)
示例11: raw
def raw(self, fileids=None):
"""
Return the corpora in their raw form.
"""
if fileids is None:
fileids = self._fileids
elif isinstance(fileids, string_types):
fileids = [fileids]
return concat([self.open(f).read() for f in fileids])
示例12: sents
def sents(self, fileids=None, **kwargs):
return concat(
[
self._view(
fileid, mode=IPIPANCorpusView.SENTS_MODE, tags=False, **kwargs
)
for fileid in self._list_morph_files(fileids)
]
)
示例13: aligned_sents
def aligned_sents(self, fileids=None):
"""
:return: the given file(s) as a list of AlignedSent objects.
:rtype: list of C{AlignedSent}
"""
return concat([AlignedSentCorpusView(fileid, enc, True, True,
self._word_tokenizer,
self._sent_tokenizer,
self._alignedsent_block_reader)
for (fileid, enc) in self.abspaths(fileids, True)])
示例14: words
def words(self, fileids=None):
"""
@return: the given file(s) as a list of words
and punctuation symbols.
@rtype: C{list} of C{str}
"""
return concat([self._alignedsent_corpus_view(fileid, enc, False, False,
self._word_tokenizer,
self._sent_tokenizer,
self._alignedsent_block_reader)
for (fileid, enc) in self.abspaths(fileids, True)])
示例15: parsed_docs
def parsed_docs(self, fileids=None):
"""
@return: A list of parsed corpus documents.
@rtype: C{list} of C{StreamBackedCorpusView}
@param fileids: A list of corpus files.
@type fileids: C{list} of C{str} or regular expression
"""
return concat([StreamBackedCorpusView(fileid,
self._read_parsed_block,
encoding=enc)
for (fileid, enc) in self.abspaths(fileids, True)])