Spaces:
Runtime error
Runtime error
Commit
·
c5e142f
1
Parent(s):
913f93c
Rename nlpapp_4900.py to app.py
Browse files- nlpapp_4900.py → app.py +15 -3
nlpapp_4900.py → app.py
RENAMED
@@ -44,14 +44,26 @@ import threading
|
|
44 |
auto_reconnect_thread = threading.Thread(target=auto_reconnect)
|
45 |
auto_reconnect_thread.start()
|
46 |
|
|
|
|
|
|
|
47 |
!pip install transformers torch gradio
|
48 |
|
49 |
-
# Download and extract the Yelp review dataset
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
import pandas as pd
|
54 |
|
|
|
55 |
train_df = pd.read_csv('yelp_review_polarity_csv/train.csv', header=None, names=['label', 'text'])
|
56 |
test_df = pd.read_csv('yelp_review_polarity_csv/test.csv', header=None, names=['label', 'text'])
|
57 |
|
|
|
44 |
auto_reconnect_thread = threading.Thread(target=auto_reconnect)
|
45 |
auto_reconnect_thread.start()
|
46 |
|
47 |
+
# Python equivalent syntax of the Colab Notebook
|
48 |
+
|
49 |
+
# Install required libraries
|
50 |
!pip install transformers torch gradio
|
51 |
|
52 |
+
# Download and extract the Yelp review dataset
|
53 |
+
import urllib.request
|
54 |
+
import tarfile
|
55 |
+
|
56 |
+
url = 'https://s3.amazonaws.com/fast-ai-nlp/yelp_review_polarity_csv.tgz'
|
57 |
+
filename = 'yelp_review_polarity_csv.tgz'
|
58 |
+
|
59 |
+
urllib.request.urlretrieve(url, filename)
|
60 |
+
|
61 |
+
with tarfile.open(filename, 'r:gz') as tar:
|
62 |
+
tar.extractall()
|
63 |
|
64 |
import pandas as pd
|
65 |
|
66 |
+
# Load training and testing datasets
|
67 |
train_df = pd.read_csv('yelp_review_polarity_csv/train.csv', header=None, names=['label', 'text'])
|
68 |
test_df = pd.read_csv('yelp_review_polarity_csv/test.csv', header=None, names=['label', 'text'])
|
69 |
|