ealdent-lda-ruby 0.1.5 → 0.1.6

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 (3) hide show
  1. data/lib/lda-inference.c +24 -0
  2. data/lib/lda-inference.h +1 -0
  3. metadata +2 -2
@@ -546,12 +546,14 @@ void run_quiet_em(char* start, corpus* corpus) {
546
546
 
547
547
  last_model = model;
548
548
  last_gamma = var_gamma;
549
+ last_phi = phi;
549
550
  }
550
551
 
551
552
  // output the final model
552
553
 
553
554
  last_model = model;
554
555
  last_gamma = var_gamma;
556
+ last_phi = phi;
555
557
 
556
558
  // output the word assignments (for visualization)
557
559
  /*
@@ -835,6 +837,27 @@ static VALUE wrap_get_gamma(VALUE self) {
835
837
  return arr;
836
838
  }
837
839
 
840
+ static VALUE wrap_get_phi(VALUE self) {
841
+ if (!model_loaded)
842
+ return Qnil;
843
+
844
+ VALUE arr;
845
+ int i = 0, j = 0;
846
+ int max_length = max_corpus_length(last_corpus);
847
+
848
+
849
+ arr = rb_ary_new2(max_length);
850
+ for (i = 0; i < max_length; i++) {
851
+ VALUE arr2 = rb_ary_new2(last_model->num_topics);
852
+ for (j = 0; j < last_model->num_topics; j++) {
853
+ rb_ary_store(arr2, j, rb_float_new(last_phi[i][j]));
854
+ }
855
+ rb_ary_store(arr, i, arr2);
856
+ }
857
+
858
+ return arr;
859
+ }
860
+
838
861
  /*
839
862
  * Get the beta matrix after the model has been run.
840
863
  */
@@ -940,6 +963,7 @@ void Init_lda_ext() {
940
963
  // retrieve model and gamma
941
964
  rb_define_method(rb_cLda, "beta", wrap_get_model_beta, 0);
942
965
  rb_define_method(rb_cLda, "gamma", wrap_get_gamma, 0);
966
+ rb_define_method(rb_cLda, "phi", wrap_get_phi, 0);
943
967
  rb_define_method(rb_cLda, "model", wrap_get_model_settings, 0);
944
968
  }
945
969
 
@@ -24,6 +24,7 @@ int VAR_MAX_ITER;
24
24
  corpus *last_corpus;
25
25
  lda_model *last_model;
26
26
  double **last_gamma;
27
+ double **last_phi;
27
28
 
28
29
  enum BOOL { FALSE, TRUE } corpus_loaded, model_loaded, VERBOSE;
29
30
  #endif
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ealdent-lda-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason M. Adams
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-11-21 00:00:00 -08:00
13
+ date: 2008-11-24 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies: []
16
16