コード例 #1
0
ファイル: brancher.py プロジェクト: ptigwe/brancher
    def add_word(self, text):
        search_res = Goo.search(text)

        ls = ListSelection(search_res[1], "Select the correct word entry", self)
        if ls.exec_() == QDialog.Accepted:
            w_idx = ls.get_value()[0]
            text_res = search_res[1][int(w_idx)].split(u'【')
            if len(text_res) == 2:
                text = text_res[1][:-1]
            definitions = Goo.get_definition(text, link=search_res[0][int(w_idx)])

            ls = ListSelection(definitions, "Select the desired definition", self, True)
            if ls.exec_() == QDialog.Accepted:
                #d_idx = ls.get_value()[0]
                res = ls.get_value()
                print 'Res', len(res)
                for d_idx in res:
                    definition = definitions[int(d_idx)]
                    print d_idx
                    print definition
                    sentence = u''
                    #sen_res = Tatoeba.search(text)

                    #ls = ListSelection(sen_res, "Select a sample sentence", self)
                    #if ls.exec_() == QDialog.Accepted:
                    #    s_idx = ls.get_value()[0]
                    #    sentence = sen_res[int(s_idx)]

                    self.add_word_with_definition(text, definition, sentence)
コード例 #2
0
ファイル: main.py プロジェクト: ptigwe/brancher
def main():
    import sys  
    reload(sys)  
    sys.setdefaultencoding('utf8')

    s = raw_input()
    tree = None
    while s != "Done":
        search_res = Goo.search(s)
        for i in range(len(search_res[1])):
            print i, search_res[1][i]
        idx = int(raw_input())
        definition = Goo.get_definition(s, link=search_res[0][idx])
        for i in range(len(definition)):
            print i, definition[i]
        def_idx = int(raw_input())
        if tree is not None:
            tree.show()
            parent = raw_input()
            tree.create_node(s, s, parent=parent)
        else:
            tree = Tree()
            tree.create_node(s, s)
        s = raw_input()