Ejemplo n.º 1
0
  private void printTopicWordAssignment(int[][] z, Corpus corpus, String filePath) {
    assert (z != null && z.length != 0 && z[0].length != 0) : "The array z is not correct!";

    FileOneByOneLineWriter writer = new FileOneByOneLineWriter(filePath);

    int D = z.length;
    for (int d = 0; d < D; ++d) {
      StringBuilder sbLine = new StringBuilder();
      int N = z[d].length;
      for (int n = 0; n < N; ++n) {
        sbLine.append(corpus.vocab.getWordstrByWordid(corpus.docs[d][n]) + ":" + z[d][n] + " ");
      }
      writer.writeLine(sbLine.toString().trim());
    }
    writer.close();
  }
Ejemplo n.º 2
0
  private void printDocumentTopicDistribution(double[][] dist, String filePath) {
    assert (dist != null && dist.length != 0 && dist[0].length != 0)
        : "The document topic distribution is not correct!";

    FileOneByOneLineWriter writer = new FileOneByOneLineWriter(filePath);

    int D = dist.length;
    for (int d = 0; d < D; ++d) {
      StringBuilder sbLine = new StringBuilder();
      int T = dist[d].length;
      for (int t = 0; t < T; ++t) {
        sbLine.append(dist[d][t] + " ");
      }
      writer.writeLine(sbLine.toString().trim());
    }
    writer.close();
  }
Ejemplo n.º 3
0
  private void printTopicWordDistribution(double[][] dist, String filePath) {
    assert (dist != null && dist.length != 0 && dist[0].length != 0)
        : "The topic word distribution is not correct!";

    FileOneByOneLineWriter writer = new FileOneByOneLineWriter(filePath);

    int T = dist.length;
    for (int t = 0; t < T; ++t) {
      StringBuilder sbLine = new StringBuilder();
      int V = dist[t].length;
      for (int w = 0; w < V; ++w) {
        sbLine.append(dist[t][w] + " ");
      }
      writer.writeLine(sbLine.toString().trim());
    }
    writer.close();
  }