Skip to content

Commit ad88df6

Browse files
First fix for angeloskath#64
1 parent 476e07c commit ad88df6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/NlpTools/Models/Lda.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,15 @@ public function getDocumentsPerTopicsProbabilities($limit_docs=-1)
239239
$denom = $doccnt + $this->ntopics*$this->a;
240240
$count_topics_docs = array();
241241
foreach ($this->count_docs_topics as $doc=>$topics) {
242-
foreach ($topics as $t=>$c)
243-
$count_topics_docs[$doc][$t]++;
242+
foreach ($topics as $t=>$c) {
243+
if (!isset($count_topics_docs[$doc])) {
244+
$count_topics_docs[$doc] = array();
245+
}
246+
if (!isset($count_topics_docs[$doc][$t])) {
247+
$count_topics_docs[$doc][$t] = 0;
248+
}
249+
$count_topics_docs[$doc][$t]++;
250+
}
244251
}
245252

246253
foreach ($p_t_d as $topic=>&$p) {

0 commit comments

Comments
 (0)