コード例 #1
0
    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
コード例 #2
0
ファイル: linkgrammar.py プロジェクト: alebahn/Understander
	def get_link_rword(self,index):
		return clg.linkage_get_link_rword(self._link,index)
コード例 #3
0
 def get_link_rword(self, index):
     return clg.linkage_get_link_rword(self._link, index)