lda-ruby 0.3.9 → 0.5.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 (54) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG.md +16 -0
  3. data/Gemfile +9 -0
  4. data/README.md +126 -3
  5. data/VERSION.yml +3 -3
  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 +10 -11
  13. data/ext/lda-ruby/cokus.h +3 -3
  14. data/ext/lda-ruby/extconf.rb +10 -6
  15. data/ext/lda-ruby/lda-inference.c +23 -7
  16. data/ext/lda-ruby/utils.c +8 -0
  17. data/ext/lda-ruby-rust/Cargo.toml +12 -0
  18. data/ext/lda-ruby-rust/README.md +73 -0
  19. data/ext/lda-ruby-rust/extconf.rb +135 -0
  20. data/ext/lda-ruby-rust/include/strings.h +35 -0
  21. data/ext/lda-ruby-rust/src/lib.rs +1263 -0
  22. data/lda-ruby.gemspec +0 -0
  23. data/lib/lda-ruby/backends/base.rb +133 -0
  24. data/lib/lda-ruby/backends/native.rb +158 -0
  25. data/lib/lda-ruby/backends/pure_ruby.rb +675 -0
  26. data/lib/lda-ruby/backends/rust.rb +607 -0
  27. data/lib/lda-ruby/backends.rb +58 -0
  28. data/lib/lda-ruby/corpus/corpus.rb +17 -15
  29. data/lib/lda-ruby/corpus/data_corpus.rb +2 -2
  30. data/lib/lda-ruby/corpus/directory_corpus.rb +2 -2
  31. data/lib/lda-ruby/corpus/text_corpus.rb +2 -2
  32. data/lib/lda-ruby/document/document.rb +6 -6
  33. data/lib/lda-ruby/document/text_document.rb +5 -4
  34. data/lib/lda-ruby/rust_build_policy.rb +21 -0
  35. data/lib/lda-ruby/version.rb +5 -0
  36. data/lib/lda-ruby.rb +293 -48
  37. data/test/backend_compatibility_test.rb +146 -0
  38. data/test/backends_selection_test.rb +100 -0
  39. data/test/benchmark_scripts_test.rb +23 -0
  40. data/test/gemspec_test.rb +27 -0
  41. data/test/lda_ruby_test.rb +49 -11
  42. data/test/packaged_gem_smoke_test.rb +33 -0
  43. data/test/pure_ruby_orchestration_test.rb +109 -0
  44. data/test/release_scripts_test.rb +93 -0
  45. data/test/rust_build_policy_test.rb +23 -0
  46. data/test/rust_orchestration_test.rb +911 -0
  47. data/test/simple_pipeline_test.rb +22 -0
  48. data/test/simple_yaml.rb +1 -7
  49. data/test/test_helper.rb +5 -6
  50. metadata +54 -38
  51. data/Rakefile +0 -61
  52. data/ext/lda-ruby/Makefile +0 -181
  53. data/test/data/.gitignore +0 -2
  54. data/test/simple_test.rb +0 -26
@@ -0,0 +1,22 @@
1
+ require_relative "test_helper"
2
+
3
+ class SimplePipelineTest < Test::Unit::TestCase
4
+ def test_end_to_end_pipeline_on_small_corpus
5
+ corpus = Lda::Corpus.new
6
+ document1 = Lda::TextDocument.new(corpus, "Dom Cobb is a skilled thief who steals secrets from dreams.")
7
+ document2 = Lda::TextDocument.new(corpus, "Jake Sully joins the mission on Pandora and learns from the Na'vi.")
8
+
9
+ corpus.add_document(document1)
10
+ corpus.add_document(document2)
11
+ corpus.remove_word("cobb")
12
+
13
+ lda = Lda::Lda.new(corpus)
14
+ lda.verbose = false
15
+ lda.num_topics = 2
16
+ lda.em("random")
17
+
18
+ topics = lda.top_words(5)
19
+ assert_equal 2, topics.size
20
+ topics.each_value { |words| assert_equal 5, words.size }
21
+ end
22
+ end
data/test/simple_yaml.rb CHANGED
@@ -1,10 +1,4 @@
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__))
1
+ require_relative "test_helper"
8
2
 
