You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$docs = [
'The queen does something',
'Queen is very good queen',
'Mission mission mission',
'What is mission your mission'
];
$tok = newWhitespaceTokenizer();
$tset = newTrainingSet();
foreach ($docsas$line) {
$tset->addDocument(
'', // the class is not used by the lda modelnewTokensDocument(
$tok->tokenize(
mb_strtolower($line)
)
)
);
}
$lda = newLda(
newDataAsFeatures(), // a feature factory to transform the document data2, // the number of topics we want1, // the dirichlet prior assumed for the per document topic distribution1// the dirichlet prior assumed for the per word topic distribution
);
$lda->train($tset,50);
$lda->getDocumentsPerTopicsProbabilities(2);
This results in:
Undefined offset: 0 at
vendor/nlp-tools/nlp-tools/src/NlpTools/Models/Lda.php:243
This probably requires something along the lines of:
if (!isset($count_topics_docs[$doc])) {
$count_topics_docs[$doc] = [];
}
if (!isset($count_topics_docs[$doc][$t])) {
$count_topics_docs[$doc][$t] = 0;
}
also, further down you have a variable $limit_docs, which is undefined, maybe the signature of method is incorrect public function getDocumentsPerTopicsProbabilities($limit_docs = -1), maybe it's $limit_words there?
But, anyways, after running this method on this input:
$docs = [
'The queen does something',
'Queen is very good queen',
'Mission mission mission',
'What is mission your mission'
];
...$lda->getDocumentsPerTopicsProbabilities(2);
I'm trying to follow http://php-nlp-tools.com/posts/introducing-latent-dirichlet-allocation.html
But trying to call
getDocumentsPerTopicsProbabilities
at the end:This results in:
Undefined offset: 0 at
vendor/nlp-tools/nlp-tools/src/NlpTools/Models/Lda.php:243
This probably requires something along the lines of:
also, further down you have a variable
$limit_docs
, which is undefined, maybe the signature of method is incorrectpublic function getDocumentsPerTopicsProbabilities($limit_docs = -1)
, maybe it's$limit_words
there?But, anyways, after running this method on this input:
I get this result:
And I'm not sure how to interpret that... :)
Thanks!
The text was updated successfully, but these errors were encountered: