Skip to content

Commit 1c0a06a

Browse files
author
Benjamin Yu
committedOct 7, 2010
Working version. Has classified entire system.
1 parent d2f1118 commit 1c0a06a

File tree

5 files changed

+124
-88
lines changed

5 files changed

+124
-88
lines changed
 

‎check_res

+59-68
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,62 @@
1-
# Format:
2-
# # Original word: 'X'
3-
# # Spelling variations of 'X' in regex; commented out because they're covered by the last line (e.g. covers fuk and pussi)
4-
# Vowel-to-nonalphabetic-character substitutions or vowel omissions (e.g. covers f*ck and pssy)
5-
# Inner letter-to-nonalphabetic substitutions (e.g. cover f**k or p***y)
6-
# Cover the original spelling variations, and randomly inserted or repeated characters (e.g. fuck, fuuuuck, fu--c032k)
7-
8-
# Original word: 'fuck'
9-
# fu[ck]?[ck]
10-
11-
# Original word: 'wank'
12-
# wan[ck]
13-
14-
# Original word: 'dick'
15-
# more complicated than usual, in order to exclude 'dic' but include every other variation of di[ck]+
16-
# dik[ck]?
17-
# dic[ck]
18-
19-
# Original word: 'cock'
20-
# [ck]o[ck][ck]
21-
22-
# Original word: 'penis'
23-
# penis
24-
25-
# Original word: 'crap'
26-
# [ck]rap
27-
28-
# Original word: 'shit'
29-
# shi[tz]
30-
31-
# Original word: 'piss'
32-
# piss
33-
34-
# Original word: 'skeet'
35-
# s[ck]eet
36-
37-
# Original word: 'bitch'
38-
# bitch
39-
40-
# Original word: 'tits'
41-
# tits
42-
43-
# Original word: 'titties'
44-
# titties
45-
46-
# Original word: 'vag' and 'vagina'
47-
# (?<=[\s])vag(ina|\s)
48-
49-
# Original word: 'pussy'
50-
# puss[yie]
51-
52-
# Original word: 'cunt'
53-
# [kc]unt
54-
55-
# Original word: 'twat'
56-
# twat
57-
58-
# Original word: 'clit'
59-
# [ck]lit
60-
61-
# Original word: 'ass'
62-
# ass
63-
64-
# Original word: 'cum'
65-
# [ck]um
66-
[ck]+[^a-zA-Z\s]*u+[^a-zA-Z\s]*m+
67-
68-
#Andy's words
1+
f[^a-zA-Z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[^a-zA-Z\s',;()]*s+[^a-zA-Z\s',;()]*s+[^a-zA-Z\s',;()]*[yie]+
45+
[kc][^a-zA-Z\s',;()]?nt
46+
[kc][^a-zA-Z\s',;()]+[^a-zA-Z\s',;()]?t
47+
[kc]+[^a-zA-Z\s',;()]*u+[^a-zA-Z\s',;()]*n+[^a-zA-Z\s',;()]*t+
48+
tw[^a-zA-Z\s',;()]?t
49+
t[^a-zA-Z\s',;()]+[^a-zA-Z\s',;()]?t
50+
t+[^a-zA-Z\s',;()]*w+[^a-zA-Z\s',;()]*a+[^a-zA-Z\s',;()]*t+
51+
[ck]l[^a-zA-Z\s',;()]?t
52+
[ck][^a-zA-Z\s',;()]+[^a-zA-Z\s',;()]?t
53+
[ck]+[^a-zA-Z\s',;()]*l+[^a-zA-Z\s',;()]*i+[^a-zA-Z\s',;()]*t+
54+
[^a-zA-Z\s',;()]ss[^a-zA-Z]?hole
55+
a[^a-zA-Z\s',;()]+s[^a-zA-Z]?hole
56+
a+[^a-zA-Z\s',;()]*s+[^a-zA-Z\s',;()]*s+[^a-zA-Z]?hole
57+
[ck][^a-zA-Z\s',;()]m
58+
[ck][^a-zA-Z\s',;()]+m
59+
[ck]+[^a-zA-Z\s',;()]*u+[^a-zA-Z\s',;()]*m+
6960
c\*\*\*
7061
f\*\*\*
7162
s\*\*\*

‎lyricsChecker.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ list< list<int> > LyricChecker::checkLyrics(string title,
6666

6767
//Fetch linked list of lyrics
6868
list<string>* lyrics = lyricsGrabber::getLyrics(title, artist, album);
69+
cout << "Lyrics grabbed." << endl;
6970

7071
//Check for empty list
7172
if (lyrics->empty() == true) {
@@ -101,6 +102,8 @@ list< list<int> > LyricChecker::checkLyrics(string title,
101102
occurances.push_back(counts);
102103
}
103104

105+
cout << "Counts calculated." << endl;
106+
104107
delete lyrics;
105108
return occurances;
106109
}

‎lyricsGrabber.cpp

+23-15
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ namespace lyricsGrabber {
9494
//Weekly keys are available from http://lyricsfly.com/api/
9595
//Review terms and request permanent keys at
9696
//http://lyricsfly.com/contact/
97-
ifstream keyFile;
9897
string skey;
9998
skey = lyric_con::return_config("lyricskey");
10099
// keyFile.open(LYRICSFLY_KEYFILE);
@@ -147,24 +146,33 @@ namespace lyricsGrabber {
147146
char tmp[50];
148147
regerror(status, NULL, tmp, 50);
149148
cout << tmp << "\n\n";
150-
exit(-1);
151-
}
152-
153-
char* stat_code;
154-
stat_code = new char[matches.rm_eo-matches.rm_so+1]; //+1 for NULL terminator!
155-
strncpy(stat_code, buf+matches.rm_so, matches.rm_eo-matches.rm_so);
156-
stat_code[matches.rm_eo-matches.rm_so] = '\0';
157-
cout << stat_code <<"\n\n";
158-
if (strcmp(stat_code, "<status>200</status>") != 0) {
159-
if (strcmp(stat_code, "<status>402</status>") == 0) {
160-
good_to_go=false;
149+
if (status == REG_NOMATCH) {
150+
good_to_go = false;
151+
sleep(1);
161152
delete[] buf;
162-
sleep(4);
163153
} else {
154+
exit(-1);
155+
}
156+
}
157+
158+
159+
if (status == 0) {
160+
char* stat_code;
161+
stat_code = new char[matches.rm_eo-matches.rm_so+1]; //+1 for NULL terminator!
162+
strncpy(stat_code, buf+matches.rm_so, matches.rm_eo-matches.rm_so);
163+
stat_code[matches.rm_eo-matches.rm_so] = '\0';
164+
//cout << stat_code <<"\n\n";
165+
if (strcmp(stat_code, "<status>200</status>") != 0) {
166+
if (strcmp(stat_code, "<status>402</status>") == 0) {
167+
good_to_go=false;
168+
delete[] buf;
169+
sleep(1);
170+
} else {
171+
good_to_go = true;
172+
}
173+
} else {
164174
good_to_go = true;
165175
}
166-
} else {
167-
good_to_go = true;
168176
}
169177

170178
regfree(&reg);

‎main.cpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "lyricsChecker.hpp"
33
#include "mysql_store.hpp"
44
#include <iostream>
5+
#include <ctime>
56

67
using namespace std;
78

@@ -10,19 +11,30 @@ int main(int argc, char* argv[]) {
1011
LyricChecker b;
1112

1213
lyrics_mysql a;
13-
a.connect("127.0.0.1", 3306, "rduser", "letmein", "Rivendell");
14+
a.connect("127.0.0.1", 3306, "rduser", "letmein", "Rivendell");
1415

15-
int count = a.query("SELECT ARTIST,TITLE,ALBUM FROM CART WHERE GROUP_NAME=\"MUSIC\"");
16+
int count = a.query("SELECT ARTIST,TITLE,ALBUM FROM CART WHERE GROUP_NAME=\"MUSIC\" AND SCHED_CODES IS NULL");
1617
for (int i = 0; i < count; i++) {
18+
cout.flush();
1719
a.getSong(i);
20+
cout << "Got song." << endl;
1821

1922
string artist,title,album;
2023
artist = a.artist();
2124
title = a.title();
2225
album = a.album();
2326

2427
lyric_code match;
28+
cout << "Checking lyrics." << endl;
2529
match = b.isPositiveMatch(title, artist, album);
30+
cout << "Lyrics checked." << endl;
31+
32+
time_t now = time(NULL);
33+
tm now1 = *localtime(&now);
34+
35+
cout << "Song ID: " << a.title() << endl;
36+
cout << asctime(&now1);
37+
2638

2739
switch (match) {
2840
case NOT_FOUND:

‎mysql_store.cpp

+25-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,20 @@ int lyrics_mysql::mark(string group) {
2121
a << "UPDATE CART SET SCHED_CODES=\"" << group << "\" WHERE ARTIST=\"" << s_artist \
2222
<< "\" AND TITLE=\"" << s_title << "\" AND ALBUM=\"" << s_album << "\"\n";
2323

24-
mysqlpp::Query myQuery = myConnect.query(a.str().c_str());
25-
myQuery.use();
26-
24+
try {
25+
mysqlpp::Query myQuery = myConnect.query(a.str().c_str());
26+
myQuery.use();
27+
}
28+
catch(exception &e) {
29+
cerr << "Exception passed while attempting to store result." << endl;
30+
cerr << "In lyrics_mysql::mark" << endl;
31+
cerr << e.what() << endl;
32+
cout << "Exception passed while attempting to store result." << endl;
33+
cout << "In lyrics_mysql::mark" << endl;
34+
cout << e.what() << endl;
35+
exit(-1);
36+
}
37+
2738
return 1;
2839
};
2940

@@ -36,6 +47,9 @@ void lyrics_mysql::connect(string host, unsigned int port, string user, string p
3647
cerr << "Exception passed while attempting to connect to database." << endl;
3748
cerr << "In lyrics_mysql::connect" << endl;
3849
cerr << e.what() << endl;
50+
cout << "Exception passed while attempting to connect to database." << endl;
51+
cout << "In lyrics_mysql::connect" << endl;
52+
cout << e.what() << endl;
3953
exit(-1);
4054
}
4155
return;
@@ -52,6 +66,9 @@ int lyrics_mysql::query(string q) {
5266
cerr << "Exception thrown when trying to query!\n";
5367
cerr << "Inside lyrics_mysql::query\n";
5468
cerr << e.what() << endl;
69+
cout << "Exception thrown when trying to query!\n";
70+
cout << "Inside lyrics_mysql::query\n";
71+
cout << e.what() << endl;
5572
exit(-1);
5673
}
5774

@@ -64,6 +81,8 @@ void lyrics_mysql::getSong(unsigned int i) {
6481
if ((i < 0) || (i >= res.num_rows())) {
6582
cerr << "Invalid index passed!\n";
6683
cerr << "Inside lyrics_mysql::getSong\n";
84+
cout << "Invalid index passed!\n";
85+
cout << "Inside lyrics_mysql::getSong\n";
6786
exit(-1);
6887
}
6988

@@ -77,6 +96,9 @@ void lyrics_mysql::getSong(unsigned int i) {
7796
cerr << "Exception in fetching the song from results!\n";
7897
cerr << "Inside lyrics_mysql::getSong\n";
7998
cerr << e.what() << endl;
99+
cout << "Exception in fetching the song from results!\n";
100+
cout << "Inside lyrics_mysql::getSong\n";
101+
cout << e.what() << endl;
80102
exit(-1);
81103
}
82104

0 commit comments

Comments
 (0)
Please sign in to comment.