Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions awe_components/components/utility_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2899,6 +2899,9 @@ def setTokenEntry(name, token, value):
# attribute. #
# TBD: put security check in for this #
#######################################
elif "blob" in name:
name = name.replace("blob.", "")
entry['value'] = getattr(token._.blob, name)
elif token.has_extension(name):
# TODO: Use Token.get_extension
# https://spacy.io/api/token
Expand Down Expand Up @@ -3384,6 +3387,16 @@ def AWE_Info(document: Doc,
raise AWE_Workbench_Error(
'Invalid indicator ' + indicator)

# QUICK FIX: spacytextblob no longer references polarity, subjectivity,
# nor assessments via doc._.X, but rather doc._.blob.X
# We are quickly fixing this problem in AWE_Info
if indicator == "polarity":
indicator = "blob.polarity"
elif indicator == "subjectivity":
indicator = "blob.subjectivity"
elif indicator == "assessments":
indicator = "blob.assessments"

if infoType == 'Doc':
baseInfo = createSpanInfo(indicator,
document)
Expand Down
14 changes: 7 additions & 7 deletions awe_components/components/viewpointFeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4636,15 +4636,15 @@ def propagateNegation(self, doc: Doc):
# neutral.
if tok._.vwp_evaluation \
or tok._.vwp_hedge \
or tok.text in doc._.assessments:
if tok._.polarity < 0 or tok._.sentiword < 0:
tok._.vwp_tone_ = min(tok._.polarity, tok._.sentiword)
elif tok._.polarity > 0 and tok._.sentiword > 0:
tok._.vwp_tone_ = max(tok._.polarity, tok._.sentiword)
or tok.text in doc._.blob.sentiment_assessments.assessments:
if tok._.blob.sentiment_assessments.polarity < 0 or tok._.sentiword < 0:
tok._.vwp_tone_ = min(tok._.blob.sentiment_assessments.polarity, tok._.sentiword)
elif tok._.blob.sentiment_assessments.polarity > 0 and tok._.sentiword > 0:
tok._.vwp_tone_ = max(tok._.blob.sentiment_assessments.polarity, tok._.sentiword)
else:
tok._.vwp_tone_ = (tok._.polarity + tok._.sentiword) / 2
tok._.vwp_tone_ = (tok._.blob.sentiment_assessments.polarity + tok._.sentiword) / 2
else:
tok._.vwp_tone_ = min(tok._.polarity, tok._.sentiword)
tok._.vwp_tone_ = min(tok._.blob.sentiment_assessments.polarity, tok._.sentiword)

# rule order fixes to the tone variable are generally a bad idea,
# but these are so common that fixing them gets rid of a lot of
Expand Down