Skip to content

Commit

Permalink
Updated black
Browse files Browse the repository at this point in the history
  • Loading branch information
romatik committed Feb 19, 2024
1 parent 9d5aefe commit 7a2f313
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
26 changes: 14 additions & 12 deletions extra_model/_adjectives.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,27 +212,29 @@ def adjective_info(dataframe_topics, dataframe_aspects, vectorizer):
)

dataframe_aspects["sentiment_compound"] = dataframe_aspects["descriptor"].apply(
lambda descriptor: sentiment_dict[descriptor][0]
if descriptor in sentiment_dict
else 0
lambda descriptor: (
sentiment_dict[descriptor][0] if descriptor in sentiment_dict else 0
)
)
dataframe_aspects["sentiment_binary"] = dataframe_aspects["descriptor"].apply(
lambda descriptor: sentiment_dict[descriptor][1]
if descriptor in sentiment_dict
else 0
lambda descriptor: (
sentiment_dict[descriptor][1] if descriptor in sentiment_dict else 0
)
)

# flip sentiment if adjective is negated
dataframe_aspects["sentiment_compound"] = dataframe_aspects.apply(
lambda x: x["sentiment_compound"] * (-1)
if x["is_negated"]
else x["sentiment_compound"],
lambda x: (
x["sentiment_compound"] * (-1)
if x["is_negated"]
else x["sentiment_compound"]
),
axis=1,
)
dataframe_aspects["sentiment_binary"] = dataframe_aspects.apply(
lambda x: x["sentiment_binary"] * (-1)
if x["is_negated"]
else x["sentiment_binary"],
lambda x: (
x["sentiment_binary"] * (-1) if x["is_negated"] else x["sentiment_binary"]
),
axis=1,
)
return dataframe_topics, dataframe_aspects
1 change: 1 addition & 0 deletions extra_model/_disambiguate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions to do word-sense disambiguation using artifical contexts."""

import logging
import math

Expand Down
1 change: 1 addition & 0 deletions extra_model/_summarize.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fill out and link the dataframes for topics, aspects and texts. Provide some summary ouput if debug-level is set to info or lower."""

import logging

logger = logging.getLogger(__name__)
Expand Down
12 changes: 9 additions & 3 deletions extra_model/_topics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Aggregate aspects into semantic clusters ('topics')."""

import logging
from collections import Counter

Expand Down Expand Up @@ -419,9 +420,14 @@ def get_topics(dataframe_aspects, vectors):
aspects, synsets_match = match(aspect_counts, vectors)
disambiguation_dict = dict(zip(aspects, synsets_match))
dataframe_aspects.loc[:, "wordnet_node"] = dataframe_aspects["aspect"].apply(
lambda aspect: disambiguation_dict[aspect].name()
if (aspect in disambiguation_dict and disambiguation_dict[aspect] is not None)
else None
lambda aspect: (
disambiguation_dict[aspect].name()
if (
aspect in disambiguation_dict
and disambiguation_dict[aspect] is not None
)
else None
)
)

# build the hypernym graph
Expand Down
1 change: 1 addition & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test package init."""

import extra_model


Expand Down

0 comments on commit 7a2f313

Please sign in to comment.