あなたのパイプラインでCountVectorizer変圧器を使用している場合は、この方法でインデックス付きの語彙を回復することができます。そして、
String[] vocabulary= countVectorizerModel.vocabulary();
、あなたはそのテキスト>(期間カウント)変換から入手SparseVectors上LDAを実行します。
Tuple2<int[], double[]>[] topicsDescribed = ldaModel.describeTopics();
int idxTopic = 0;
for (Tuple2<int[], double[]> element : topicsDescribed) {
idxTopic++;
int[] termIndices = element._1;
double[] termScores = element._2;
System.out.println("Topic >> " + idxTopic);
for (int i = 0; i < termIndices.length; i++) {
System.out.println("termIndex --> " + termIndices[i] + + "word="+ vocabulary[termIndices[i]] + + ",score= " + termScores[i]);
}
}
}
、LDAの結果を見ると、あなたがそのような
ldaModel.vocabSize() == vocabulary.length
として、パイプラインを通じて用語の語彙を一貫しておくので、これは動作します