File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99
1010import joblib
1111import numpy as np
12+ from rich .console import Console
13+ from rich .tree import Tree
1214
1315from turftopic .container import TopicContainer
1416
@@ -157,6 +159,26 @@ def __iter__(self):
157159 def get_vocab (self ) -> np .ndarray :
158160 return self .vocab
159161
162+ def __str__ (self ):
163+ console = Console ()
164+ with console .capture () as capture :
165+ tree = Tree ("TopicData" )
166+ for key , value in self .items ():
167+ if value is None :
168+ continue
169+ if hasattr (value , "shape" ):
170+ text = f"{ key } { value .shape } "
171+ elif hasattr (value , "__len__" ):
172+ text = f"{ key } ({ len (value )} )"
173+ else :
174+ text = key
175+ tree .add (text )
176+ console .print (tree )
177+ return capture .get ()
178+
179+ def __repr__ (self ):
180+ return str (self )
181+
160182 def visualize_topicwizard (self , ** kwargs ):
161183 """Opens the topicwizard web app with which you can interactively investigate your model.
162184 See [topicwizard's documentation](https://github.com/x-tabdeveloping/topicwizard) for more detail.
You can’t perform that action at this time.
0 commit comments