class ResearchTopicGen::SystemTopicGenerator
System Research Topic Generatorg
Public Class Methods
new()
click to toggle source
# File lib/research_topicgen.rb, line 56 def initialize @connectives_file, @system_file = ResearchTopicGen.load_file('system') @added = {} @words = [] end
Public Instance Methods
approach_based()
click to toggle source
approach-based: [generic] - [a/an] [buzz2] approach
# File lib/research_topicgen.rb, line 69 def approach_based buzz2 = gen_word :buzz2 article = ResearchTopicGen.add_article( buzz2 ) "#{generic} - #{article} #{buzz2} approach" end
generic()
click to toggle source
generic: [name]: [word1], [word2] [word3]
# File lib/research_topicgen.rb, line 63 def generic w1_3 = format_words( 0, caps = true ) "#{gen_word( :names )}: #{w1_3}" end
ings()
click to toggle source
- ing
- buzz1
- buzz2
-
[buzz3]s
# File lib/research_topicgen.rb, line 88 def ings ing = gen_word( :ings ) rest = format_words(0, article=false) "#{ing} #{rest}s" end
looong()
click to toggle source
- generic
- a/an
- buzz1], [buzz2
-
[buzz3]s
# File lib/research_topicgen.rb, line 82 def looong rest = format_words( 4 ) "#{generic} #{rest}s" end
onfoo()
click to toggle source
on…: ons
# File lib/research_topicgen.rb, line 76 def onfoo foo = format_words( 0, article=false ) "on #{foo}s" end
Private Instance Methods
format_words( offset, caps = false, article = true )
click to toggle source
# File lib/research_topicgen.rb, line 96 def format_words( offset, caps = false, article = true ) gen_words # (re-)generate a fresh set of words ws = @words[offset, 3] bz1 = ws.first bz2_3 = ws[1, 2].join( ' ' ) article = article ? ResearchTopicGen.add_article( bz1, caps ) : '' "#{article} #{bz1}, #{bz2_3}" end
gen_word( bz )
click to toggle source
# File lib/research_topicgen.rb, line 105 def gen_word( bz ) loop do word = @system_file[bz].sample unless @added[word] @added[word] = true return word end end end
gen_words()
click to toggle source
# File lib/research_topicgen.rb, line 115 def gen_words # flush stored results @added = {} @words = [] BZS.cycle(2).map do |bz| @words.push gen_word( bz ) end @words.insert(3, gen_word(:buzz2)) end