lda-ruby 0.5.0-x64-mingw-ucrt
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +69 -0
- data/Gemfile +9 -0
- data/README.md +160 -0
- data/VERSION.yml +5 -0
- data/docs/modernization-handoff.md +233 -0
- data/docs/porting-strategy.md +148 -0
- data/docs/precompiled-platform-policy.md +81 -0
- data/docs/precompiled-target-evaluation.md +67 -0
- data/docs/release-runbook.md +192 -0
- data/docs/rust-orchestration-guardrails.md +50 -0
- data/ext/lda-ruby/cokus.c +144 -0
- data/ext/lda-ruby/cokus.h +27 -0
- data/ext/lda-ruby/extconf.rb +13 -0
- data/ext/lda-ruby/lda-alpha.c +96 -0
- data/ext/lda-ruby/lda-alpha.h +21 -0
- data/ext/lda-ruby/lda-data.c +67 -0
- data/ext/lda-ruby/lda-data.h +14 -0
- data/ext/lda-ruby/lda-inference.c +1023 -0
- data/ext/lda-ruby/lda-inference.h +63 -0
- data/ext/lda-ruby/lda-model.c +345 -0
- data/ext/lda-ruby/lda-model.h +31 -0
- data/ext/lda-ruby/lda-x64-mingw-ucrt.def +2 -0
- data/ext/lda-ruby/lda.h +54 -0
- data/ext/lda-ruby/utils.c +119 -0
- data/ext/lda-ruby/utils.h +18 -0
- data/ext/lda-ruby-rust/Cargo.toml +12 -0
- data/ext/lda-ruby-rust/README.md +73 -0
- data/ext/lda-ruby-rust/extconf.rb +135 -0
- data/ext/lda-ruby-rust/include/strings.h +35 -0
- data/ext/lda-ruby-rust/src/lib.rs +1263 -0
- data/lda-ruby.gemspec +78 -0
- data/lib/lda-ruby/backends/base.rb +133 -0
- data/lib/lda-ruby/backends/native.rb +158 -0
- data/lib/lda-ruby/backends/pure_ruby.rb +675 -0
- data/lib/lda-ruby/backends/rust.rb +607 -0
- data/lib/lda-ruby/backends.rb +58 -0
- data/lib/lda-ruby/config/stopwords.yml +571 -0
- data/lib/lda-ruby/corpus/corpus.rb +45 -0
- data/lib/lda-ruby/corpus/data_corpus.rb +22 -0
- data/lib/lda-ruby/corpus/directory_corpus.rb +25 -0
- data/lib/lda-ruby/corpus/text_corpus.rb +27 -0
- data/lib/lda-ruby/document/data_document.rb +30 -0
- data/lib/lda-ruby/document/document.rb +40 -0
- data/lib/lda-ruby/document/text_document.rb +39 -0
- data/lib/lda-ruby/lda.so +0 -0
- data/lib/lda-ruby/rust_build_policy.rb +21 -0
- data/lib/lda-ruby/version.rb +5 -0
- data/lib/lda-ruby/vocabulary.rb +46 -0
- data/lib/lda-ruby.rb +413 -0
- data/lib/lda_ruby_rust.so +0 -0
- data/license.txt +504 -0
- data/test/backend_compatibility_test.rb +146 -0
- data/test/backends_selection_test.rb +100 -0
- data/test/benchmark_scripts_test.rb +23 -0
- data/test/data/docs.dat +46 -0
- data/test/data/sample.rb +20 -0
- data/test/data/wiki-test-docs.yml +123 -0
- data/test/gemspec_test.rb +27 -0
- data/test/lda_ruby_test.rb +319 -0
- data/test/packaged_gem_smoke_test.rb +33 -0
- data/test/pure_ruby_orchestration_test.rb +109 -0
- data/test/release_scripts_test.rb +93 -0
- data/test/rust_build_policy_test.rb +23 -0
- data/test/rust_orchestration_test.rb +911 -0
- data/test/simple_pipeline_test.rb +22 -0
- data/test/simple_yaml.rb +17 -0
- data/test/test_helper.rb +10 -0
- metadata +118 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#ifndef LDA_ALPHA_H
|
|
2
|
+
#define LDA_ALPHA_H
|
|
3
|
+
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
#include <math.h>
|
|
6
|
+
#include <float.h>
|
|
7
|
+
|
|
8
|
+
#include "lda.h"
|
|
9
|
+
#include "utils.h"
|
|
10
|
+
|
|
11
|
+
#define NEWTON_THRESH 1e-5
|
|
12
|
+
#define MAX_ALPHA_ITER 1000
|
|
13
|
+
|
|
14
|
+
double alhood(double a, double ss, int D, int K);
|
|
15
|
+
double d_alhood(double a, double ss, int D, int K);
|
|
16
|
+
double d2_alhood(double a, int D, int K);
|
|
17
|
+
double opt_alpha(double ss, int D, int K);
|
|
18
|
+
double quiet_opt_alpha(double ss, int D, int K);
|
|
19
|
+
//void maximize_alpha(double** gamma, lda_model* model, int num_docs);
|
|
20
|
+
|
|
21
|
+
#endif
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// (C) Copyright 2004, David M. Blei (blei [at] cs [dot] cmu [dot] edu)
|
|
2
|
+
|
|
3
|
+
// This file is part of LDA-C.
|
|
4
|
+
|
|
5
|
+
// LDA-C is free software; you can redistribute it and/or modify it under
|
|
6
|
+
// the terms of the GNU General Public License as published by the Free
|
|
7
|
+
// Software Foundation; either version 2 of the License, or (at your
|
|
8
|
+
// option) any later version.
|
|
9
|
+
|
|
10
|
+
// LDA-C is distributed in the hope that it will be useful, but WITHOUT
|
|
11
|
+
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12
|
+
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13
|
+
// for more details.
|
|
14
|
+
|
|
15
|
+
// You should have received a copy of the GNU General Public License
|
|
16
|
+
// along with this program; if not, write to the Free Software
|
|
17
|
+
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
18
|
+
// USA
|
|
19
|
+
|
|
20
|
+
#include "lda-data.h"
|
|
21
|
+
|
|
22
|
+
corpus* read_data(char* data_filename)
|
|
23
|
+
{
|
|
24
|
+
FILE *fileptr;
|
|
25
|
+
int length, count, word, n, nd, nw;
|
|
26
|
+
corpus* c;
|
|
27
|
+
|
|
28
|
+
printf("reading data from %s\n", data_filename);
|
|
29
|
+
c = malloc(sizeof(corpus));
|
|
30
|
+
c->docs = 0;
|
|
31
|
+
c->num_terms = 0;
|
|
32
|
+
c->num_docs = 0;
|
|
33
|
+
fileptr = fopen(data_filename, "r");
|
|
34
|
+
nd = 0; nw = 0;
|
|
35
|
+
while ((fscanf(fileptr, "%10d", &length) != EOF))
|
|
36
|
+
{
|
|
37
|
+
c->docs = (document*) realloc(c->docs, sizeof(document)*(nd+1));
|
|
38
|
+
c->docs[nd].length = length;
|
|
39
|
+
c->docs[nd].total = 0;
|
|
40
|
+
c->docs[nd].words = malloc(sizeof(int)*length);
|
|
41
|
+
c->docs[nd].counts = malloc(sizeof(int)*length);
|
|
42
|
+
for (n = 0; n < length; n++)
|
|
43
|
+
{
|
|
44
|
+
fscanf(fileptr, "%10d:%10d", &word, &count);
|
|
45
|
+
word = word - OFFSET;
|
|
46
|
+
c->docs[nd].words[n] = word;
|
|
47
|
+
c->docs[nd].counts[n] = count;
|
|
48
|
+
c->docs[nd].total += count;
|
|
49
|
+
if (word >= nw) { nw = word + 1; }
|
|
50
|
+
}
|
|
51
|
+
nd++;
|
|
52
|
+
}
|
|
53
|
+
fclose(fileptr);
|
|
54
|
+
c->num_docs = nd;
|
|
55
|
+
c->num_terms = nw;
|
|
56
|
+
printf("number of docs : %d\n", nd);
|
|
57
|
+
printf("number of terms : %d\n", nw);
|
|
58
|
+
return(c);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
int max_corpus_length(corpus* c)
|
|
62
|
+
{
|
|
63
|
+
int n, max = 0;
|
|
64
|
+
for (n = 0; n < c->num_docs; n++)
|
|
65
|
+
if (c->docs[n].length > max) max = c->docs[n].length;
|
|
66
|
+
return(max);
|
|
67
|
+
}
|