9
3
  class Test::Unit::TestCase
10
4
 
data/test/test_helper.rb CHANGED
@@ -1,11 +1,10 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'yaml'
1
+ require "test/unit"
2
+ require "shoulda-context"
3
+ require "yaml"
5
4
 
6
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
7
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
8
- require 'lda-ruby'
7
+ require "lda-ruby"
9
8
 
10
9
  class Test::Unit::TestCase
11
10
  end
metadata CHANGED
@@ -1,44 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lda-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Blei
8
8
  - Jason Adams
9
9
  - Rio Akasaka
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-02-11 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: shoulda
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ! '>='
27
- - !ruby/object:Gem::Version
28
- version: '0'
29
- description: Ruby port of Latent Dirichlet Allocation by David M. Blei. See http://www.cs.princeton.edu/~blei/lda-c/.
30
- email: jasonmadams@gmail.com
13
+ date: 2026-05-04 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: Ruby wrapper and toolkit for Latent Dirichlet Allocation based on the
16
+ original lda-c implementation by David M. Blei.
17
+ email:
18
+ - jasonmadams@gmail.com
31
19
  executables: []
32
20
  extensions:
33
21
  - ext/lda-ruby/extconf.rb
34
- extra_rdoc_files:
35
- - README.md
22
+ - ext/lda-ruby-rust/extconf.rb
23
+ extra_rdoc_files: []
36
24
  files:
37
25
  - CHANGELOG.md
26
+ - Gemfile
38
27
  - README.md
39
- - Rakefile
40
28
  - VERSION.yml
41
- - ext/lda-ruby/Makefile
29
+ - docs/modernization-handoff.md
30
+ - docs/porting-strategy.md
31
+ - docs/precompiled-platform-policy.md
32
+ - docs/precompiled-target-evaluation.md
33
+ - docs/release-runbook.md
34
+ - docs/rust-orchestration-guardrails.md
35
+ - ext/lda-ruby-rust/Cargo.toml
36
+ - ext/lda-ruby-rust/README.md
37
+ - ext/lda-ruby-rust/extconf.rb
38
+ - ext/lda-ruby-rust/include/strings.h
39
+ - ext/lda-ruby-rust/src/lib.rs
42
40
  - ext/lda-ruby/cokus.c
43
41
  - ext/lda-ruby/cokus.h
44
42
  - ext/lda-ruby/extconf.rb
@@ -55,6 +53,11 @@ files:
55
53
  - ext/lda-ruby/utils.h
56
54
  - lda-ruby.gemspec
57
55
  - lib/lda-ruby.rb
56
+ - lib/lda-ruby/backends.rb
57
+ - lib/lda-ruby/backends/base.rb
58
+ - lib/lda-ruby/backends/native.rb
59
+ - lib/lda-ruby/backends/pure_ruby.rb
60
+ - lib/lda-ruby/backends/rust.rb
58
61
  - lib/lda-ruby/config/stopwords.yml
59
62
  - lib/lda-ruby/corpus/corpus.rb
60
63
  - lib/lda-ruby/corpus/data_corpus.rb
@@ -63,38 +66,51 @@ files:
63
66
  - lib/lda-ruby/document/data_document.rb
64
67
  - lib/lda-ruby/document/document.rb
65
68
  - lib/lda-ruby/document/text_document.rb
69
+ - lib/lda-ruby/rust_build_policy.rb
70
+ - lib/lda-ruby/version.rb
66
71
  - lib/lda-ruby/vocabulary.rb
67
72
  - license.txt
68
- - test/data/.gitignore
73
+ - test/backend_compatibility_test.rb
74
+ - test/backends_selection_test.rb
75
+ - test/benchmark_scripts_test.rb
69
76
  - test/data/docs.dat
70
77
  - test/data/sample.rb
71
78
  - test/data/wiki-test-docs.yml
79
+ - test/gemspec_test.rb
72
80
  - test/lda_ruby_test.rb
