remove negative words
This commit is contained in:
@@ -238,6 +238,54 @@
|
|||||||
" writer = csv.writer(csvfile)\n",
|
" writer = csv.writer(csvfile)\n",
|
||||||
" writer.writerows(single_syllable_nouns_cleaned)"
|
" writer.writerows(single_syllable_nouns_cleaned)"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 14,
|
||||||
|
"id": "836b0473-2b4f-4c82-921e-1d6ed51c65f3",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from textblob import TextBlob\n",
|
||||||
|
"\n",
|
||||||
|
"# Alternative method using sentiment analysis (requires: pip install textblob)\n",
|
||||||
|
"def is_negative(word):\n",
|
||||||
|
" # Simple sentiment check - words with negative polarity\n",
|
||||||
|
" analysis = TextBlob(word)\n",
|
||||||
|
" return analysis.sentiment.polarity < -0.1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 20,
|
||||||
|
"id": "1c9517b7-a17a-4c94-9bd6-ca0da1cfd708",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"cow\n",
|
||||||
|
"game\n",
|
||||||
|
"green\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"for word in single_syllable_nouns_cleaned:\n",
|
||||||
|
" if is_negative(word):\n",
|
||||||
|
" print(word)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 15,
|
||||||
|
"id": "3a2e6440-842c-4a2f-be1e-49b4771c651b",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"sentiment_filtered_nouns = [word for word in single_syllable_nouns_cleaned if not is_negative(word)]"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
Reference in New Issue
Block a user