research_topicgen 0.1.1 → 0.1.3

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: e3e62081eb8f983cdd31a13ef17379b7154ff19f
4
- data.tar.gz: 60a0a40ab5e941d3ca46ce9b48dcd83410868572
3
+ metadata.gz: f312d608a4f1df1a5801fb57023dc6839915b715
4
+ data.tar.gz: 353a37ac03ac0d48ff30e72225722db9ee9094db
5
5
  SHA512:
6
- metadata.gz: 0399be077f2c3d32ba0212a2f453d2011f0f6b39e6bf10bfcd72c825d17298bcee75c4d05b233325c4e445c01c9b3d4415599d4f27c45540057d119bd61946bf
7
- data.tar.gz: 688b22872fd5ea40e35164b536a088e71f9de5baefbdb963ae3034f6845427a7423407b696b5215132087dc86e1744f0fd1fa1ca34a5f54221df10f245771e67
6
+ metadata.gz: d09cf86b09f6df8124ace618c99c1654c81ce10c99785c233a942d738fa1da7efeed6d3ee0d6f088f42d248ea5713d24c65523e972c26144a7039f6a84c2db2e
7
+ data.tar.gz: e6253e85fb57f92da6e8740471e8517d9c97ff887e53b9a8fb90f97ffe0adfaa113ae188fc2019e0dcb07bef4e68a6ef16216602554911fd316b15b34452d9e6
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'research_topicgen'
3
3
 
4
- puts ResearchTopicGen.random
4
+ puts ResearchTopicGen.system
5
+ puts ResearchTopicGen.crypto
6
+ puts ResearchTopicGen.cs
@@ -1,118 +1,122 @@
1
1
  require 'psych'
2
2
 
3
3
  module ResearchTopicGen
4
- VERSION = '0.1.1'.freeze
4
+ VERSION = '0.1.3'.freeze
5
5
 
6
- def self.load_file(topic)
7
- case topic
8
- when 'cs'
9
- cs_file = Psych.load_file(File.join(File.dirname(__FILE__), 'data/cs_data.yml'))
10
- connectives_file = Psych.load_file(File.join(File.dirname(__FILE__), 'data/connectives.yml'))
11
- return connectives_file, cs_file
12
- when 'system'
13
- connectives_file = Psych.load_file(File.join(File.dirname(__FILE__), 'data/connectives.yml'))
14
- system_file = Psych.load_file(File.join(File.dirname(__FILE__), 'data/system_data.yml'))
15
- return connectives_file, system_file
16
- when 'crypto'
17
- crypto_file = Psych.load_file(File.join(File.dirname(__FILE__), 'data/crypto_data.yml'))
18
- return crypto_file
19
- else
20
- return nil
21
- end
22
- end
6
+ def self.load_yml_data(topic)
7
+ Psych.load_file(File.join(File.dirname(__FILE__), "data", "#{topic}.yml"))
8
+ end
9
+
10
+ def self.load_file(topic)
11
+ case topic
12
+ when 'cs'
13
+ [load_yml_data('connectives'), load_yml_data('cs_data')]
14
+ when 'system'
15
+ [load_yml_data('connectives'), load_yml_data('system_data')]
16
+ when 'crypto'
17
+ load_yml_data('crypto_data')
18
+ end
19
+ end
23
20
 
24
- # CS Research Topic Generator
25
- def self.cs
26
- connectives_file, cs_file = self.load_file('cs')
27
- connectives = Array.new.push(connectives_file[:common_connectives], connectives_file[:extra_connectives][1])
28
- .flatten! # :common_connectives were stored in an array.
29
- sentence = [cs_file[:buzz1].sample, cs_file[:buzz2].sample, cs_file[:buzz3].sample, connectives[rand(0...connectives.length)], cs_file[:buzz1].sample, cs_file[:buzz2].sample, cs_file[:buzz3].sample ]
30
- pre_connective = ResearchTopicGen.vowel_check(sentence[0], true)
31
- mid_connective = ResearchTopicGen.vowel_check(sentence[4], false)
32
- sentence.insert(0, pre_connective)
33
- sentence.insert(5, mid_connective)
34
- sentence.join(' ') << '.' # Period to mark the end of the sentence.
35
- end
21
+ # CS Research Topic Generator
22
+ def self.cs
23
+ connectives_file, cs_file = self.load_file('cs')
24
+ connectives = *connectives_file[:common_connectives], *connectives_file[:extra_connectives][1]
25
+ connectives.flatten!
26
+ sentence = [cs_file[:buzz1].sample,
27
+ cs_file[:buzz2].sample,
28
+ cs_file[:buzz3].sample,
29
+ connectives.sample,
30
+ cs_file[:buzz1].sample,
31
+ cs_file[:buzz2].sample,
32
+ cs_file[:buzz3].sample
33
+ ]
34
+ pre_connective = ResearchTopicGen.add_article(sentence[0], true)
35
+ mid_connective = ResearchTopicGen.add_article(sentence[4], false)
36
+ sentence.insert(0, pre_connective)
37
+ sentence.insert(5, mid_connective)
38
+ "#{sentence.join(' ')}."
39
+ end
36
40
 
