def print_enhanced_table(self): """Parses CSV table already containing at least two columns with Spanish/English word pairs. The third column is optional and usually contains a 'checked' flag, which declares whether a word has been already validated. The generated table will contain an extra row for a normalized version of the original Spanish word, an extra row for translation (from SpanishDict.com) and an extra column for the word type (e.g. noun). Keyword arguments: src -- path to input CSV file out -- output stream """ thread_pool = ThreadPool(self.__print_enhanced_row) rows = self._parse_src() self.print_header_row(rows[0].get_column_format() if len(rows) > 0 else self._column_format.split('|')) for row in rows: if len(row) < 2: print('Skip incomplete row') else: p = Processable(lambda word: Wordanalyzer.get_translation_es(word), row.original_word, row) p.start() thread_pool.add(p) #end if #end for thread_pool.finish()
def print_table_with_ipa_de(self): """TODO decribe what this method does.""" thread_pool = ThreadPool(self.__print_row_with_ipa) rows = self._parse_src() self.print_header_row(rows[0].get_column_format() if len(rows) > 0 else self._column_format.split('|')) for row in rows: if len(row) < 1: print('Skip incomplete row') else: p = Processable(lambda word: Wordanalyzer.get_ipa_de(word), row[0], row) p.start() thread_pool.add(p) #end if #end for thread_pool.finish()
def print_enhanced_table_en(self): """TODO decribe what this method does.""" thread_pool = ThreadPool(self.__print_enhanced_row_en) rows = self._parse_src() self.print_header_row(rows[0].get_column_format() if len(rows) > 0 else self._column_format.split('|')) for row in rows: if len(row) < 2: print('Skip incomplete row') else: p = Processable(lambda word: Wordanalyzer.get_translation_en(word), row.original_word, row) p.start() thread_pool.add(p) #end if #end for thread_pool.finish()
def print_conjugation_table(self, tenses): """TODO decribe what this method does. Keyword arguments: tenses -- TODO describe what this argument is about """ thread_pool = ThreadPool(self.__print_conjugation_table) rows = self._parse_src() self.print_csv_row(['[Infinitive]', '[yo]', '[tú]', '[el/ella/usted]', '[nosotros, -as]', '[vosotros, -as]', '[ellos/ellas/ustedes]', '[Tense]']) # print header for row in rows: if len(row) < 1: print('Skip incomplete row') else: for tense in tenses: p = Processable(lambda word: Wordanalyzer.get_conjugation_es(word, tense), row.original_word, row) p.start() thread_pool.add(p) #end for #end if #end for thread_pool.finish()