Skip to content

Commit 548dda5

Browse files
committed
v 1.0
1 parent 6a59f76 commit 548dda5

File tree

4 files changed

+136
-42
lines changed

4 files changed

+136
-42
lines changed

.gitignore

Lines changed: 91 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,94 @@
1-
venv/
2-
dist/
3-
*.egg-info/
1+
# Byte-compiled / optimized / DLL files
42
__pycache__/
3+
*.py[cod]
4+
*$py.class
55

6-
sentibank/__pycache__/
7-
sentibank/dict_arXiv/__pycache__/
6+
# C extensions
7+
*.so
88

9-
test.py
10-
test.ipynb
11-
note.txt
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.nox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
*.py,cover
48+
.hypothesis/
49+
.pytest_cache/
50+
cover/
51+
52+
# Environments
53+
.env
54+
.venv
55+
env/
56+
venv/
57+
ENV/
58+
env.bak/
59+
venv.bak/
60+
61+
# IDEs
62+
.idea/
63+
.vscode/
64+
*.swp
65+
*.swo
66+
*~
67+
.DS_Store
68+
69+
# Jupyter Notebook
70+
.ipynb_checkpoints
71+
72+
# IPython
73+
profile_default/
74+
ipython_config.py
75+
76+
# pyenv
77+
.python-version
78+
79+
# mypy
80+
.mypy_cache/
81+
.dmypy.json
82+
dmypy.json
83+
84+
# Pyre type checker
85+
.pyre/
86+
87+
# pytype static type analyzer
88+
.pytype/
89+
90+
# Cython debug symbols
91+
cython_debug/
92+
93+
# test.py (for local testing)
94+
test.py

sentibank/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.2.4'

sentibank/utils.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import re
1111
import enchant
1212
from sentibank import archive
13+
import subprocess
14+
import sys
1315

1416
load = archive.load()
1517

@@ -26,10 +28,37 @@ def __init__(self):
2628
"""
2729
Initializes the Analysis class by loading the Spacy NLP pipeline with emoji detection.
2830
"""
29-
self.spacy_nlp = spacy.load(
30-
"en_core_web_sm",
31-
exclude=["parser", "senter", "attribute_ruler", "lemmatizer", "ner"],
32-
)
31+
try:
32+
self.spacy_nlp = spacy.load(
33+
"en_core_web_sm",
34+
exclude=["parser", "senter", "attribute_ruler", "lemmatizer", "ner"],
35+
)
36+
except OSError:
37+
# Model not found, attempt to download it
38+
import subprocess
39+
import sys
40+
41+
print("SpaCy model 'en_core_web_sm' not found. Downloading...")
42+
try:
43+
subprocess.check_call(
44+
[sys.executable, "-m", "spacy", "download", "en_core_web_sm"],
45+
stdout=subprocess.DEVNULL, # Suppress output for cleaner experience
46+
stderr=subprocess.STDOUT
47+
)
48+
# Try loading again after download
49+
self.spacy_nlp = spacy.load(
50+
"en_core_web_sm",
51+
exclude=["parser", "senter", "attribute_ruler", "lemmatizer", "ner"],
52+
)
53+
print("Successfully downloaded and loaded en_core_web_sm")
54+
except subprocess.CalledProcessError:
55+
raise RuntimeError(
56+
"Failed to download spaCy model automatically.\n"
57+
"Please install it manually by running:\n"
58+
" python -m spacy download en_core_web_sm"
59+
)
60+
61+
# Add emoji detection pipeline (this stays the same)
3362
# self.spacy_nlp.add_pipe("sentencizer")
3463
self.spacy_nlp.add_pipe("emoji", first=True)
3564

setup.py

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,29 @@
11
from setuptools import setup
2-
from setuptools.command.install import install
3-
import subprocess
4-
import sys
5-
6-
with open('README.md') as f:
7-
long_description = f.read()
8-
9-
class CustomInstallCommand(install):
10-
def run(self):
11-
install.run(self)
12-
subprocess.check_call([sys.executable, "-m", "spacy", "download", "en_core_web_sm"])
13-
# def run(self):
14-
# install.run(self)
15-
# if 'en_core_web_sm' not in spacy.util.get_installed_models():
16-
# subprocess.check_call([sys.executable, "-m", "spacy", "download", "en_core_web_sm"])
172

183
setup(
194
name='sentibank',
205
packages=['sentibank'],
216
package_data={'sentibank': ['dict_arXiv/*.csv', 'dict_arXiv/*.pickle', 'dict_arXiv/*.json']},
22-
version='0.2.3',
7+
version='1.0',
238
license='CC BY-NC-SA 4.0',
249
description='Unifying sentiment lexicons and dictionaries into an accessible open python package',
25-
long_description=long_description,
26-
long_description_content_type='text/markdown',
27-
author='Nick S.H Oh',
28-
author_email='research@socius.org',
10+
author='Nick Oh',
11+
author_email='nick.sh.oh@socius.org',
2912
url='https://github.com/socius-org/sentibank',
30-
download_url='https://github.com/socius-org/sentibank/archive/refs/tags/0.2.3.tar.gz',
13+
download_url='https://github.com/socius-org/sentibank/archive/refs/tags/0.2.4.tar.gz', # Updated
3114
keywords=[
3215
'Sentiment Analysis',
3316
'Sentiment Dictionary',
3417
'Sentiment Lexicon',
3518
'Semantic Orientation'
3619
],
3720
install_requires=[
38-
'spacy == 3.7.2',
39-
'spacymoji == 3.1.0',
40-
'rich == 13.4.2',
41-
'pandas == 2.1.4',
42-
'pyenchant == 3.2.2'
21+
'spacy>=3.7.2',
22+
'spacymoji>=3.1.0',
23+
'rich>=13.4.2',
24+
'pandas>=2.1.4',
25+
'pyenchant>=3.2.2'
4326
],
27+
python_requires='>=3.8',
4428
include_package_data=True,
45-
cmdclass={
46-
'install': CustomInstallCommand,
47-
}
48-
)
29+
)

0 commit comments

Comments
 (0)