37
- # System Research Topic Generator
38
- def self.system
39
- connectives_file, system_file = self.load_file('system')
40
- connectives = Array.new.push(connectives_file[:common_connectives], connectives_file[:extra_connectives][0])
41
- .flatten!
42
- word1, word2, word3, word4 = system_file[:buzz1].sample, system_file[:buzz2].sample, system_file[:buzz3].sample, system_file[:buzz2].sample
43
- name, ingword = system_file[:names].sample, system_file[:ings].sample
41
+ # System Research Topic Generatorg
42
+ def self.system
43
+ connectives_file, system_file = self.load_file('system')
44
+ connectives = *connectives_file[:common_connectives], connectives_file[:extra_connectives][0]
45
+ connectives.flatten!
46
+ word1, word2, word3, word4 = system_file[:buzz1].sample, system_file[:buzz2].sample, system_file[:buzz3].sample, system_file[:buzz2].sample
47
+ name, ingword = system_file[:names].sample, system_file[:ings].sample
48
+
49
+ word2, word3, word4 =
50
+ case
51
+ when word2 == word1
52
+ self.random_word(system_file, 1, word1, word2)
53
+ when word3 == word1 || word3 == word2
54
+ self.random_word(system_file, 2, word1, word2, word3)
55
+ when word4 == word2 || word4 == word3 || word4 == word1
56
+ self.random_word(system_file, 3, word1, word2, word3, word4)
57
+ else
58
+ [word2, word3, word4]
59
+ end
60
+
61
+ # generic: [name]: [word1], [word2] [word3]
62
+ pre_connective = self.add_article(word1, true)
63
+ result1 = "#{name}: #{pre_connective} #{word1}, #{word2} #{word3}"
64
+
65
+ # approach-based: [generic] - [a/an] [buzz2] approach
66
+ mid_connective = self.add_article(word4, false)
67
+ result2 = "#{name}:#{word1}, #{word2} #{word3}s-- #{mid_connective} #{word4} approach"
68
+
69
+ # on...: on[foo]s
70
+ result3 = "On #{word1}, #{word2} #{word3}s"
71
+ word5, word6, word7 = system_file[:buzz1].sample, system_file[:buzz2].sample, system_file[:buzz3].sample
72
+ mid_connective = self.add_article(word5, false)
73
+ word6 = self.random_word(system_file, 4, word1, word2, word3, word5, word6) if word5 == word6 || word5 == word3 || word5 == word2 || word5 == word1
74
+ word7 = self.random_word(system_file, 5, word1, word2, word3, word5, word6, word7) if word7 == word5 || word7 == word6 || word7 == word3 || word7 == word2 || word7 == word1
75
+ result4 = "#{result1} #{mid_connective} #{word5} #{word6} #{word7}s"
76
+ result5 = "#{ingword} #{word1}, #{word2} #{word3}s"
77
+ results = [result1, result2, result3, result4, result5]
78
+ "#{results.sample}."
79
+ end
44
80
 
45
- word2, word3, word4 =
46
- case
47
- when word2==word1
48
- self.random_word(system_file, 1, word1, word2)
49
- when (word3==word1 || word3==word2)
50
- self.random_word(system_file, 2, word1, word2, word3)
51
- when (word4==word2 || word4==word3 || word4==word1)
52
- self.random_word(system_file, 3, word1, word2, word3, word4)
53
- else
54
- [word2, word3, word4]
55
- end
81
+ # Crypto Research Topic Generator
82
+ def self.crypto
83
+ crypto_file = self.load_file('crypto')
84
+ word1, word2, word3 = crypto_file[:buzz1].sample, crypto_file[:buzz2].sample, crypto_file[:buzz3].sample
85
+ word2 = word2.match(word1) ? ResearchTopicGen.random_word(crypto_file, 1, word1, word2) : word2 #If word1 and word2 are same, replace word2 with a different word.
86
+ pre_connective = ResearchTopicGen.add_article(word1, true)
87
+ sentence = "#{pre_connective} #{word1}, #{word2} #{word3}."
88
+ end
56
89
 
