wapiti 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b556f6c375171e82550f04adffc293154d90e370
4
- data.tar.gz: 1a40a18e7e4f6afbbfc8a51d1aaef6a469375574
3
+ metadata.gz: f8e3f42f711858caf64ca6682ea3aea8d9439a02
4
+ data.tar.gz: 32569d35d3e6d2af1adf91df7a1a8d7ba996d198
5
5
  SHA512:
6
- metadata.gz: f904c8d7ce3b0c48a74f4f2e678b120626eb89ae9d22a3cc4b75d3b8c081d8dc0cffbe030a9a2b3132927a80c696e5df7eb6673a66420600ebcf7e09eb497282
7
- data.tar.gz: 58be17b5b87d9ee0ee7fa6037492e1bb0b6070ae1611c640799ab318fcf8abfc074ef89bcb944297b428996f8b2b13fc9dfed6081d6fbf02c0d4bfd8e54e1ea3
6
+ metadata.gz: 2ed36dbff7978ca5a731bc3381faad7b9fc362dcdd46ce0b7495dceacd6d21458a33bab5250ee71788d4b2e553625d3b39e61b4140ef701498f04742cf10d19c
7
+ data.tar.gz: d9e10608342bc351c88cbb61d37af504b983c3e5b973ee2a29919951987ec4d3a3919d98f053990300207820cf59ab297c80a6efb4806060999c0090079b9e39
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.1.1 / 2014-02-27
2
+ ==================
3
+ * Updated train routine
4
+
1
5
  0.1.0 / 2014-02-25
2
6
  ==================
3
7
  * Updated to wapiti 1.5.0
data/ext/wapiti/native.c CHANGED
@@ -29,20 +29,10 @@ VALUE cLogger;
29
29
  int wapiti_main(int argc, char *argv[argc]);
30
30
 
31
31
  void dolabel(mdl_t *mdl);
32
- void dotrain(mdl_t *mdl);
33
- void doupdt(mdl_t *mdl);
34
32
 
35
33
 
36
34
  /* --- Utilities --- */
37
35
 
38
- static void trn_auto(mdl_t *mdl) {
39
- const int maxiter = mdl->opt->maxiter;
40
- mdl->opt->maxiter = 3;
41
- trn_sgdl1(mdl);
42
- mdl->opt->maxiter = maxiter;
43
- trn_lbfgs(mdl);
44
- }
45
-
46
36
  static const struct {
47
37
  const char *name;
48
38
  void (* train)(mdl_t *mdl);
@@ -52,10 +42,9 @@ static const struct {
52
42
  {"bcd", trn_bcd },
53
43
  {"rprop", trn_rprop},
54
44
  {"rprop+", trn_rprop},
55
- {"rprop-", trn_rprop},
56
- {"auto", trn_auto }
45
+ {"rprop-", trn_rprop}
57
46
  };
58
- static const int trn_cnt = sizeof(trn_lst) / sizeof(trn_lst[0]);
47
+ static const uint32_t trn_cnt = sizeof(trn_lst) / sizeof(trn_lst[0]);
59
48
 
60
49
 
61
50
  /* --- Options Class --- */
@@ -865,13 +854,14 @@ static VALUE model_train(VALUE self, VALUE data) {
865
854
 
866
855
  mdl_t* model = get_model(self);
867
856
 
868
- int trn;
857
+ uint32_t trn;
869
858
  for (trn = 0; trn < trn_cnt; trn++) {
870
859
  if (!strcmp(model->opt->algo, trn_lst[trn].name)) break;
871
860
  }
872
861
 
873
862
  if (trn == trn_cnt) {
874
- rb_raise(cNativeError, "failed to train model: unknown algorithm '%s'", model->opt->algo);
863
+ rb_raise(cNativeError,
864
+ "failed to train model: unknown algorithm '%s'", model->opt->algo);
875
865
  }
876
866
 
877
867
  FILE *file;
@@ -882,22 +872,20 @@ static VALUE model_train(VALUE self, VALUE data) {
882
872
  file = fopen(model->opt->pattern, "r");
883
873
 
884
874
  if (!file) {
885
- rb_raise(cNativeError, "failed to train model: failed to load pattern file '%s'", model->opt->pattern);
875
+ rb_raise(cNativeError,
876
+ "failed to train model: failed to load pattern file '%s'", model->opt->pattern);
886
877
  }
887
878
 
888
879
  rdr_loadpat(model->reader, file);
889
880
  fclose(file);
890
- }
891
- else {
892
- // rb_raise(cNativeError, "failed to train model: no pattern given");
893
- }
894
881
 
895
- qrk_lock(model->reader->obs, false);
882
+ qrk_lock(model->reader->obs, false);
883
+ }
896
884
 
897
885
 
898
886
  // Load the training data. When this is done we lock the quarks as we
899
887
  // don't want to put in the model, informations present only in the
900
- // devlopment set.
888
+ // development set.
901
889
 
902
890
  switch (TYPE(data)) {
903
891
  case T_STRING:
@@ -928,7 +916,8 @@ static VALUE model_train(VALUE self, VALUE data) {
928
916
  // the training dataset will be used instead.
929
917
  if (model->opt->devel) {
930
918
  if (!(file = fopen(model->opt->devel, "r"))) {
931
- rb_raise(cNativeError, "failed to train model: cannot open development file '%s'", model->opt->devel);
919
+ rb_raise(cNativeError,
920
+ "failed to train model: cannot open development file '%s'", model->opt->devel);
932
921
  }
933
922
 
934
923
  model->devel = rdr_readdat(model->reader, file, true);
@@ -937,7 +926,8 @@ static VALUE model_train(VALUE self, VALUE data) {
937
926
 
938
927
  // Initialize the model. If a previous model was loaded, this will be
939
928
  // just a resync, else the model structure will be created.
940
- rb_funcall(self, rb_intern("sync"), 0);
929
+ // rb_funcall(self, rb_intern("sync"), 0);
930
+ mdl_sync(model);
941
931
 
942
932
  // Train the model.
943
933
  uit_setup(model);
@@ -946,7 +936,8 @@ static VALUE model_train(VALUE self, VALUE data) {
946
936
 
947
937
  // If requested compact the model.
948
938
  if (model->opt->compact) {
949
- rb_funcall(self, rb_intern("compact"), 0);
939
+ // rb_funcall(self, rb_intern("compact"), 0);
940
+ mdl_compact(model);
950
941
  }
951
942
 
952
943
  return self;
@@ -1,3 +1,3 @@
1
1
  module Wapiti
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wapiti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-25 00:00:00.000000000 Z
11
+ date: 2014-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake