Skip to content
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

Merged
merged 26 commits into from
Nov 28, 2017
Merged

Sentiment analysis #33

merged 26 commits into from
Nov 28, 2017

Conversation

jnelson16
Copy link
Member

Also raises errors if certain modules are not installed


@decorator
def check_nltk(func, *args, **kwargs):
if args[-1] is None:
Copy link
Member

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


@decorator
def check_textblob(func, *args, **kwargs):
if args[-2] is None:
Copy link
Member

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
Copy link
Member

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'
]
Copy link
Member

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?

help='Performs sentiment analysis on the text',
arguments=[
quantgov.utils.CLIArg(
flags=('--analyzer'),
Copy link
Member

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"?

sentences = textblob.TextBlob(doc.text).sentences
return doc.index + (round(sum(len(
sentence.words) for sentence in sentences) /
len(sentences), int(precision)),)
Copy link
Member

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.


import quantgov

try:
import nltk.corpus
Copy link
Member

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.

@jnelson16
Copy link
Member Author

@OliverSherouse ready for another look

@OliverSherouse OliverSherouse merged commit e3f9c7a into QuantGov:dev Nov 28, 2017
OliverSherouse added a commit that referenced this pull request Apr 17, 2018
* 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
OliverSherouse added a commit that referenced this pull request Apr 17, 2018
* 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
OliverSherouse added a commit that referenced this pull request May 21, 2018
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants