org.knowceans.corpus.analysis
Class AtmTopicsConverter

java.lang.Object
  extended by org.knowceans.corpus.analysis.TopicsConverter
      extended by org.knowceans.corpus.analysis.AtmTopicsConverter

public class AtmTopicsConverter
extends TopicsConverter

ActorMediaTopicAnalyser analyses the results of an LS-AMQ run. It performs the same operations as TopicAnalyser but replaces documents by actors.

Author:
heinrich

Field Summary
private  java.util.Vector<java.lang.String> allActors
           
private  java.util.HashSet<java.lang.Integer> queryActors
           
 
Constructor Summary
AtmTopicsConverter()
           
 
Method Summary
protected  void analyseMatching(java.lang.String modelname, java.lang.String suffix)
          Analyse binary actor--topic relations using KL divergence.
private static double kl(double[] p, double[] q)
          KL-divergence between distributions p and q.
static void main(java.lang.String[] args)
           
private  double[][] matchActors(double[][][] psi, int p, int q, boolean queryActorsOnly)
          Build matrix of actor--actor matches according to the Kullback-Leibler-divergence, M_ij = KL(demand_i||supply_j).
private  java.util.HashSet<java.lang.Integer> readActors(java.lang.String modelname)
          read the actor indices of all actors and those that posted queries.
 void run(java.lang.String directory, java.lang.String model, java.lang.String suffix)
          performs topic analysis, including query topics
static void saveMatching(java.lang.String filename, java.util.Vector<org.knowceans.map.TreeMultiMap<java.lang.Double,java.lang.Integer>> actors, java.lang.String comment, java.lang.String additional)
          save the matching information between actors.
private  org.knowceans.map.TreeMultiMap<java.lang.Double,java.lang.Integer> sort(double[] ds, int i, double d)
          sort the array in descending order.
 
Methods inherited from class org.knowceans.corpus.analysis.TopicsConverter
analyse, extractTopics, normaliseRows, posterior, posterior, printMatrix, run, saveTopics, test, truncateMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

allActors

private java.util.Vector<java.lang.String> allActors

queryActors

private java.util.HashSet<java.lang.Integer> queryActors
Constructor Detail

AtmTopicsConverter

public AtmTopicsConverter()
Method Detail

main

public static void main(java.lang.String[] args)

run

public void run(java.lang.String directory,
                java.lang.String model,
                java.lang.String suffix)
performs topic analysis, including query topics


analyseMatching

protected void analyseMatching(java.lang.String modelname,
                               java.lang.String suffix)
Analyse binary actor--topic relations using KL divergence.

Parameters:
modelname - model file name without extension
suffix - of binary files added to model name
comment - for original matrix

saveMatching

public static void saveMatching(java.lang.String filename,
                                java.util.Vector<org.knowceans.map.TreeMultiMap<java.lang.Double,java.lang.Integer>> actors,
                                java.lang.String comment,
                                java.lang.String additional)
save the matching information between actors.

Parameters:
filename -
actors -
comment -
additional -

sort

private org.knowceans.map.TreeMultiMap<java.lang.Double,java.lang.Integer> sort(double[] ds,
                                                                                int i,
                                                                                double d)
sort the array in descending order. XXX: very similar to TopicAnalyser.extractTopics()

Parameters:
ds - array
i - maximum elements in return type or -1
d - minimum element value
Returns:

matchActors

private double[][] matchActors(double[][][] psi,
                               int p,
                               int q,
                               boolean queryActorsOnly)
Build matrix of actor--actor matches according to the Kullback-Leibler-divergence, M_ij = KL(demand_i||supply_j).

Parameters:
psi - matrix[][][] of actor--topic associations, by relations in first index
p - relation of left KL argument
q - relation of right KL argument
queryActorsOnly - set KL divergence to Double.INF for all non-querying actors
Returns:

kl

private static double kl(double[] p,
                         double[] q)
KL-divergence between distributions p and q. (The measure is asymmetric: KL(p||q) = int p(x) * log(p(x)/q(x)) dx).

Parameters:
p - discrete pdf
q - discrete pdf (q.length = p.length)
Returns:
KL divergence

readActors

private java.util.HashSet<java.lang.Integer> readActors(java.lang.String modelname)
read the actor indices of all actors and those that posted queries.

Parameters:
modelname -
Returns: