package com.davidbracewell.apollo.ml.clustering.topic;

import com.davidbracewell.apollo.affinity.DistanceMeasure;
import com.davidbracewell.apollo.linalg.Vector;
import com.davidbracewell.apollo.ml.EncoderPair;
import com.davidbracewell.apollo.ml.Instance;
import com.davidbracewell.apollo.ml.clustering.flat.FlatClustering;
import com.davidbracewell.apollo.optimization.Optimum;
import com.davidbracewell.collection.counter.Counter;
import lombok.NonNull;

/**
 * @author David B. Bracewell
 */
public abstract class TopicModel extends FlatClustering {
   private static final long serialVersionUID = 1L;
   protected int K;

   @Override
   public int size() {
      return K;
   }

   protected TopicModel(EncoderPair encoderPair, DistanceMeasure distanceMeasure) {
      super(encoderPair, distanceMeasure);
   }

   @Override
   public int hardCluster(@NonNull Instance instance) {
      return Optimum.MAXIMUM.optimumIndex(softCluster(instance));
   }

   /**
    * Gets topic vector.
    *
    * @param topic the topic
    * @return the topic vector
    */
   public abstract Vector getTopicVector(int topic);

   /**
    * Gets the words and their probabilities for a given topic
    *
    * @param topic the topic
    * @return the topic words
    */
   public abstract Counter<String> getTopicWords(int topic);

   /**
    * Gets the distribution across topics for a given feature.
    *
    * @param feature the feature (word) whose topic distribution is desired
    * @return the distribution across topics for the given feature
    */
   public abstract double[] getTopicDistribution(String feature);

}// END OF TopicModel

@@ -442,23 +442,67 @@
  lombok.
-NonNull
+Getter;%0Aimport lombok.NonNull;%0Aimport lombok.Setter
 ;%0A%0A/**%0A 
@@ -651,82 +651,46 @@
 %0A   
-protected int K;%0A%0A   @Override%0A   public int size() %7B%0A      return K;%0A   %7D
+@Getter%0A   @Setter%0A   protected int K;
 %0A%0A  
@@ -827,144 +827,296 @@
 %0A   
-@Override%0A   public int hardCluster(@NonNull Instance instance) %7B%0A 
+/**%0A    * Gets the distribution across topics for a given feature.%0A    *%0A    * @param feature the feature (word) whose topic distribution is desired%0A
     
- 
+* @
 return 
-Optimum.MAXIMUM.optimumIndex(softCluster(instance));%0A   %7D
+the distribution across topics for the given feature%0A    */%0A   public abstract double%5B%5D getTopicDistribution(String feature);
 %0A%0A  
@@ -1483,296 +1483,202 @@
 %0A   
-/**%0A    * Gets the distribution across topics for a given feature.%0A    *%0A    * @param feature the feature (word) whose topic distribution is desired%0A    * @return the distribution across topics for the given feature%0A    */%0A   public abstract double%5B%5D getTopicDistribution(String feature);
+@Override%0A   public int hardCluster(@NonNull Instance instance) %7B%0A      return Optimum.MAXIMUM.optimumIndex(softCluster(instance));%0A   %7D%0A%0A   @Override%0A   public int size() %7B%0A      return K;%0A   %7D
 %0A%0A%7D/

Make abstract Topic model