{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from biased_stop_words import get_stop_words\n", "from sklearn.feature_extraction.text import CountVectorizer" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "biased_stop_words = get_stop_words('gendered')\n", "corpus = [\n", " 'He is an astronaut, he is on Venus',\n", " 'He is an accountant, he is on Earth',\n", " 'She is an astronaut, she is on Mars'\n", "]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['accountant', 'an', 'astronaut', 'earth', 'is', 'mars', 'on', 'venus']\n", "[[0 1 1 0 2 0 1 1]\n", " [1 1 0 1 2 0 1 0]\n", " [0 1 1 0 2 1 1 0]]\n" ] } ], "source": [ "vectorizer = CountVectorizer(stop_words=biased_stop_words)\n", "X = vectorizer.fit_transform(corpus)\n", "print(vectorizer.get_feature_names())\n", "\n", "print(X.toarray()) " ] } ], "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.0" } }, "nbformat": 4, "nbformat_minor": 2 }