Created
December 16, 2019 00:15
-
-
Save pgolding/60b36668a0422eeb4ce146991e0c4736 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"metadata": { | |
"trusted": true, | |
"collapsed": false, | |
"editable": true, | |
"deletable": true | |
}, | |
"cell_type": "code", | |
"source": "from sklearn.feature_extraction.text import CountVectorizer\nSentence_1 = [\"John likes to watch movies. Mary likes movies too.\"]\nvectorizer = CountVectorizer()\nX = vectorizer.fit_transform(Sentence_1)\nprint(X)", | |
"execution_count": 8, | |
"outputs": [ | |
{ | |
"text": " (0, 5)\t1\n (0, 2)\t1\n (0, 3)\t2\n (0, 6)\t1\n (0, 4)\t1\n (0, 1)\t2\n (0, 0)\t1\n", | |
"name": "stdout", | |
"output_type": "stream" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true, | |
"collapsed": false, | |
"editable": true, | |
"deletable": true | |
}, | |
"cell_type": "code", | |
"source": "print(vectorizer.get_feature_names())\n", | |
"execution_count": 9, | |
"outputs": [ | |
{ | |
"text": "['john', 'likes', 'mary', 'movies', 'to', 'too', 'watch']\n", | |
"name": "stdout", | |
"output_type": "stream" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true, | |
"collapsed": true, | |
"editable": true, | |
"deletable": true | |
}, | |
"cell_type": "code", | |
"source": "", | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"language_info": { | |
"codemirror_mode": { | |
"version": 3, | |
"name": "ipython" | |
}, | |
"mimetype": "text/x-python", | |
"file_extension": ".py", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.7", | |
"nbconvert_exporter": "python", | |
"name": "python" | |
}, | |
"kernelspec": { | |
"name": "conda-env-faq-py", | |
"display_name": "Python [conda env:faq]", | |
"language": "python" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment