diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-03-26 09:42:45 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-03-26 09:42:45 -0400 |
commit | ce7f42f1f3a45b9167a9cc4e85e1bc4488013c70 (patch) | |
tree | cf5d20927bc65a3a70303251ded0fb78072c642b | |
download | yandere-ce7f42f1f3a45b9167a9cc4e85e1bc4488013c70.tar.gz yandere-ce7f42f1f3a45b9167a9cc4e85e1bc4488013c70.tar.bz2 yandere-ce7f42f1f3a45b9167a9cc4e85e1bc4488013c70.zip |
Initial commit
-rw-r--r-- | .gitmodules | 6 | ||||
-rw-r--r-- | CMakeLists.txt | 17 | ||||
-rw-r--r-- | chemist.cpp | 156 | ||||
-rw-r--r-- | data.txt | 226 | ||||
m--------- | vendor/twitcurl | 0 | ||||
m--------- | vendor/verbly | 0 |
6 files changed, 405 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..16192d6 --- /dev/null +++ b/.gitmodules | |||
@@ -0,0 +1,6 @@ | |||
1 | [submodule "vendor/verbly"] | ||
2 | path = vendor/verbly | ||
3 | url = https://github.com/hatkirby/verbly | ||
4 | [submodule "vendor/twitcurl"] | ||
5 | path = vendor/twitcurl | ||
6 | url = https://github.com/swatkat/twitcurl | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9508ca5 --- /dev/null +++ b/CMakeLists.txt | |||
@@ -0,0 +1,17 @@ | |||
1 | cmake_minimum_required (VERSION 2.6) | ||
2 | project (chemist) | ||
3 | |||
4 | set(CMAKE_BUILD_TYPE Debug) | ||
5 | |||
6 | add_subdirectory(vendor/twitcurl/libtwitcurl) | ||
7 | add_subdirectory(vendor/verbly) | ||
8 | |||
9 | find_package(PkgConfig) | ||
10 | pkg_check_modules(YamlCpp yaml-cpp REQUIRED) | ||
11 | pkg_check_modules(sqlite3 sqlite3 REQUIRED) | ||
12 | |||
13 | include_directories(vendor/twitcurl/libtwitcurl ${sqlite3_INCLUDE_DIR} vendor/verbly/lib) | ||
14 | add_executable(chemist chemist.cpp) | ||
15 | set_property(TARGET chemist PROPERTY CXX_STANDARD 11) | ||
16 | set_property(TARGET chemist PROPERTY CXX_STANDARD_REQUIRED ON) | ||
17 | target_link_libraries(chemist verbly ${sqlite3_LIBRARIES} ${YamlCpp_LIBRARIES} twitcurl curl) | ||
diff --git a/chemist.cpp b/chemist.cpp new file mode 100644 index 0000000..a111931 --- /dev/null +++ b/chemist.cpp | |||
@@ -0,0 +1,156 @@ | |||
1 | #include <yaml-cpp/yaml.h> | ||
2 | #include <iostream> | ||
3 | #include <cstdlib> | ||
4 | #include <ctime> | ||
5 | #include <sstream> | ||
6 | #include <twitcurl.h> | ||
7 | #include <verbly.h> | ||
8 | |||
9 | int main(int argc, char** argv) | ||
10 | { | ||
11 | srand(time(NULL)); | ||
12 | |||
13 | YAML::Node config = YAML::LoadFile("config.yml"); | ||
14 | |||
15 | twitCurl twitter; | ||
16 | twitter.getOAuth().setConsumerKey(config["consumer_key"].as<std::string>()); | ||
17 | twitter.getOAuth().setConsumerSecret(config["consumer_secret"].as<std::string>()); | ||
18 | twitter.getOAuth().setOAuthTokenKey(config["access_key"].as<std::string>()); | ||
19 | twitter.getOAuth().setOAuthTokenSecret(config["access_secret"].as<std::string>()); | ||
20 | |||
21 | std::map<std::string, std::vector<std::string>> groups; | ||
22 | std::ifstream datafile("data.txt"); | ||
23 | if (!datafile.is_open()) | ||
24 | { | ||
25 | std::cout << "Could not find data.txt" << std::endl; | ||
26 | return 1; | ||
27 | } | ||
28 | |||
29 | bool newgroup = true; | ||
30 | std::string line; | ||
31 | std::string curgroup; | ||
32 | while (getline(datafile, line)) | ||
33 | { | ||
34 | if (line.back() == '\r') | ||
35 | { | ||
36 | line.pop_back(); | ||
37 | } | ||
38 | |||
39 | if (newgroup) | ||
40 | { | ||
41 | curgroup = line; | ||
42 | newgroup = false; | ||
43 | } else { | ||
44 | if (line.empty()) | ||
45 | { | ||
46 | newgroup = true; | ||
47 | } else { | ||
48 | groups[curgroup].push_back(line); | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | |||
53 | verbly::data database {"data.sqlite3"}; | ||
54 | for (;;) | ||
55 | { | ||
56 | std::cout << "Generating tweet" << std::endl; | ||
57 | std::string action = "{Main}"; | ||
58 | int tknloc; | ||
59 | while ((tknloc = action.find("{")) != std::string::npos) | ||
60 | { | ||
61 | std::string token = action.substr(tknloc+1, action.find("}")-tknloc-1); | ||
62 | std::string modifier; | ||
63 | int modloc; | ||
64 | if ((modloc = token.find(":")) != std::string::npos) | ||
65 | { | ||
66 | modifier = token.substr(modloc+1); | ||
67 | token = token.substr(0, modloc); | ||
68 | } | ||
69 | |||
70 | std::string canontkn; | ||
71 | std::transform(std::begin(token), std::end(token), std::back_inserter(canontkn), [] (char ch) { | ||
72 | return std::toupper(ch); | ||
73 | }); | ||
74 | |||
75 | std::string result; | ||
76 | if (canontkn == "NOUN") | ||
77 | { | ||
78 | result = database.nouns().is_not_proper().random().limit(1).run().front().singular_form(); | ||
79 | } else if (canontkn == "ADJECTIVE") | ||
80 | { | ||
81 | result = database.adjectives().random().limit(1).run().front().base_form(); | ||
82 | } else if (canontkn == "VERBING") | ||
83 | { | ||
84 | result = database.verbs().random().limit(1).run().front().ing_form(); | ||
85 | } else if (canontkn == "YEAR") | ||
86 | { | ||
87 | result = std::to_string(rand() % 100 + 1916); | ||
88 | } else if (canontkn == "REGION") | ||
89 | { | ||
90 | auto hem1 = database.nouns().with_singular_form("eastern hemisphere").limit(1).run().front(); | ||
91 | auto hem2 = database.nouns().with_singular_form("western hemisphere").limit(1).run().front(); | ||
92 | verbly::filter<verbly::noun> region{hem1, hem2}; | ||
93 | region.set_orlogic(true); | ||
94 | |||
95 | result = database.nouns().full_part_holonym_of(region).random().limit(1).run().front().singular_form(); | ||
96 | } else if (canontkn == "FAMOUSNAME") | ||
97 | { | ||
98 | auto person = database.nouns().with_singular_form("person").limit(1).run().front(); | ||
99 | auto ptypes = database.nouns().full_hyponym_of({person}).is_class().random().limit(1).run().front(); | ||
100 | result = database.nouns().instance_of({ptypes}).random().limit(1).run().front().singular_form(); | ||
101 | } else { | ||
102 | auto group = groups[canontkn]; | ||
103 | result = group[rand() % group.size()]; | ||
104 | } | ||
105 | |||
106 | if (modifier == "indefinite") | ||
107 | { | ||
108 | if ((result.length() > 1) && (isupper(result[0])) && (isupper(result[1]))) | ||
109 | { | ||
110 | result = "an " + result; | ||
111 | } else if ((result[0] == 'a') || (result[0] == 'e') || (result[0] == 'i') || (result[0] == 'o') || (result[0] == 'u')) | ||
112 | { | ||
113 | result = "an " + result; | ||
114 | } else { | ||
115 | result = "a " + result; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | std::string finalresult; | ||
120 | if (islower(token[0])) | ||
121 | { | ||
122 | std::transform(std::begin(result), std::end(result), std::back_inserter(finalresult), [] (char ch) { | ||
123 | return std::tolower(ch); | ||
124 | }); | ||
125 | } else if (isupper(token[0]) && !isupper(token[1])) | ||
126 | { | ||
127 | auto words = verbly::split<std::list<std::string>>(result, " "); | ||
128 | for (auto& word : words) | ||
129 | { | ||
130 | word[0] = std::toupper(word[0]); | ||
131 | } | ||
132 | |||
133 | finalresult = verbly::implode(std::begin(words), std::end(words), " "); | ||
134 | } else { | ||
135 | finalresult = result; | ||
136 | } | ||
137 | |||
138 | action.replace(tknloc, action.find("}")-tknloc+1, finalresult); | ||
139 | } | ||
140 | |||
141 | action.resize(140); | ||
142 | |||
143 | std::string replyMsg; | ||
144 | if (twitter.statusUpdate(action)) | ||
145 | { | ||
146 | twitter.getLastWebResponse(replyMsg); | ||
147 | std::cout << "Twitter message: " << replyMsg << std::endl; | ||
148 | } else { | ||
149 | twitter.getLastCurlError(replyMsg); | ||
150 | std::cout << "Curl error: " << replyMsg << std::endl; | ||
151 | } | ||
152 | |||
153 | std::cout << "Waiting" << std::endl; | ||
154 | sleep(60 * 60); | ||
155 | } | ||
156 | } | ||
diff --git a/data.txt b/data.txt new file mode 100644 index 0000000..6a7c6ea --- /dev/null +++ b/data.txt | |||
@@ -0,0 +1,226 @@ | |||
1 | MAIN | ||
2 | {PRIMARY} {SECONDARY} | ||
3 | |||
4 | PRIMARY | ||
5 | {NAME} is {CLASS:indefinite} commonly used to treat {syndrome}. | ||
6 | {NAME} is {CLASS:indefinite} primarily used for {syndrome}. | ||
7 | {NAME} is {CLASS:indefinite} prescribed for {syndrome}. | ||
8 | {NAME} is {CLASS:indefinite} approved for treatment of {syndrome}, {syndrome}, and {syndrome}. | ||
9 | {NAME} is {CLASS:indefinite} used for {syndrome} and {syndrome}. | ||
10 | {NAME} is {CLASS:indefinite} used with {existent} to treat {syndrome}. | ||
11 | |||
12 | SECONDARY | ||
13 | Developed in {year} in response to the Great {Noun} Epidemic in {Region}. | ||
14 | Frequently prescribed off-label for {syndrome}. | ||
15 | Sometimes used for {syndrome} because of its {verbing} effect. | ||
16 | Illegal to own in the US because of its {verbing} effect. | ||
17 | Developed in {year} to replace {existent}. | ||
18 | Overtook {existent} as the primary treatment, having fewer side effects. | ||
19 | Synthesized by {FamousName} in {year} in a {verbing} accident. | ||
20 | Used mainly in {year}, before {existent} became popular. | ||
21 | |||
22 | SYNDROME | ||
23 | Irritable {Noun} Syndrome | ||
24 | {Adjective} {Noun} Syndrome | ||
25 | Severe {Noun} | ||
26 | Major {Adjective} Disorder | ||
27 | {Adjective} {Noun} Disorder | ||
28 | Obsessive {Adjective} Disorder | ||
29 | Clinical {Noun} | ||
30 | |||
31 | CLASS | ||
32 | analgesic | ||
33 | painkiller | ||
34 | anaesthetic | ||
35 | antihistamine | ||
36 | anticonvulsant | ||
37 | antiepileptic | ||
38 | antidepressant | ||
39 | antimigraine | ||
40 | antipsychotic | ||
41 | benzodiazepine | ||
42 | antiparkinsonian | ||
43 | immunosuppressive | ||
44 | antianaemia | ||
45 | anticoagulant | ||
46 | blood thinner | ||
47 | antiarrhythmic | ||
48 | antithrombotic | ||
49 | antifungal | ||
50 | anti-infective | ||
51 | anti-inflammatory | ||
52 | disinfectant | ||
53 | antispetic | ||
54 | antiemetic | ||
55 | diuretic | ||
56 | opiod painkiller | ||
57 | antiulcer | ||
58 | laxative | ||
59 | sedative | ||
60 | hormone | ||
61 | estrogen | ||
62 | androgen | ||
63 | contraceptive | ||
64 | ovulation inducer | ||
65 | thyroid stimulant | ||
66 | antithyroid | ||
67 | insulin | ||
68 | vaccine | ||
69 | oxytocin | ||
70 | SSRI | ||
71 | anxiolytic | ||
72 | antipanic agent | ||
73 | tricyclic | ||
74 | MAOI | ||
75 | SNRI | ||
76 | antiandrogen | ||
77 | psychedelic | ||
78 | vitamin | ||
79 | probiotic | ||
80 | antibiotic | ||
81 | antiviral drug | ||
82 | stimulant | ||
83 | depressant | ||
84 | |||
85 | EXISTENT | ||
86 | Fluoxetine | ||
87 | Prozac | ||
88 | Sertraline | ||
89 | Zoloft | ||
90 | Escitalopram | ||
91 | Lexapro | ||
92 | Venlafaxine | ||
93 | Effexor | ||
94 | Aripiprazole | ||
95 | Abilify | ||
96 | Alprazolam | ||
97 | Xanax | ||
98 | Diazepam | ||
99 | Valium | ||
100 | Lamotrigine | ||
101 | Lamictal | ||
102 | Gabapentin | ||
103 | Neurontin | ||
104 | Acetaminophen | ||
105 | Tylenol | ||
106 | Ibuprofin | ||
107 | Advil | ||
108 | Lurasidone | ||
109 | Latuda | ||
110 | Lithium | ||
111 | Activated charcoal | ||
112 | Estradiol | ||
113 | AndroGel | ||
114 | Ziprasidone | ||
115 | Geodon | ||
116 | Risperidone | ||
117 | Risperdal | ||
118 | Quetiapine | ||
119 | Seroquel | ||
120 | Cymbalta | ||
121 | Duloxetine | ||
122 | Bupropion | ||
123 | Welbutrin | ||
124 | Buspirone | ||
125 | Buspar | ||
126 | Oxycontin | ||
127 | Oxycodone | ||
128 | Concerta | ||
129 | Methylphenidate | ||
130 | Ritalin | ||
131 | Vyvanse | ||
132 | Lisdexamfetamine | ||
133 | Adderall | ||
134 | Epinephrine | ||
135 | Adrenaline | ||
136 | Testosterone gel | ||
137 | Cialis | ||
138 | Viagra | ||
139 | Heroin | ||
140 | Morphine | ||
141 | Crystal meth | ||
142 | |||
143 | NAME | ||
144 | {PRENAME}{NAMEMID}{NAMEIFX} | ||
145 | |||
146 | PRENAME | ||
147 | Oxy | ||
148 | Ari | ||
149 | Zi | ||
150 | Quetia | ||
151 | Mor | ||
152 | Her | ||
153 | Cia | ||
154 | Via | ||
155 | He | ||
156 | Con | ||
157 | Flu | ||
158 | Ser | ||
159 | Es | ||
160 | Ven | ||
161 | Al | ||
162 | Dia | ||
163 | Lamo | ||
164 | Gaba | ||
165 | Aceta | ||
166 | Ibu | ||
167 | Lura | ||
168 | Ris | ||
169 | Li | ||
170 | Estra | ||
171 | Du | ||
172 | Bus | ||
173 | Epin | ||
174 | |||
175 | NAMEMID | ||
176 | pipra | ||
177 | pi | ||
178 | to | ||
179 | stero | ||
180 | cer | ||
181 | oxe | ||
182 | tra | ||
183 | cita | ||
184 | lo | ||
185 | la | ||
186 | fa | ||
187 | pra | ||
188 | zo | ||
189 | ze | ||
190 | tri | ||
191 | pen | ||
192 | mino | ||
193 | pro | ||
194 | si | ||
195 | peri | ||
196 | thi | ||
197 | loxe | ||
198 | con | ||
199 | epher | ||
200 | {NAMEMID} | ||
201 | {NAMEMID} | ||
202 | |||
203 | NAMEIFX | ||
204 | zole | ||
205 | ne | ||
206 | tine | ||
207 | lin | ||
208 | tamine | ||
209 | gra | ||
210 | phine | ||
211 | ta | ||
212 | line | ||
213 | pram | ||
214 | xine | ||
215 | lam | ||
216 | pam | ||
217 | gine | ||
218 | tin | ||
219 | phen | ||
220 | fin | ||
221 | done | ||
222 | um | ||
223 | diol | ||
224 | tin | ||
225 | rone | ||
226 | ine \ No newline at end of file | ||
diff --git a/vendor/twitcurl b/vendor/twitcurl new file mode 160000 | |||
Subproject 6659e86de7481e50977b7569c75138f7f69ad3c | |||
diff --git a/vendor/verbly b/vendor/verbly new file mode 160000 | |||
Subproject 6b7c77f3a28d9a44afacb76e3db58a5ff5f59f4 | |||