-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sentiment analysis #33
Conversation
complexity builtins
in setup.py
nltk fixes
nltk troubles
quantgov/corpora/utils.py
Outdated
|
||
@decorator | ||
def check_nltk(func, *args, **kwargs): | ||
if args[-1] is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we passing this as an argument? It's available module wide. Just do if NLTK
quantgov/corpora/utils.py
Outdated
|
||
@decorator | ||
def check_textblob(func, *args, **kwargs): | ||
if args[-2] is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here. if textblob is None
setup.cfg
Outdated
@@ -3,7 +3,7 @@ universal = 1 | |||
[tool:pytest] | |||
addopts = --flake8 | |||
flake8-ignore = | |||
*.py W391 W503 | |||
*.py W391 W503 F821 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't ignore this; it's an important error. Where are you getting it?
setup.py
Outdated
'textblob', | ||
'nltk', | ||
'decorator' | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decorator needs to be in the main requires, since it's used regardless. I don't like the name builtins
; maybe nlp
?
quantgov/corpora/builtins.py
Outdated
help='Performs sentiment analysis on the text', | ||
arguments=[ | ||
quantgov.utils.CLIArg( | ||
flags=('--analyzer'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did I tell you to do this? If not, it's good forward thinking! But a bad variable name. Maybe "backend"?
quantgov/corpora/builtins.py
Outdated
sentences = textblob.TextBlob(doc.text).sentences | ||
return doc.index + (round(sum(len( | ||
sentence.words) for sentence in sentences) / | ||
len(sentences), int(precision)),) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the user wants unrounded output? Maybe if precision = None
return unrounded, otherwise the rounded version.
quantgov/corpora/builtins.py
Outdated
|
||
import quantgov | ||
|
||
try: | ||
import nltk.corpus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not to make this more complicated than it already is, but we need specific NLTK corpora, right? We should check for those and either download them automatically or (probably better) tell the user how to do so.
@OliverSherouse ready for another look |
* Inaugurated 0.4.0 dev series * Sentiment analysis (#33) Closes #11 #12 #13 and adds Sentiment analysis! * complexity * complexity builtins * complexity builtins with tests * code review updates * option tests * added nltk requirement in setup.py * add pip install to .travis.yml * nltk fixes * another nltk fix * last nltk fix? * you know the drill * Update .travis.yml * nltk troubles * some final cleanup * if it aint broke... * textblob sentiment * tests and error raising * fixed install req * pep8 fixes * code review updates * fix travis file * import fixes * small fix * Test corpora (#35) * complexity * complexity builtins * complexity builtins with tests * code review updates * option tests * added nltk requirement in setup.py * add pip install to .travis.yml * nltk fixes * another nltk fix * last nltk fix? * you know the drill * Update .travis.yml * nltk troubles * some final cleanup * new corpora in English!! * hotfix to add timestamp as corpus identifier * Skl compatibility (#41) * Add sklearn 0.17 compatibility Paper over library reorganization. * renamed corpora to corpus, added deprecation warning (#42) * renamed corpora to corpus, added deprecation warning * moved load_driver and set up for future forcing of full imports of submodules Closes #31 * S3 drivers (#44) * initial working commit for s3 driver and database driver * removing 3.6 formatting * adding extra requirements list * adding basic s3 driver test * Removing unnecessary function * This ain't 2007 * test updates * adding s3driver to new corpus structure * Rounding (#45) * bumped version
* Inaugurated 0.4.0 dev series * Sentiment analysis (#33) Closes #11 #12 #13 and adds Sentiment analysis! * complexity * complexity builtins * complexity builtins with tests * code review updates * option tests * added nltk requirement in setup.py * add pip install to .travis.yml * nltk fixes * another nltk fix * last nltk fix? * you know the drill * Update .travis.yml * nltk troubles * some final cleanup * if it aint broke... * textblob sentiment * tests and error raising * fixed install req * pep8 fixes * code review updates * fix travis file * import fixes * small fix * Test corpora (#35) * complexity * complexity builtins * complexity builtins with tests * code review updates * option tests * added nltk requirement in setup.py * add pip install to .travis.yml * nltk fixes * another nltk fix * last nltk fix? * you know the drill * Update .travis.yml * nltk troubles * some final cleanup * if it aint broke... * new corpora in English!! * hotfix to add timestamp as corpus identifier * Skl compatibility (#41) * Add sklearn 0.17 compatibility Paper over library reorganization. * renamed corpora to corpus, added deprecation warning (#42) * renamed corpora to corpus, added deprecation warning * moved load_driver and set up for future forcing of full imports of submodules Closes #31 * S3 drivers (#44) * initial working commit for s3 driver and database driver * removing 3.6 formatting * adding extra requirements list * adding basic s3 driver test * Removing unnecessary function * This ain't 2007 * test updates * adding s3driver to new corpus structure * Rounding (#45) * bumped version * Fix NLTK loading bug Fix evaluation order when NLTK is not present
* hotfix to add timestamp as corpus identifier (#39) * bumped version * Release 0.4 (#47) * Inaugurated 0.4.0 dev series * Sentiment analysis (#33) Closes #11 #12 #13 and adds Sentiment analysis! * complexity * complexity builtins * complexity builtins with tests * code review updates * option tests * added nltk requirement in setup.py * add pip install to .travis.yml * nltk fixes * another nltk fix * last nltk fix? * you know the drill * Update .travis.yml * nltk troubles * some final cleanup * if it aint broke... * textblob sentiment * tests and error raising * fixed install req * pep8 fixes * code review updates * fix travis file * import fixes * small fix * Test corpora (#35) * complexity * complexity builtins * complexity builtins with tests * code review updates * option tests * added nltk requirement in setup.py * add pip install to .travis.yml * nltk fixes * another nltk fix * last nltk fix? * you know the drill * Update .travis.yml * nltk troubles * some final cleanup * new corpora in English!! * hotfix to add timestamp as corpus identifier * Skl compatibility (#41) * Add sklearn 0.17 compatibility Paper over library reorganization. * renamed corpora to corpus, added deprecation warning (#42) * renamed corpora to corpus, added deprecation warning * moved load_driver and set up for future forcing of full imports of submodules Closes #31 * S3 drivers (#44) * initial working commit for s3 driver and database driver * removing 3.6 formatting * adding extra requirements list * adding basic s3 driver test * Removing unnecessary function * This ain't 2007 * test updates * adding s3driver to new corpus structure * Rounding (#45) * bumped version * Fix NLTK loading bug Fix evaluation order when NLTK is not present
Also raises errors if certain modules are not installed