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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +69 -0
  3. data/Gemfile +9 -0
  4. data/README.md +160 -0
  5. data/VERSION.yml +5 -0
  6. data/docs/modernization-handoff.md +233 -0
  7. data/docs/porting-strategy.md +148 -0
  8. data/docs/precompiled-platform-policy.md +81 -0
  9. data/docs/precompiled-target-evaluation.md +67 -0
  10. data/docs/release-runbook.md +192 -0
  11. data/docs/rust-orchestration-guardrails.md +50 -0
  12. data/ext/lda-ruby/cokus.c +144 -0
  13. data/ext/lda-ruby/cokus.h +27 -0
  14. data/ext/lda-ruby/extconf.rb +13 -0
  15. data/ext/lda-ruby/lda-alpha.c +96 -0
  16. data/ext/lda-ruby/lda-alpha.h +21 -0
  17. data/ext/lda-ruby/lda-data.c +67 -0
  18. data/ext/lda-ruby/lda-data.h +14 -0
  19. data/ext/lda-ruby/lda-inference.c +1023 -0
  20. data/ext/lda-ruby/lda-inference.h +63 -0
  21. data/ext/lda-ruby/lda-model.c +345 -0
  22. data/ext/lda-ruby/lda-model.h +31 -0
  23. data/ext/lda-ruby/lda-x64-mingw-ucrt.def +2 -0
  24. data/ext/lda-ruby/lda.h +54 -0
  25. data/ext/lda-ruby/utils.c +119 -0
  26. data/ext/lda-ruby/utils.h +18 -0
  27. data/ext/lda-ruby-rust/Cargo.toml +12 -0
  28. data/ext/lda-ruby-rust/README.md +73 -0
  29. data/ext/lda-ruby-rust/extconf.rb +135 -0
  30. data/ext/lda-ruby-rust/include/strings.h +35 -0
  31. data/ext/lda-ruby-rust/src/lib.rs +1263 -0
  32. data/lda-ruby.gemspec +78 -0
  33. data/lib/lda-ruby/backends/base.rb +133 -0
  34. data/lib/lda-ruby/backends/native.rb +158 -0
  35. data/lib/lda-ruby/backends/pure_ruby.rb +675 -0
  36. data/lib/lda-ruby/backends/rust.rb +607 -0
  37. data/lib/lda-ruby/backends.rb +58 -0
  38. data/lib/lda-ruby/config/stopwords.yml +571 -0
  39. data/lib/lda-ruby/corpus/corpus.rb +45 -0
  40. data/lib/lda-ruby/corpus/data_corpus.rb +22 -0
  41. data/lib/lda-ruby/corpus/directory_corpus.rb +25 -0
  42. data/lib/lda-ruby/corpus/text_corpus.rb +27 -0
  43. data/lib/lda-ruby/document/data_document.rb +30 -0
  44. data/lib/lda-ruby/document/document.rb +40 -0
  45. data/lib/lda-ruby/document/text_document.rb +39 -0
  46. data/lib/lda-ruby/lda.so +0 -0
  47. data/lib/lda-ruby/rust_build_policy.rb +21 -0
  48. data/lib/lda-ruby/version.rb +5 -0
  49. data/lib/lda-ruby/vocabulary.rb +46 -0
  50. data/lib/lda-ruby.rb +413 -0
  51. data/lib/lda_ruby_rust.so +0 -0
  52. data/license.txt +504 -0
  53. data/test/backend_compatibility_test.rb +146 -0
  54. data/test/backends_selection_test.rb +100 -0
  55. data/test/benchmark_scripts_test.rb +23 -0
  56. data/test/data/docs.dat +46 -0
  57. data/test/data/sample.rb +20 -0
  58. data/test/data/wiki-test-docs.yml +123 -0
  59. data/test/gemspec_test.rb +27 -0
  60. data/test/lda_ruby_test.rb +319 -0
  61. data/test/packaged_gem_smoke_test.rb +33 -0
  62. data/test/pure_ruby_orchestration_test.rb +109 -0
  63. data/test/release_scripts_test.rb +93 -0
  64. data/test/rust_build_policy_test.rb +23 -0
  65. data/test/rust_orchestration_test.rb +911 -0
  66. data/test/simple_pipeline_test.rb +22 -0
  67. data/test/simple_yaml.rb +17 -0
  68. data/test/test_helper.rb +10 -0
  69. 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
+ }
@@ -0,0 +1,14 @@
1
+ #ifndef LDA_DATA_H
2
+ #define LDA_DATA_H
3
+
4
+ #include <stdio.h>
5
+ #include <stdlib.h>
6
+
7
+ #include "lda.h"
8
+
9
+ #define OFFSET 0; // offset for reading data
10
+
11
+ corpus* read_data(char* data_filename);
12
+ int max_corpus_length(corpus* c);
13
+
14
+ #endif