def pipelineParsing(grammar, language, sentences, K=20): #buf = [sent for sent in sentences]; buf, sentences = itertools.tee(sentences, 2); sentences = itertools.imap(gf_utils.lexer(lang=language), sentences); parser = gf_utils.getKBestParses(grammar, language, K, callbacks=[("PN", parseNames(grammar, language)), ("Symb", parseUnknown(grammar, language))]); for sent, (time, parsesBlock) in itertools.izip(buf, itertools.imap(parser, sentences)): yield (sent, parsesBlock);
def pipelineParsing(grammar, language, sentences, K=20): #buf = [sent for sent in sentences]; buf, sentences = itertools.tee(sentences, 2) parser = gf_utils.getKBestParses(grammar, language, K) for sent, (time, parsesBlock) in zip(buf, map(parser, sentences)): # print("before parser = ") yield (sent, parsesBlock)
def pipelineParsing(grammar, language, sentences, K=20): #buf = [sent for sent in sentences]; buf, sentences = itertools.tee(sentences, 2); sentences = itertools.imap(gf_utils.lexer(lang=language), sentences); parser = gf_utils.getKBestParses(grammar, language, K); for sent, (time, parsesBlock) in itertools.izip(buf, itertools.imap(parser, sentences)): yield (sent, parsesBlock);