verbchains = []
for sentence in sentences:
chains = self.__verbchain_detector.detectVerbChainsFromSent(sentence)
offset = 0
for chain in chains:
chain[PHRASE] = [idx+offset for idx in chain[PHRASE]]
chain[START] = self[WORDS][chain[PHRASE][0]][START]
chain[END] = self[WORDS][chain[PHRASE][-1]][END]
offset += len(sentence)
verbchains.extend(chains)
self[VERB_CHAINS] = verbchains
return self
After Change
for chain in chains:
// 1) Get spans for all words of the phrase
word_spans = [ ( sentence[idx][START], sentence[idx][END] ) \
for idx in sorted( chain[PHRASE] ) ]
// 2) Assign to the chain
chain[START] = [ span[0] for span in word_spans ]
chain[END] = [ span[1] for span in word_spans ]
verbchains.extend(chains)
self[VERB_CHAINS] = verbchains
return self