本文整理汇总了Python中orangecontrib.text.corpus.Corpus.from_numpy方法的典型用法代码示例。如果您正苦于以下问题:Python Corpus.from_numpy方法的具体用法?Python Corpus.from_numpy怎么用?Python Corpus.from_numpy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orangecontrib.text.corpus.Corpus
的用法示例。
在下文中一共展示了Corpus.from_numpy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from orangecontrib.text.corpus import Corpus [as 别名]
# 或者: from orangecontrib.text.corpus.Corpus import from_numpy [as 别名]
def main():
from Orange.data import Table, Domain, ContinuousVariable, StringVariable
words = 'hey~mr. tallyman tally~me banana daylight come and me wanna go home'
words = np.array([w.replace('~', ' ') for w in words.split()], dtype=object, ndmin=2).T
weights = np.random.random((len(words), 1))
data = np.zeros((len(words), 0))
metas = []
for i, w in enumerate(weights.T):
data = np.column_stack((data, words, w))
metas = metas + [StringVariable('Topic' + str(i)),
ContinuousVariable('weights')]
domain = Domain([], metas=metas)
table = Table.from_numpy(domain,
X=np.zeros((len(words), 0)),
metas=data)
app = QtGui.QApplication([''])
w = OWWordCloud()
w.on_topics_change(table)
domain = Domain([], metas=[StringVariable('text')])
data = Corpus.from_numpy(domain, X=np.zeros((1, 0)), metas=np.array([[' '.join(words.flat)]]))
w.on_corpus_change(data)
w.show()
app.exec()