lda-ruby 0.3.8 → 0.4.0

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 (47) hide show
  1. checksums.yaml +7 -0
  2. data/{CHANGELOG → CHANGELOG.md} +20 -0
  3. data/Gemfile +9 -0
  4. data/README.md +157 -0
  5. data/VERSION.yml +4 -4
  6. data/docs/modernization-handoff.md +190 -0
  7. data/docs/porting-strategy.md +127 -0
  8. data/docs/precompiled-platform-policy.md +68 -0
  9. data/docs/release-runbook.md +157 -0
  10. data/ext/lda-ruby/extconf.rb +10 -6
  11. data/ext/lda-ruby/lda-inference.c +21 -5
  12. data/ext/lda-ruby-rust/Cargo.toml +12 -0
  13. data/ext/lda-ruby-rust/README.md +48 -0
  14. data/ext/lda-ruby-rust/extconf.rb +123 -0
  15. data/ext/lda-ruby-rust/src/lib.rs +456 -0
  16. data/lda-ruby.gemspec +70 -71
  17. data/lib/lda-ruby/backends/base.rb +129 -0
  18. data/lib/lda-ruby/backends/native.rb +158 -0
  19. data/lib/lda-ruby/backends/pure_ruby.rb +613 -0
  20. data/lib/lda-ruby/backends/rust.rb +226 -0
  21. data/lib/lda-ruby/backends.rb +58 -0
  22. data/lib/lda-ruby/corpus/corpus.rb +17 -15
  23. data/lib/lda-ruby/corpus/data_corpus.rb +2 -2
  24. data/lib/lda-ruby/corpus/directory_corpus.rb +2 -2
  25. data/lib/lda-ruby/corpus/text_corpus.rb +14 -9
  26. data/lib/lda-ruby/document/document.rb +6 -8
  27. data/lib/lda-ruby/document/text_document.rb +5 -4
  28. data/lib/lda-ruby/rust_build_policy.rb +21 -0
  29. data/lib/lda-ruby/version.rb +5 -0
  30. data/lib/lda-ruby.rb +293 -48
  31. data/test/backend_compatibility_test.rb +146 -0
  32. data/test/backends_selection_test.rb +100 -0
  33. data/test/gemspec_test.rb +27 -0
  34. data/test/lda_ruby_test.rb +49 -11
  35. data/test/packaged_gem_smoke_test.rb +33 -0
  36. data/test/release_scripts_test.rb +54 -0
  37. data/test/rust_build_policy_test.rb +23 -0
  38. data/test/simple_pipeline_test.rb +22 -0
  39. data/test/simple_yaml.rb +1 -7
  40. data/test/test_helper.rb +5 -6
  41. metadata +62 -75
  42. data/README +0 -21
  43. data/README.markdown +0 -37
  44. data/Rakefile +0 -61
  45. data/ext/lda-ruby/Makefile +0 -181
  46. data/test/data/.gitignore +0 -2
  47. data/test/simple_test.rb +0 -26
