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 +4 -4
- data/bin/research_topicgen +3 -1
- data/lib/research_topicgen.rb +111 -107
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f312d608a4f1df1a5801fb57023dc6839915b715
|
4
|
+
data.tar.gz: 353a37ac03ac0d48ff30e72225722db9ee9094db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d09cf86b09f6df8124ace618c99c1654c81ce10c99785c233a942d738fa1da7efeed6d3ee0d6f088f42d248ea5713d24c65523e972c26144a7039f6a84c2db2e
|
7
|
+
data.tar.gz: e6253e85fb57f92da6e8740471e8517d9c97ff887e53b9a8fb90f97ffe0adfaa113ae188fc2019e0dcb07bef4e68a6ef16216602554911fd316b15b34452d9e6
|
data/bin/research_topicgen
CHANGED
data/lib/research_topicgen.rb
CHANGED
@@ -1,118 +1,122 @@
|
|
1
1
|
require 'psych'
|
2
2
|
|
3
3
|
module ResearchTopicGen
|
4
|
-
|
4
|
+
VERSION = '0.1.3'.freeze
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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.
|
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:
|
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:
|