예제 #1
0
파일: deck.py 프로젝트: nano13/tambi
    def generateIPATable(self, command, args):
        if command == 'deck.ipaVowels':
            table_type = 'vowels'
        elif command == 'deck.ipaConsonants':
            table_type = 'consonants'
        try:
            deck_prefix = args[0]
        except IndexError:
            """ everything is fine, we just do not have an argument """
            deck_prefix = ''

        deckpath = self.config.readPath("vocable", "deckpath")
        root, dirs, path = next(iter(os.walk(deckpath)))
        dirs.sort()
        """ append all 'phonetical'-characters from all decks to the variable 'result_char_list' and pass it to the ipa-class to generate the table """
        result_char_list = []
        for directory in dirs:
            if directory.startswith(deck_prefix):
                db_path = os.path.join(root, directory, "database.sqlite")
                self.dbAdapter.initialize(db_path)
                result = self.dbAdapter.selectDeckItems()

                for entry in result:
                    phonetical = entry["phonetical"]
                    if phonetical:
                        for char in phonetical:
                            result_char_list.append(char)

        ipa = Ipa()
        result_table, header, header_vertical = ipa._generateIpaTableFromData(
            table_type, result_char_list)

        result_object = Result()
        result_object.category = "table"
        result_object.payload = result_table
        result_object.header = header
        result_object.header_left = header_vertical
        return result_object
예제 #2
0
파일: ipa.py 프로젝트: nano13/tambi
    def generateRawIpaTable(self, command, a):
        if command == 'ipa.vowels':
            phones = self.__getVowelsDict()
            result_table, header, header_vertical = self.__getVowelsRawTable()
        elif command == 'ipa.consonants':
            phones = self.__getConsonantsDict()
            result_table, header, header_vertical = self.__getConsonantsRawTable(
            )

        keys = phones.keys()
        for key in keys:
            position = phones[key]
            try:
                result_table[position[0]][position[1]] = key
            except IndexError:
                pass

        result_object = Result()
        result_object.category = "table"
        result_object.payload = result_table
        result_object.header = header
        result_object.header_left = header_vertical
        return result_object