forked from dotnet/machinelearning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlda_document.cpp
More file actions
29 lines (26 loc) · 880 Bytes
/
lda_document.cpp
File metadata and controls
29 lines (26 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#include "lda_document.h"
namespace lda
{
LDADocument::LDADocument(int32_t* memory_begin, int32_t* memory_end) :
memory_begin_(memory_begin), memory_end_(memory_end), cursor_(*memory_begin) {}
// should be called when sweeped over all the tokens in a document
void LDADocument::ResetCursor()
{
cursor_ = 0;
}
void LDADocument::GetDocTopicCounter(lda::light_hash_map& doc_topic_counter)
{
int32_t* p = memory_begin_ + 2;
int32_t num = 0;
while (p < memory_end_)
{
doc_topic_counter.inc(*p, 1);
++p; ++p;
if (++num == 512)
return;
}
}
}