Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b354ef
commit 50de61a
Showing
6 changed files
with
173 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ startup/PID_DIR/* | |
*.log | ||
web/.idea | ||
twitter-geo.dump | ||
allCountries.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from database.database import Database | ||
|
||
db = Database("twitter-geo") | ||
|
||
print ("Connection Established") | ||
|
||
file = open("allCountries.txt", 'r') | ||
|
||
|
||
progress = 0 | ||
|
||
for line in file: | ||
entries = line.split('\t') | ||
remove_newline_from_last = entries[-1].split('\n')[0] | ||
|
||
i = 0 | ||
for entry in entries: | ||
if entries[i] == '': | ||
entries[i] = None | ||
i+=1 | ||
|
||
db.loadCountries(entries[0], entries[1], entries[2], entries[3], entries[4], | ||
entries[5], entries[6], entries[7], entries[8], entries[9], | ||
entries[10], entries[11], entries[12], entries[13], entries[14], | ||
entries[15], entries[16], entries[17], remove_newline_from_last) | ||
progress += 1 | ||
if (progress%100000 == 0): | ||
print ("Processed lines: ", progress) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from database import Database | ||
|
||
class Database(Database): | ||
|
||
|
||
#retweeted_id --> tweeten är en retweet | ||
#in_reply_to_user_id --> någon har blivit mentioned | ||
#in_reply_to_status_id --> tweeten är ett svar på en annan tweet | ||
#original_tweet_retweet_count --> finns bara på kommenterade retweets | ||
#En retweet är en "ren" retweet om attributet "original_tweet_retweet_count" inte är null | ||
#En retweet är en "kommenterad" retweet om attributet "original_tweet_retweet_count" är null | ||
|
||
#Statements för att hämta ut statistik | ||
#SELECT count(*) FROM tweets WHERE retweeted_id IS NOT NULL AND in_reply_to_status_id IS NOT NULL AND | ||
#SELECT count(*) FROM tweets WHERE retweeted_id IS NOT NULL AND in_reply_to_status_id IS NOT NULL AND | ||
#SELECT count(*) FROM tweets WHERE retweeted_id IS NOT NULL AND in_reply_to_status_id IS NULL AND in_ | ||
#SELECT count(*) FROM tweets WHERE retweeted_id IS NOT NULL AND in_reply_to_status_id IS NULL AND in_ | ||
#SELECT count(*) FROM tweets WHERE retweeted_id IS NULL AND in_reply_to_status_id IS NOT NULL AND in_ | ||
#SELECT count(*) FROM tweets WHERE retweeted_id IS NULL AND in_reply_to_status_id IS NOT NULL AND in_ | ||
#SELECT count(*) FROM tweets WHERE retweeted_id IS NULL AND in_reply_to_status_id IS NULL AND in_repl | ||
#SELECT count(*) FROM tweets WHERE retweeted_id IS NULL AND in_reply_to_status_id IS NULL AND in_repl | ||
|
||
def get_total_clean_retweet_count(self): | ||
cur = self.conn.cursor() | ||
|
||
statement = """ | ||
SELECT count(*) FROM tweets WHERE retweeted_id IS NOT NULL | ||
AND in_reply_to_status_id IS NULL | ||
AND in_reply_to_user_id IS NULL; | ||
""" | ||
|
||
cur.execute(statement) | ||
retweet_count = cur.fetchone() | ||
|
||
cur.close() | ||
return retweet_count[0] | ||
|
||
def get_total_commented_retweet_count(self): | ||
cur = self.conn.cursor() | ||
|
||
statement = """ | ||
SELECT count(*) FROM tweets | ||
WHERE retweeted_id IS NOT NULL | ||
AND in_reply_to_status_id IS NULL | ||
AND in_reply_to_user_id IS NOT NULL | ||
""" | ||
cur.execute(statement) | ||
commented_retweet_count = cur.fetchone() | ||
|
||
cur.close() | ||
return commented_retweet_count[0] | ||
|
||
def get_total_reply_count(self): | ||
cur = self.conn.cursor() | ||
|
||
statement = """ | ||
SELECT count(*) FROM tweets | ||
WHERE retweeted_id IS NOT NULL | ||
AND in_reply_to_status_id IS NOT NULL | ||
AND in_reply_to_user_id IS NOT NULL; | ||
""" | ||
cur.execute(statement) | ||
commented_retweet_count = cur.fetchone() | ||
|
||
cur.close() | ||
return commented_retweet_count[0] | ||
|
||
def get_total_mention_count(self): | ||
cur = self.conn.cursor() | ||
|
||
statement = """ | ||
select count(*) from tweets | ||
where in_reply_to_user_id <> 25073877 | ||
AND text ILIKE '@realDonaldTrump%'; | ||
""" | ||
cur.execute(statement) | ||
commented_retweet_count = cur.fetchone() | ||
|
||
cur.close() | ||
return commented_retweet_count[0] |