Projects STRLCPY Maryam Commits f46565d6
🤬
  • Adding the --output and --api functionality. Tested by using = topicmodeling -i mixed.json -t json -m all-distilroberta-v1 --output report json testreport iris/topicmodeling topicmodeling -i mixed.json -t json -m all-distilroberta-v1 --api

  • Loading...
  • Hatma Suryotrisongko committed 2 years ago
    f46565d6
    1 parent bd4089ee
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■
    maryam/core/util/iris/plotly.py maryam/core/util/iris/plotlyutil.py
    skipped 11 lines
    12 12  along with this program. If not, see <http://www.gnu.org/licenses/>.
    13 13  """
    14 14   
    15  -import plotly
     15 +import plotlyutil
    16 16   
    17 17  class main:
    18 18   
    skipped 20 lines
  • ■ ■ ■ ■ ■ ■
    maryam/core/util/iris/topic.py
    skipped 156 lines
    157 157   
    158 158   topics, _ = topic_model.fit_transform(self.corpus)
    159 159   print(topic_model.get_topic_info()[:6])
     160 + output = topic_model.get_topic_info()
    160 161   
    161 162   corpus_labeled = pd.DataFrame({'ClusterLabel': topics, 'Sentence': self.corpus})
    162 163   if verbose == True:
    skipped 7 lines
    170 171   print("Cluster #" + str(i) + " = ")
    171 172   print(topic_model.get_topic(i))
    172 173   i += 1
     174 + 
     175 + return output
    173 176   
    174 177   
  • ■ ■ ■ ■ ■ ■
    maryam/modules/iris/topicmodeling.py
    skipped 14 lines
    15 15   'author': 'Hatma Suryotrisongko',
    16 16   'version': '0.1.0',
    17 17   'description': 'Topic Modeling Algorithms.',
     18 + 'required': ('dask', 'scikit-learn', 'umap', 'bertopic', 'gensim'),
    18 19   'options': (
    19 20   ('inputfile', None, True, 'Input file that contains the data', '-i', 'store', str),
    20 21   ('filetype', None, True, 'File type: csv/json', '-t', 'store', str),
    skipped 9 lines
    30 31   
    31 32   run = self.topic(self.options['inputfile'], self.options['filetype'], self.options['showcharts'], self.options['verbose'])
    32 33   run.run_sklearn_cluster_kmeans(self.options['pretrained_model'], self.options['showcharts'], self.options['verbose'])
    33  - run.run_topic_modeling_bertopic(self.options['pretrained_model'], self.options['verbose'])
     34 + 
     35 + results = run.run_topic_modeling_bertopic(self.options['pretrained_model'], self.options['verbose'])
     36 + print("\n\nResults = \n")
     37 + print( results )
     38 + 
     39 + output = {'results': results.to_json(orient="records") }
     40 + print("\n\nOutput = \n")
     41 + print( output )
     42 + 
     43 + inputfile = self.options['inputfile']
     44 + self.save_gather(output, 'iris/topicmodeling', inputfile, output=self.options['output'])
     45 + 
     46 + return output
    34 47   
    35 48   
    36 49  def module_run(self):
    skipped 1 lines
Please wait...
Page is in error, reload to recover