def create_words_table(words: List) -> Table: words_var = StringVariable("Words") words_var.attributes = {"type": "words"} domain = Domain([], metas=[words_var]) data = [[w] for w in words] words = Table.from_list(domain, data) words.name = "Words" return words
def commit(self): selection = self._get_selected_words_indices() self.selected_words = set(np.array(self.words_model)[selection]) words, selected_words = None, None if self.words_model: words_var = StringVariable("Words") words_var.attributes = {"type": "words"} domain = Domain([], metas=[words_var]) _words = Table.from_list(domain, [[w] for w in self.words_model]) _words.name = "Words" if selection: selected_words = _words[selection] words = create_annotated_table(_words, selection) self.Outputs.words.send(words) self.Outputs.selected_words.send(selected_words)
def commit(self): if not self.sig_words: self.Outputs.words.send(None) # retrieve the data except the header tree = np.array(self.tree_to_table(), dtype=object)[1:] words_var = StringVariable("Words") words_var.attributes = {"type": "words"} attrs = [ContinuousVariable("p-values"), ContinuousVariable("FDR values")] domain = Domain(attrs, metas=[words_var]) X = tree.take([1, 2], axis=1).astype(float) metas = tree.take([0], axis=1) words = Table.from_numpy(domain, X=X, metas=metas) words.name = "Words" self.Outputs.words.send(words)
def commit(self): words = None if self.selected_words: words_var = StringVariable(WORDS_COLUMN_NAME) words_var.attributes = {"type": "words"} model = self.model attrs = [ ContinuousVariable(model.headerData(i + 1, Qt.Horizontal)) for i in range(len(self.selected_scoring_methods)) ] domain = Domain(attrs, metas=[words_var]) sort_column, reverse = self.sort_column_order data = sorted(model, key=lambda a: a[sort_column], reverse=reverse) data = [s[1:] + s[:1] for s in data if s[0] in self.selected_words] words = Table.from_list(domain, data) words.name = "Words" self.Outputs.words.send(words)
sort_column, reverse = self.sort_column_order data = sorted(model, key=lambda a: a[sort_column], reverse=reverse) data = [s[1:] + s[:1] for s in data if s[0] in self.selected_words] words = Table.from_list(domain, data) words.name = "Words" self.Outputs.words.send(words) def send_report(self): if not self.corpus: return self.report_data("Corpus", self.corpus) if self.words is not None: self.report_paragraph("Words", ", ".join(self.words)) self.report_table("Keywords", self.view, num_format="{:.3f}") if __name__ == "__main__": # pylint: disable=ungrouped-imports from Orange.widgets.utils.widgetpreview import WidgetPreview words_var_ = StringVariable(WORDS_COLUMN_NAME) words_var_.attributes = {"type": "words"} lists = [[w] for w in ["human", "graph", "minors", "trees"]] words_ = Table.from_list(Domain([], metas=[words_var_]), lists) words_.name = "Words" WidgetPreview(OWKeywords).run( set_corpus=Corpus.from_file("deerwester"), # deerwester book-excerpts # set_words=words_ )