@@ -1,181 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- #### Start of system configuration section. ####
5
-
6
- srcdir = .
7
- topdir = /home/taf2/.local/include/ruby-1.9.1
8
- hdrdir = /home/taf2/.local/include/ruby-1.9.1
9
- arch_hdrdir = /home/taf2/.local/include/ruby-1.9.1/$(arch)
10
- VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
11
- prefix = $(DESTDIR)/home/taf2/.local
12
- exec_prefix = $(prefix)
13
- vendorhdrdir = $(rubyhdrdir)/vendor_ruby
14
- sitehdrdir = $(rubyhdrdir)/site_ruby
15
- rubyhdrdir = $(includedir)/$(RUBY_INSTALL_NAME)-$(ruby_version)
16
- vendordir = $(libdir)/$(RUBY_INSTALL_NAME)/vendor_ruby
17
- sitedir = $(libdir)/$(RUBY_INSTALL_NAME)/site_ruby
18
- mandir = $(datarootdir)/man
19
- localedir = $(datarootdir)/locale
20
- libdir = $(exec_prefix)/lib
21
- psdir = $(docdir)
22
- pdfdir = $(docdir)
23
- dvidir = $(docdir)
24
- htmldir = $(docdir)
25
- infodir = $(datarootdir)/info
26
- docdir = $(datarootdir)/doc/$(PACKAGE)
27
- oldincludedir = $(DESTDIR)/usr/include
28
- includedir = $(prefix)/include
29
- localstatedir = $(prefix)/var
30
- sharedstatedir = $(prefix)/com
31
- sysconfdir = $(prefix)/etc
32
- datadir = $(datarootdir)
33
- datarootdir = $(prefix)/share
34
- libexecdir = $(exec_prefix)/libexec
35
- sbindir = $(exec_prefix)/sbin
36
- bindir = $(exec_prefix)/bin
37
- rubylibdir = $(libdir)/$(ruby_install_name)/$(ruby_version)
38
- archdir = $(rubylibdir)/$(arch)
39
- sitelibdir = $(sitedir)/$(ruby_version)
40
- sitearchdir = $(sitelibdir)/$(sitearch)
41
- vendorlibdir = $(vendordir)/$(ruby_version)
42
- vendorarchdir = $(vendorlibdir)/$(sitearch)
43
-
44
- CC = gcc
45
- CXX = g++
46
- LIBRUBY = $(LIBRUBY_SO)
47
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
48
- LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
49
- LIBRUBYARG_STATIC = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
50
- OUTFLAG = -o
51
- COUTFLAG = -o
52
-
53
- RUBY_EXTCONF_H =
54
- cflags = $(optflags) $(debugflags) $(warnflags)
55
- optflags = -O0
56
- debugflags = -g3 -ggdb
57
- warnflags = -Wall -Wno-parentheses
58
- CFLAGS = -fPIC $(cflags) -fPIC -Wall -ggdb -O0
59
- INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
60
- DEFS =
61
- CPPFLAGS = -D USE_RUBY $(DEFS) $(cppflags)
62
- CXXFLAGS = $(CFLAGS) $(cxxflags)
63
- ldflags = -L. -rdynamic -Wl,-export-dynamic
64
- dldflags =
65
- archflag =
66
- DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
67
- LDSHARED = $(CC) -shared
68
- LDSHAREDXX = $(CXX) -shared
69
- AR = ar
70
- EXEEXT =
71
-
72
- RUBY_INSTALL_NAME = ruby
73
- RUBY_SO_NAME = ruby
74
- arch = x86_64-linux
75
- sitearch = x86_64-linux
76
- ruby_version = 1.9.1
77
- ruby = /home/taf2/.local/bin/ruby
78
- RUBY = $(ruby)
79
- RM = rm -f
80
- RM_RF = $(RUBY) -run -e rm -- -rf
81
- RMDIRS = $(RUBY) -run -e rmdir -- -p
82
- MAKEDIRS = mkdir -p
83
- INSTALL = /usr/bin/install -c
84
- INSTALL_PROG = $(INSTALL) -m 0755
85
- INSTALL_DATA = $(INSTALL) -m 644
86
- COPY = cp
87
-
88
- #### End of system configuration section. ####
89
-
90
- preload =
91
-
92
- libpath = . $(libdir)
93
- LIBPATH = -L. -L$(libdir) -Wl,-R$(libdir)
94
- DEFFILE =
95
-
96
- CLEANFILES = mkmf.log
97
- DISTCLEANFILES =
98
- DISTCLEANDIRS =
99
-
100
- extout =
101
- extout_prefix =
102
- target_prefix =
103
- LOCAL_LIBS =
104
- LIBS = $(LIBRUBYARG_SHARED) -lpthread -lrt -ldl -lcrypt -lm -lc
105
- SRCS = lda-model.c lda-data.c utils.c lda-alpha.c cokus.c lda-inference.c
106
- OBJS = lda-model.o lda-data.o utils.o lda-alpha.o cokus.o lda-inference.o
107
- TARGET = lda_ext
108
- DLLIB = $(TARGET).so
109
- EXTSTATIC =
110
- STATIC_LIB =
111
-
112
- BINDIR = $(bindir)
113
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
114
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
115
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
116
- HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
117
- ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
118
-
119
- TARGET_SO = $(DLLIB)
120
- CLEANLIBS = $(TARGET).so
121
- CLEANOBJS = *.o *.bak
122
-
123
- all: $(DLLIB)
124
- static: $(STATIC_LIB)
125
-
126
- clean-rb-default::
127
- clean-rb::
128
- clean-so::
129
- clean: clean-so clean-rb-default clean-rb
130
- @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
131
-
132
- distclean-rb-default::
133
- distclean-rb::
134
- distclean-so::
135
- distclean: clean distclean-so distclean-rb-default distclean-rb
136
- @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
137
- @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
138
- @-$(RMDIRS) $(DISTCLEANDIRS)
139
-
140
- realclean: distclean
141
- install: install-so install-rb
142
-
143
- install-so: $(RUBYARCHDIR)
144
- install-so: $(RUBYARCHDIR)/$(DLLIB)
145
- $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
146
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
147
- install-rb: pre-install-rb install-rb-default
148
- install-rb-default: pre-install-rb-default
149
- pre-install-rb: Makefile
150
- pre-install-rb-default: Makefile
151
- $(RUBYARCHDIR):
152
- $(MAKEDIRS) $@
153
-
154
- site-install: site-install-so site-install-rb
155
- site-install-so: install-so
156
- site-install-rb: install-rb
157
-
158
- .SUFFIXES: .c .m .cc .cxx .cpp .C .o
159
-
160
- .cc.o:
161
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
162
-
163
- .cxx.o:
164
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
165
-
166
- .cpp.o:
167
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
168
-
169
- .C.o:
170
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
171
-
172
- .c.o:
173
- $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
174
-
175
- $(DLLIB): $(OBJS) Makefile
176
- @-$(RM) $(@)
177
- $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
178
-
179
-
180
-
181
- $(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
data/test/data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- tmp*.txt
2
- tmp*.yml
data/test/simple_test.rb DELETED
@@ -1,26 +0,0 @@
1
- require 'rubygems'
2
- require 'shoulda'
3
- require 'yaml'
4
- require 'lda-ruby'
5
-
6
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
- $LOAD_PATH.unshift(File.dirname(__FILE__))
8
-
9
- class Test::Unit::TestCase
10
-
11
- @corpus = Lda::Corpus.new
12
- @document1 = Lda::TextDocument.new(@corpus, 'Dom Cobb is a skilled thief, the absolute best in the dangerous art of extraction, stealing valuable secrets from deep within the subconscious during the dream state, when the mind is at its most vulnerable. Cobb\'s rare ability has made him a coveted player in this treacherous new world of corporate espionage, but it has also made him an international fugitive and cost him everything he has ever loved. Now Cobb is being offered a chance at redemption. One last job could give him his life back but only if he can accomplish the impossible-inception. Instead of the perfect heist, Cobb and his team of specialists have to pull off the reverse: their task is not to steal an idea but to plant one. If they succeed, it could be the perfect crime. But no amount of careful planning or expertise can prepare the team for the dangerous enemy that seems to predict their every move. An enemy that only Cobb could have seen coming.')
13
- @document2 = Lda::TextDocument.new(@corpus, 'When his brother is killed in a robbery, paraplegic Marine Jake Sully decides to take his place in a mission on the distant world of Pandora. There he learns of greedy corporate figurehead Parker Selfridge\'s intentions of driving off the native humanoid \"Na\'vi\" in order to mine for the precious material scattered throughout their rich woodland. In exchange for the spinal surgery that will fix his legs, Jake gathers intel for the cooperating military unit spearheaded by gung-ho Colonel Quaritch, while simultaneously attempting to infiltrate the Na\'vi people with the use of an \"avatar\" identity. While Jake begins to bond with the native tribe and quickly falls in love with the beautiful alien Neytiri, the restless Colonel moves forward with his ruthless extermination tactics, forcing the soldier to take a stand - and fight back in an epic battle for the fate of Pandora.')
14
-
15
- @corpus.add_document(@document1)
16
- @corpus.add_document(@document2)
17
- @corpus.remove_word("cobb")
18
- @lda = Lda::Lda.new(@corpus)
19
-
20
- @lda.verbose = false
21
- @lda.num_topics = 2
22
- @lda.em('random')
23
- topics = @lda.top_words(5)
24
- puts topics
25
-
26
- end