from nltk.chunk import ChunkParserI
from nltk.chunk.util import conlltags2tree
from nltk.corpus import gazetteers
class LocationChunker(ChunkParserI):
def __init__(self):
self.locations = set(gazetteers.words())
self.lookahead = 0
for loc in self.locations:
nwords = loc.count(' ')
if nwords > self.lookahead:
self.lookahead = nwords
nltk.chunk 中的 ChunkParserI 是什么?它究竟是为了什么?另外,请解释代码。分块和解析有什么区别?