73
- - test/simple_test.rb
81
+ - test/packaged_gem_smoke_test.rb
82
+ - test/pure_ruby_orchestration_test.rb
83
+ - test/release_scripts_test.rb
84
+ - test/rust_build_policy_test.rb
85
+ - test/rust_orchestration_test.rb
86
+ - test/simple_pipeline_test.rb
74
87
  - test/simple_yaml.rb
75
88
  - test/test_helper.rb
76
- homepage: http://github.com/ealdent/lda-ruby
77
- licenses: []
78
- metadata: {}
79
- post_install_message:
89
+ homepage: https://github.com/ealdent/lda-ruby
90
+ licenses:
91
+ - GPL-2.0-or-later
92
+ metadata:
93
+ homepage_uri: https://github.com/ealdent/lda-ruby
94
+ source_code_uri: https://github.com/ealdent/lda-ruby
95
+ changelog_uri: https://github.com/ealdent/lda-ruby/blob/master/CHANGELOG.md
96
+ lda_ruby_gem_variant: source
97
+ post_install_message:
80
98
  rdoc_options: []
81
99
  require_paths:
82
100
  - lib
83
- - ext
84
101
  required_ruby_version: !ruby/object:Gem::Requirement
85
102
  requirements:
86
- - - ! '>='
103
+ - - ">="
87
104
  - !ruby/object:Gem::Version
88
- version: '0'
105
+ version: '3.2'
89
106
  required_rubygems_version: !ruby/object:Gem::Requirement
90
107
  requirements:
91
- - - ! '>='
108
+ - - ">="
92
109
  - !ruby/object:Gem::Version
93
110
  version: '0'
94
111
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.4.5
97
- signing_key:
112
+ rubygems_version: 3.5.22
113
+ signing_key:
98
114
  specification_version: 4
99
- summary: Ruby port of Latent Dirichlet Allocation by David M. Blei.
115
+ summary: Ruby implementation of Latent Dirichlet Allocation (LDA).
100
116
  test_files: []
data/Rakefile DELETED
@@ -1,61 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'yaml'
4
-
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "lda-ruby"
9
- gem.summary = %Q{Ruby port of Latent Dirichlet Allocation by David M. Blei.}
10
- gem.description = %Q{Ruby port of Latent Dirichlet Allocation by David M. Blei. See http://www.cs.princeton.edu/~blei/lda-c/.}
11
- gem.email = "jasonmadams@gmail.com"
12
- gem.homepage = "http://github.com/ealdent/lda-ruby"
13
- gem.authors = ['David Blei', 'Jason Adams', 'Rio Akasaka']
14
- gem.extensions = ['ext/lda-ruby/extconf.rb']
15
- gem.files.include 'stopwords.txt'
16
- gem.require_paths = ['lib', 'ext']
17
- gem.add_dependency 'shoulda'
18
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
- end
20
-
21
- rescue LoadError
22
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
23
- end
24
-
25
- require 'rake/testtask'
26
- Rake::TestTask.new(:test) do |test|
27
- test.libs << 'lib' << 'test'
28
- test.pattern = 'test/**/*_test.rb'
29
- test.verbose = true
30
- end
31
-
32
- begin
33
- require 'rcov/rcovtask'
34
- Rcov::RcovTask.new do |test|
35
- test.libs << 'test'
36
- test.pattern = 'test/**/*_test.rb'
37
- test.verbose = true
38
- end
39
- rescue LoadError
40
- task :rcov do
41
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
42
- end
43
- end
44
-
45
- task :default => :test
46
-
47
- require 'rake/rdoctask'
48
- Rake::RDocTask.new do |rdoc|
49
- if File.exist?('VERSION.yml')
50
- config = YAML.load(File.read('VERSION.yml'))
51
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
52
- else
53
- version = ""
54
- end
55
-
56
- rdoc.rdoc_dir = 'rdoc'
57
- rdoc.title = "lda-ruby #{version}"
58
- rdoc.rdoc_files.include('README*')
59
- rdoc.rdoc_files.include('lib/**/*.rb')
60
- end
61
-
@@ -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