def getAllConnects(self, sentence): logging.debug('getAllConnects start') result = [] options = ParseOptions() try: s = sentence.encode('ascii', 'ignore') except: return result sent = Sentence(s, self.dictionary) lc = sent.parse(options) logging.debug('checkSummary sent parsed') if lc == 0: clg.parse_options_set_min_null_count(options._po, 1) clg.parse_options_set_max_null_count( options._po, clg.sentence_length(sent._sent)) lc = sent.parse(options) if lc > 0: linkage = Linkage(0, sent, options) num_links = clg.linkage_get_num_links(linkage._link) for i in range(num_links): label = clg.linkage_get_link_label(linkage._link, i) lword = clg.linkage_get_link_lword(linkage._link, i) rword = clg.linkage_get_link_rword(linkage._link, i) lw = clg.sentence_get_word(sent._sent, lword) rw = clg.sentence_get_word(sent._sent, rword) result.append((label, lword, rword, lw, rw)) del linkage del options del sent logging.debug('getAllConnects end') return result
def __getitem__(self,key): if key<0 or key>=len(self): raise IndexError return clg.sentence_get_word(self._sent,key)
def get_word(self, w): return clg.sentence_get_word(self._sent,w)
def __getitem__(self, key): if key < 0 or key >= len(self): raise IndexError return clg.sentence_get_word(self._sent, key)
def get_word(self, w): return clg.sentence_get_word(self._sent, w)