-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from smoke-trees/dev
Updated Version
- Loading branch information
Showing
4 changed files
with
58 additions
and
6 deletions.
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ == '0.0.4' | ||
__version__ == '0.0.5' |
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,43 @@ | ||
import gdown | ||
import pickle | ||
|
||
import pandas as pd | ||
|
||
|
||
class Datasets(object): | ||
""" | ||
A class for managing downloads and loading of SmokTrees' datasets | ||
""" | ||
|
||
def __init__(self, output = 'datasets.pickle', config = 'result.json'): | ||
super().__init__() | ||
|
||
self.base_url = 'https://drive.google.com/uc?id=' | ||
self.url_id = self.get_complete_url('https://drive.google.com/file/d/10G-d7rdIHsQ9s8XE1mgs6t-hfQjVD-KA/view?usp=sharing') | ||
self.output = output | ||
|
||
def get_complete_url(self, url): | ||
""" | ||
method (used internally inside class) to get complete link (including base_url) from the given url | ||
Parameters | ||
---------- | ||
url : str | ||
url to split and make complete url from | ||
Returns | ||
------- | ||
link : str | ||
complete url to the model file | ||
""" | ||
split_url = url.split('/') | ||
return self.base_url + split_url[5] | ||
|
||
def get_emo_tweets(self): | ||
try: | ||
gdown.download(self.url_id, self.output, quiet = False) | ||
gdown.download(self.get_complete_url(pickle.load(open(self.output, 'rb'))['emotion_tweets']['link']), 'tweets.csv', quiet = False) | ||
return pd.read_csv('tweets.csv') | ||
except: | ||
print("[ERROR]:Error in loading dataset, please check downloaded file") |
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