x-tabdeveloping / turftopic

Robust and fast topic models with sentence-transformers.
https://x-tabdeveloping.github.io/turftopic/
MIT License
8 stars 3 forks source link

Implement exporting tables from models describing topics #12

Closed x-tabdeveloping closed 4 months ago

x-tabdeveloping commented 4 months ago

Rationale:

Topics can already be described in the models by using the print_topics() method. The problem is that this does not output the table in a reusable format. If some user wants to topic descriptions as a format that can be reused and imported in other types of software, this is impractical. We should provide some easy method to achieve this in Turftopic.

Implementation:

I have a couple of approaches up my sleeve for this:

  1. We can create a new method, which returns the topic descriptions in a pd.DataFrame. This would make it easy for data scientists to work with, but would introduce pandas as a dependency, which I would love to avoid.
  2. We can add a parameter to print_topics(), that specifies the format in which it should be printed, e.g. model.print_topics(format="csv"). This would allow users to pipe stdout into a csv file. This would not introduce dependencies, but would be a bit less intuitive.
  3. We could add a method that returns a string model.export_topics(format="csv") and then users are able to print this or write it out to a file.
x-tabdeveloping commented 4 months ago

Addressed by #13