Spaces:
Running
Running
Create import_nltk_files.py
Browse files- import_nltk_files.py +24 -0
import_nltk_files.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import shutil
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
try:
|
| 5 |
+
print("Importing nltk files...")
|
| 6 |
+
|
| 7 |
+
# Define source and destination paths
|
| 8 |
+
source_folder = '/home/user/app/nltk_data'
|
| 9 |
+
destination_folder = '/home/user/nltk_data'
|
| 10 |
+
|
| 11 |
+
# Ensure the destination folder exists, create if it doesn't
|
| 12 |
+
os.makedirs(destination_folder, exist_ok=True)
|
| 13 |
+
|
| 14 |
+
# Move the source folder to the destination
|
| 15 |
+
shutil.move(source_folder, destination_folder)
|
| 16 |
+
|
| 17 |
+
print(f"NLTK folder moved to {destination_folder}")
|
| 18 |
+
|
| 19 |
+
except FileNotFoundError as fnf_error:
|
| 20 |
+
print(f"Error: Source folder not found. {fnf_error}")
|
| 21 |
+
except PermissionError as perm_error:
|
| 22 |
+
print(f"Error: Permission denied. {perm_error}")
|
| 23 |
+
except Exception as e:
|
| 24 |
+
print(f"An unexpected error occurred: {e}")
|