Commit fe6274be authored by Kathryn Elliott's avatar Kathryn Elliott

Separate out the coherence calculation.

parent fbb9192a
......@@ -277,6 +277,16 @@ class TopicModel:
return((max_n, max_model))
def calculate_coherence_models(self):
self._coherence_models = {}
# Documentation for these parameters: https://radimrehurek.com/gensim/models/coherencemodel.html
for topic_number, max_topic in self._topics_generator():
self._logging.info("Calulating coherence model for {0}.".format(topic_number))
self._coherence_models[topic_number] = CoherenceModel(model = self._models[topic_number], texts = self._corpus, dictionary = self._dictionary, coherence='c_v')
self._logging.info("Topic coherence: {0}".format(self._coherence_models[topic_number].get_coherence()))
def export_topics_per_documents(self, topic_id):
fields = ["topic_id", "document_id", "probability"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment