Skip to content

Instantly share code, notes, and snippets.

@LowriWilliams
Created January 25, 2021 14:04
Show Gist options
  • Save LowriWilliams/cb163c65f2ee51d5fc6bb526194a2526 to your computer and use it in GitHub Desktop.
Save LowriWilliams/cb163c65f2ee51d5fc6bb526194a2526 to your computer and use it in GitHub Desktop.
wn/synonyms_antonyms.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'dear', 'in_force', 'practiced', 'serious', 'in_effect', 'adept', 'proficient', 'thoroughly', 'skilful', 'upright', 'unspoilt', 'near', 'honorable', 'safe', 'honest', 'unspoiled', 'beneficial', 'right', 'well', 'undecomposed', 'skillful', 'commodity', 'ripe', 'dependable', 'secure', 'sound', 'good', 'expert', 'soundly', 'salutary', 'trade_good', 'full', 'estimable', 'respectable', 'goodness', 'just', 'effective'}\n",
"\n",
"\n",
"{'badness', 'bad', 'evil', 'evilness', 'ill'}\n"
]
}
],
"source": [
"synonyms = [] \n",
"antonyms = [] \n",
" \n",
"for syn in wn.synsets(\"good\"): \n",
" for l in syn.lemmas(): \n",
" synonyms.append(l.name()) \n",
" if l.antonyms(): \n",
" antonyms.append(l.antonyms()[0].name()) \n",
" \n",
"print(set(synonyms)) \n",
"print(\"\\n\")\n",
"print(set(antonyms)) "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment