本文整理匯總了Python中nltk.TreebankWordTokenizer方法的典型用法代碼示例。如果您正苦於以下問題:Python nltk.TreebankWordTokenizer方法的具體用法?Python nltk.TreebankWordTokenizer怎麽用?Python nltk.TreebankWordTokenizer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nltk
的用法示例。
在下文中一共展示了nltk.TreebankWordTokenizer方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import nltk [as 別名]
# 或者: from nltk import TreebankWordTokenizer [as 別名]
def __init__(self):
self._word_tokenizer = nltk.TreebankWordTokenizer()
if FLAGS.punkt_tokenizer_file is not None:
self._sent_tokenizer = py_utils.load_pickle(FLAGS.punkt_tokenizer_file)
else:
self._sent_tokenizer = nltk.load("tokenizers/punkt/english.pickle")
示例2: _treebank_en
# 需要導入模塊: import nltk [as 別名]
# 或者: from nltk import TreebankWordTokenizer [as 別名]
def _treebank_en(self, text):
if self.word_tokenizer is None:
import nltk
self.word_tokenizer = nltk.TreebankWordTokenizer()
return [
token.replace("''", '"').replace("``", '"')
for token in self.word_tokenizer.tokenize(text)
]
示例3: tokenize
# 需要導入模塊: import nltk [as 別名]
# 或者: from nltk import TreebankWordTokenizer [as 別名]
def tokenize(self, text):
return TreebankWordTokenizer().tokenize(text)
示例4: __init__
# 需要導入模塊: import nltk [as 別名]
# 或者: from nltk import TreebankWordTokenizer [as 別名]
def __init__(self):
self.sent_tokenzier = nltk.load('tokenizers/punkt/english.pickle')
self.word_tokenizer = nltk.TreebankWordTokenizer()