module ResearchTopicGen
Constants
- BZS
- VERSION
Public Class Methods
add_article(word, caps=false)
click to toggle source
# File lib/research_topicgen.rb, line 127 def self.add_article(word, caps=false) if word.downcase.start_with?('a', 'e', 'i', 'o', 'u') article = "an" else article = 'a' end caps ? article.capitalize : article end
crypto()
click to toggle source
Crypto Research Topic Generator
# File lib/research_topicgen.rb, line 8 def self.crypto cf = self.load_yml_data( 'crypto' ) word1, word2, word3 = self.samples( BZS, cf ) until word1 != word2 word2 = cf[:buzz2].sample end pre_connective = self.add_article(word1, caps=true) "#{pre_connective} #{word1}, #{word2} #{word3}." end
cs()
click to toggle source
CS Research Topic Generator
# File lib/research_topicgen.rb, line 19 def self.cs connectives_file, cs_file = self.load_file('cs') com_connective = [ connectives_file[:common_connectives].sample, connectives_file[:extra_connectives][1] ].sample pre_wrds = self.samples( %i[buzz1 buzz2 buzz3], cs_file ) pst_wrds = self.samples( %i[buzz1 buzz2 buzz3], cs_file ) pre_connective = self.add_article(pre_wrds.first, caps=true) mid_connective = self.add_article(pst_wrds.first) sentence = [ pre_connective, *pre_wrds, com_connective, mid_connective, *pst_wrds ] "#{sentence.join ' '}." end
load_file(topic)
click to toggle source
# File lib/research_topicgen.rb, line 145 def self.load_file(topic) conf = load_yml_data('connectives') [ conf, load_yml_data(topic) ] end
load_yml_data(topic)
click to toggle source
# File lib/research_topicgen.rb, line 140 def self.load_yml_data(topic) data = File.join( File.dirname(__FILE__), "data", "#{topic}.yml" ) Psych.load_file( data ) end
random()
click to toggle source
Generate Random Topic
# File lib/research_topicgen.rb, line 49 def self.random topic = %w[ cs system crypto ].sample self.send( topic ) end
samples( keys , table )
click to toggle source
# File lib/research_topicgen.rb, line 136 def self.samples( keys , table ) keys.map { |key| table[key].sample } end
system()
click to toggle source
System Research Topic Generatorg
# File lib/research_topicgen.rb, line 42 def self.system mtds = [:generic, :approach_based, :onfoo, :looong, :ings] gen = SystemTopicGenerator.new gen.send( mtds.sample ) end