本文整理匯總了Python中nltk.tag.stanford.NERTagger.batch_tag方法的典型用法代碼示例。如果您正苦於以下問題:Python NERTagger.batch_tag方法的具體用法?Python NERTagger.batch_tag怎麽用?Python NERTagger.batch_tag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nltk.tag.stanford.NERTagger
的用法示例。
在下文中一共展示了NERTagger.batch_tag方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from nltk.tag.stanford import NERTagger [as 別名]
# 或者: from nltk.tag.stanford.NERTagger import batch_tag [as 別名]
def main():
parser = get_argparser()
args = parser.parse_args()
ner = NERTagger('lib/english.all.3class.distsim.crf.ser.gz',
'lib/stanford-ner-2013-06-20.jar',
encoding='utf-8')
text = get_text(args.workid)
sentences = nltk.sent_tokenize(text)
tokenized_sentences = [nltk.word_tokenize(s) for s in sentences]
tagged_sentences = ner.batch_tag(tokenized_sentences)
print(set_of_named_entities(tagged_sentences))
示例2: annotate_ner
# 需要導入模塊: from nltk.tag.stanford import NERTagger [as 別名]
# 或者: from nltk.tag.stanford.NERTagger import batch_tag [as 別名]
def annotate_ner(sentences):
ner = NERTagger('models/nob-ner-model.ser.gz',
'../tools/stanford-ner-2014-01-04/stanford-ner.jar', encoding='utf-8')
return ner.batch_tag(sentences)