Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nltk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
nltk
Commits
a045c561
Commit
a045c561
authored
Apr 26, 2015
by
Ewan Klein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extracted method to check for presence of 'but'
parent
6e9f49c4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
nltk/sentiment/vader.py
+6
-2
No files found.
nltk/sentiment/vader.py
View file @
a045c561
...
...
@@ -495,6 +495,11 @@ class SentimentIntensityDetector(object):
valence
=
valence
*
n_scalar
sentiments
.
append
(
valence
)
sentiments
=
self
.
_but_check
(
words_and_emoticons
,
sentiments
)
return
self
.
score_valence
(
sentiments
,
text
)
def
_but_check
(
self
,
words_and_emoticons
,
sentiments
):
# check for modification in sentiment due to contrastive conjunction 'but'
if
'but'
in
words_and_emoticons
or
'BUT'
in
words_and_emoticons
:
try
:
...
...
@@ -509,8 +514,7 @@ class SentimentIntensityDetector(object):
elif
si
>
bi
:
sentiments
.
pop
(
si
)
sentiments
.
insert
(
si
,
sentiment
*
1.5
)
return
self
.
score_valence
(
sentiments
,
text
)
return
sentiments
def
score_valence
(
self
,
sentiments
,
text
):
if
sentiments
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment