Skip to content

Commit

Permalink
Updated sentiment analysis component and overall project configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
aadiraju committed Mar 24, 2021
1 parent f5429f9 commit 73f42e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ pipeline:
# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
# # If you'd like to customize it, uncomment and adjust the pipeline.
# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
- name: WhitespaceTokenizer
- name: SpacyNLP
- name: SpacyTokenizer
- name: sentiment.SentimentAnalyzer
- name: SpacyFeaturizer
- name: RegexFeaturizer
- name: LexicalSyntacticFeaturizer
- name: CountVectorsFeaturizer
Expand Down
Binary file not shown.
9 changes: 7 additions & 2 deletions sentiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,19 @@ def process(self, message, **kwargs):
and append the prediction results to the message class."""

sid = SentimentIntensityAnalyzer()
res = sid.polarity_scores(message.text)
data = ""
try:
data = message.data['text']
except KeyError:
pass
res = sid.polarity_scores(data)
key, value = max(res.items(), key=lambda x: x[1])

entity = self.convert_to_rasa(key, value)

message.set("entities", [entity], add_to_output=True)

def persist(self, model_dir):
def persist(self, file_name, model_dir):
"""Pass because a pre-trained model is already persisted"""

pass

0 comments on commit 73f42e5

Please sign in to comment.