本文整理汇总了Python中nltk.corpus.reader.xmldocs.XMLCorpusReader.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python XMLCorpusReader.__init__方法的具体用法?Python XMLCorpusReader.__init__怎么用?Python XMLCorpusReader.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.corpus.reader.xmldocs.XMLCorpusReader
的用法示例。
在下文中一共展示了XMLCorpusReader.__init__方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from nltk.corpus.reader.xmldocs import XMLCorpusReader [as 别名]
# 或者: from nltk.corpus.reader.xmldocs.XMLCorpusReader import __init__ [as 别名]
def __init__(self, root, fileids='.*'):
"""
Corpus reader designed to work with National Corpus of Polish.
See http://nkjp.pl/ for more details about NKJP.
use example:
import nltk
import nkjp
from nkjp import NKJPCorpusReader
x = NKJPCorpusReader(root='/home/USER/nltk_data/corpora/nkjp/', fileids='') # obtain the whole corpus
x.header()
x.raw()
x.words()
x.tagged_words(tags=['subst', 'comp']) #Link to find more tags: nkjp.pl/poliqarp/help/ense2.html
x.sents()
x = NKJPCorpusReader(root='/home/USER/nltk_data/corpora/nkjp/', fileids='Wilk*') # obtain particular file(s)
x.header(fileids=['WilkDom', '/home/USER/nltk_data/corpora/nkjp/WilkWilczy'])
x.tagged_words(fileids=['WilkDom', '/home/USER/nltk_data/corpora/nkjp/WilkWilczy'], tags=['subst', 'comp'])
"""
if isinstance(fileids, string_types):
XMLCorpusReader.__init__(self, root, fileids + '.*/header.xml')
else:
XMLCorpusReader.__init__(
self, root, [fileid + '/header.xml' for fileid in fileids]
)
self._paths = self.get_paths()
示例2: __init__
# 需要导入模块: from nltk.corpus.reader.xmldocs import XMLCorpusReader [as 别名]
# 或者: from nltk.corpus.reader.xmldocs.XMLCorpusReader import __init__ [as 别名]
def __init__(self, *args, **kwargs):
if 'textid_file' in kwargs: self._textids = kwargs['textid_file']
else: self._textids = None
XMLCorpusReader.__init__(self, *args)
CategorizedCorpusReader.__init__(self, kwargs)
self._init_textids()
示例3: __init__
# 需要导入模块: from nltk.corpus.reader.xmldocs import XMLCorpusReader [as 别名]
# 或者: from nltk.corpus.reader.xmldocs.XMLCorpusReader import __init__ [as 别名]
def __init__(self, root, fileids, wrap_etree=False):
XMLCorpusReader.__init__(self, root, fileids, wrap_etree)
self._lemma_to_class = defaultdict(list)
"""A dictionary mapping from verb lemma strings to lists of
verbnet class identifiers."""
self._wordnet_to_class = defaultdict(list)
"""A dictionary mapping from wordnet identifier strings to
lists of verbnet class identifiers."""
self._class_to_fileid = {}
"""A dictionary mapping from class identifiers to
corresponding file identifiers. The keys of this dictionary
provide a complete list of all classes and subclasses."""
self._shortid_to_longid = {}
# Initialize the dictionaries. Use the quick (regexp-based)
# method instead of the slow (xml-based) method, because it
# runs 2-30 times faster.
self._quick_index()
示例4: __init__
# 需要导入模块: from nltk.corpus.reader.xmldocs import XMLCorpusReader [as 别名]
# 或者: from nltk.corpus.reader.xmldocs.XMLCorpusReader import __init__ [as 别名]
def __init__(self, root, fileids, lazy=True):
XMLCorpusReader.__init__(self, root, fileids)
self._lazy = lazy
示例5: __init__
# 需要导入模块: from nltk.corpus.reader.xmldocs import XMLCorpusReader [as 别名]
# 或者: from nltk.corpus.reader.xmldocs.XMLCorpusReader import __init__ [as 别名]
def __init__(self, root, fileids, wordnet, lazy=True):
XMLCorpusReader.__init__(self, root, fileids)
self._lazy = lazy
self._wordnet = wordnet
示例6: __init__
# 需要导入模块: from nltk.corpus.reader.xmldocs import XMLCorpusReader [as 别名]
# 或者: from nltk.corpus.reader.xmldocs.XMLCorpusReader import __init__ [as 别名]
def __init__(self, root, fileids):
XMLCorpusReader.__init__(self, root, fileids)
示例7: __init__
# 需要导入模块: from nltk.corpus.reader.xmldocs import XMLCorpusReader [as 别名]
# 或者: from nltk.corpus.reader.xmldocs.XMLCorpusReader import __init__ [as 别名]
def __init__(self, root, fileid):
XMLCorpusReader.__init__(self, root, fileid)
self._fileid = self._fileids[0]
self.elt = self.xml()
self.data = _xml_to_dict(self.elt)