57
- # generic: [name]: [word1], [word2] [word3]
58
- pre_connective = self.vowel_check(word1, true)
59
- result1 = "#{name}: #{pre_connective} #{word1}, #{word2} #{word3}"
60
-
61
- # approach-based: [generic] - [a/an] [buzz2] approach
62
- mid_connective = self.vowel_check(word4, false)
63
- result2 = "#{name}:#{word1}, #{word2} #{word3}s-- #{mid_connective} #{word4} approach"
64
-
65
- # on...: on[foo]s
66
- result3 = "On #{word1}, #{word2} #{word3}s"
67
- word5, word6, word7 = system_file[:buzz1].sample, system_file[:buzz2].sample, system_file[:buzz3].sample
68
- mid_connective = self.vowel_check(word5, false)
69
- word6 = self.random_word(system_file, 4, word1, word2, word3, word5, word6) if (word5==word6 || word5==word3 || word5==word2 || word5==word1)
70
- word7 = self.random_word(system_file, 5, word1, word2, word3, word5, word6, word7) if (word7==word5 || word7==word6 || word7==word3 || word7==word2 || word7==word1)
71
- result4 = "#{result1} #{mid_connective} #{word5} #{word6} #{word7}s"
72
- result5 = "#{ingword} #{word1}, #{word2} #{word3}s"
73
- results = [result1, result2, result3, result4, result5]
74
- "#{results.sample}."
75
- end
90
+ # Generate Random Topic
91
+ def self.random
92
+ result = [ResearchTopicGen.cs, ResearchTopicGen.system, ResearchTopicGen.crypto].sample
93
+ end
76
94
 
77
- # Crypto Research Topic Generator
78
- def self.crypto
79
- crypto_file = self.load_file('crypto')
80
- word1, word2, word3 = crypto_file[:buzz1].sample, crypto_file[:buzz2].sample, crypto_file[:buzz3].sample
81
- word2 = word2.match(word1) ? ResearchTopicGen.random_word(crypto_file, 1, word1, word2) : word2 #If word1 and word2 are same, replace word2 with a different word.
82
- pre_connective = ResearchTopicGen.vowel_check(word1, true)
83
- sentence = "#{pre_connective} #{word1}, #{word2} #{word3}."
84
- end
95
+ # Logic here needs a change.
96
+ def self.random_word(file, checks, *col)
97
+ if checks == 2
98
+ col[2] = file[:buzz3].sample until col[0] != col[2] && col[1] != col[2]
99
+ col[1..checks]
100
+ elsif checks == 3
101
+ col[3] = file[:buzz2].sample until col[3] != col[1] && col[3] != col[2] && col[3] != col[0]
102
+ col[1..checks]
103
+ elsif checks == 4
104
+ col[4] = file[:buzz2].sample until col[3] != col[4] && col[3] != col[2] && col[3] != col[1] && col[3] != col[0]
105
+ elsif checks == 5
106
+ col[5] = file[:buzz3].sample until col[5] != col[3] && col[5] != col[4] && col[5] != col[2] && col[5] != col[1]
107
+ else
108
+ col[1] = file[:buzz2].sample until col[0] != col[1]
109
+ col[1]
110
+ end
111
+ end
85
112
 
86
- # Generate Random Topic
87
- def self.random
88
- result = [ResearchTopicGen.cs, ResearchTopicGen.system, ResearchTopicGen.crypto].sample
89
- end
90
-
91
- # Generate random word when col1 and col2 are same.
92
- def self.random_word(file, checks, *col)
93
- case checks
94
- when 2
95
- col[2] = file[:buzz3].sample until (col[0] != col[2] && col[1] != col[2])
96
- return col[1..checks]
97
- when 3
98
- col[3] = file[:buzz2].sample until (col[3] != col[1] && col[3] != col[2] && col[3] != col[0])
99
- return col[1..checks]
100
- when 4
101
- col[4] = file[:buzz2].sample until (col[3] != col[4] && col[3] != col[2] && col[3] != col[1] && col[3] != col[0])
102
- when 5
103
- col[5] = file[:buzz3].sample until (col[5] != col[3] && col[5] != col[4] && col[5] != col[2] && col[5] != col[1] && col[5] != col[0])
104
- else
105
- col[1] = file[:buzz2].sample until col[0] != col[1]
106
- end
107
- end
108
-
109
- # return the correct article
110
- def self.vowel_check(word, caps)
111
- if word.match(/^[aeiou]/i)
112
- article = "an"
113
- else
114
- article = 'a'
115
- end
116
- return caps ? article.capitalize : article
117
- end
113
+ # return the correct article
114
+ def self.add_article(word, caps)
115
+ if word.match(/^[aeiou]/i)
116
+ article = "an"
117
+ else
118
+ article = 'a'
119
+ end
120
+ caps ? article.capitalize : article
121
+ end
118
122
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: research_topicgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - slackr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-17 00:00:00.000000000 Z
11
+ date: 2016-01-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple gem to generate worthy Research Topics.
14
14
  email: slackErEhth77@openmailbox.org
@@ -43,9 +43,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  version: '0'
44
44
  requirements: []
45
45
  rubyforge_project:
46
- rubygems_version: 2.4.5
46
+ rubygems_version: 2.4.5.1
47
47
  signing_key:
48
48
  specification_version: 4
49
49
  summary: research_topicgen - A Research Topic Generator
50
50
  test_files: []
51
- has_rdoc: