Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Feature vector creation raises errors on empty fields in raw data #25

Open
sechkova opened this issue Jan 20, 2022 · 0 comments
Open

Feature vector creation raises errors on empty fields in raw data #25

sechkova opened this issue Jan 20, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@sechkova
Copy link
Contributor

sechkova commented Jan 20, 2022

Describe the bug

If the raw data .csv files contain empty fields (fields that equal nan values), the automatic feature creation crashes with an error.

Reproduction steps

python ./ml-conversational-analytic-tool/featureVector.py <rawdatafile>

Traceback (most recent call last):
  File "~/workspace/ml-conversational-analytic-tool/ml-conversational-analytic-tool/featureVector.py", line 162, in <module>
    df = featurizer.formFeatures()
  File "~/workspace/ml-conversational-analytic-tool/ml-conversational-analytic-tool/featureVector.py", line 70, in formFeatures
    pull_analyzed = self.commentAnalyzer.analyzeComment(row["Body"])
  File "~/workspace/ml-conversational-analytic-tool/ml-conversational-analytic-tool/commentAnalysis.py", line 31, in analyzeComment
    result['Sentiment'] = self.getSentiment(comment)  # Determine sentiment
  File "~/workspace/ml-conversational-analytic-tool/ml-conversational-analytic-tool/commentAnalysis.py", line 77, in getSentiment
    return self.vader_sentiment.polarity_scores(comment)["compound"]
  File "~/workspace/ml-conversational-analytic-tool/.env/lib/python3.10/site-packages/nltk/sentiment/vader.py", line 361, in polarity_scores
    sentitext = SentiText(
  File "~/workspace/ml-conversational-analytic-tool/.env/lib/python3.10/site-packages/nltk/sentiment/vader.py", line 270, in __init__
    text = str(text.encode("utf-8"))
AttributeError: 'float' object has no attribute 'encode'

Expected behavior

Preprocess the input raw data in order to handle empty/nan fields.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant